We are providing Quality Education for C Language, C++ Language, C# Language ,Asp.net, Asp.net MVC with All framework as like MVC2 MVC3 MVC4 MVC5 MVC6 and Also we are providing Many Post mvc With Entity and Link Framework
Tuesday, 20 October 2015
Saturday, 3 October 2015
Asp.Net Page life-cycle event
Asp. Net Page Life Cycle events
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="pagelifecycle.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<br />
<br />
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</div>
</form>
</body>
</html>
ASP.Net Grid View Tutorial
Insert Update Delete Using grid View :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;
namespace gridviewinserupdatedel
{
public class mydblayer
{
public int empid { get; set; }
public string empname { get; set; }
public string gender { get; set; }
public string empphoto { get; set; }
}
public class empdataaccesslayer
{
public static List<mydblayer> getallemployee()
{
List<mydblayer> listemp = new List<mydblayer>();
string cs = ConfigurationManager.ConnectionStrings["iuConnectionString"].ToString();
SqlConnection cn = new SqlConnection(cs);
SqlCommand cmd = new SqlCommand("select * from employeedt",cn);
cn.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
mydblayer employeedata = new mydblayer();
employeedata.empid = Convert.ToInt32(dr[0]);
employeedata.empname = dr[1].ToString();
employeedata.gender = dr[2].ToString();
employeedata.empphoto = dr[3].ToString();
listemp.Add(employeedata);
}
cn.Close();
return listemp;
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="gridviewclassWebForm1.aspx.cs" Inherits="gridviewinserupdatedel.gridviewclassWebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="empid" HeaderText="Employee Id" />
<asp:BoundField DataField="empname" HeaderText="Employee Name" />
<asp:BoundField DataField="gender" HeaderText="Employee Gender" />
<asp:TemplateField HeaderText="Employee Image">
<ItemTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl='<%# Bind("empphoto") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
protected void Page_Load(object sender, EventArgs e)
{
GridView1.DataSource= empdataaccesslayer.getallemployee();
GridView1.DataBind();
}
Monday, 24 August 2015
MDI (Multiple Document Interface) form with C# Language
MDI Multiple Document Interface with C# Language
MDI MDI Multiple Document Interface applications allow to display multiple documents at the same time, with each document displayed in its own window.
Creating MDI Multiple Document Interface Parent Forms
MDI parent form is the base of MDI. This is the form that holds the MDI child windows, which are all the sub windows in which the client work together with the mdi application.
Create a new form and add the code
this.IsMdiContainer=true;
Create MDI child forms
form frmchild=new form();
frmchild.mdiparent=this;
frmchild.show();
E.g.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace alhuda_marksheet
{
public partial class MDIParentuser : Form
{
public MDIParentuser()
{
InitializeComponent();
}
private void admissionToolStripMenuItem_Click(object sender, EventArgs e)
{
if (ActiveMdiChild != null)
ActiveMdiChild.Close();
Form1 obj = new Form1();
obj.MdiParent = this;
obj.Show();
}
private void marksToolStripMenuItem_Click(object sender, EventArgs e)
{
if (ActiveMdiChild != null)
ActiveMdiChild.Close();
marks obj = new marks();
obj.MdiParent = this;
obj.Show();
}
private void reportToolStripMenuItem_Click(object sender, EventArgs e)
{
if (ActiveMdiChild != null)
ActiveMdiChild.Close();
report obj = new report();
obj.MdiParent = this;
obj.Show();
}
private void logoutToolStripMenuItem_Click(object sender, EventArgs e)
{
login obj = new login();
obj.Show();
this.Hide();
}
}
}
MDI MDI Multiple Document Interface applications allow to display multiple documents at the same time, with each document displayed in its own window.
Creating MDI Multiple Document Interface Parent Forms
MDI parent form is the base of MDI. This is the form that holds the MDI child windows, which are all the sub windows in which the client work together with the mdi application.
Create a new form and add the code
this.IsMdiContainer=true;
Create MDI child forms
form frmchild=new form();
frmchild.mdiparent=this;
frmchild.show();
E.g.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace alhuda_marksheet
{
public partial class MDIParentuser : Form
{
public MDIParentuser()
{
InitializeComponent();
}
private void admissionToolStripMenuItem_Click(object sender, EventArgs e)
{
if (ActiveMdiChild != null)
ActiveMdiChild.Close();
Form1 obj = new Form1();
obj.MdiParent = this;
obj.Show();
}
private void marksToolStripMenuItem_Click(object sender, EventArgs e)
{
if (ActiveMdiChild != null)
ActiveMdiChild.Close();
marks obj = new marks();
obj.MdiParent = this;
obj.Show();
}
private void reportToolStripMenuItem_Click(object sender, EventArgs e)
{
if (ActiveMdiChild != null)
ActiveMdiChild.Close();
report obj = new report();
obj.MdiParent = this;
obj.Show();
}
private void logoutToolStripMenuItem_Click(object sender, EventArgs e)
{
login obj = new login();
obj.Show();
this.Hide();
}
}
}
Array in C# Language
Array in C# Language :
array is an object used to store object of the same type and provides access to the objects using an index.
To create an object of type System.string and System.Array Class.
c# array index starts at zero. that means first item of an array will be stored at zero positions.
The positions of the last item on the array will total number of items-1.
int[] arryname;
int[] arrayname=new int[100];
Multi Dimensional array :
int [,]array_name=new int[3,5];
array is an object used to store object of the same type and provides access to the objects using an index.
To create an object of type System.string and System.Array Class.
c# array index starts at zero. that means first item of an array will be stored at zero positions.
The positions of the last item on the array will total number of items-1.
int[] arryname;
int[] arrayname=new int[100];
Multi Dimensional array :
int [,]array_name=new int[3,5];
Wednesday, 19 August 2015
Tokens in C++ Language
Tokens in C++ language:
Tokens is a smallest individual unit of a program .
In c++ language have followings types of tokens
Tokens is a smallest individual unit of a program .
In c++ language have followings types of tokens
- Keywords
- Identifiers
- Operators
- Constant
- String
- Special symbols
keywords
keywords are reserve word in a program which meaning reserved in compiler.
in c+ language has 48+15 key words.
Identifiers
Identifier refers to name of variables pointers functions structure union etc.
Rules for naming Identifier :
- Identifier can not be numeric and can not be start from numeric
- Identifier can not be any special character or can not be start from any special character.
- Identifier can not be keywords.
- Identifier length can not be more then 32 character long.
- Upper case and lower case letter are distinct.
Operators:
operators are the symbols that used on the operands for the specific purpose.
like
A+B
where A and B are the operands and + is a operator .
Constants
Constants refers to a fixed values that don't change during the executions of programs.
like:
234 integer constant
34.9 float constant
'A' character constant
etc.
String:
String are the collections of the character enclosed within double codes.
like:
"sheikh"
"abdul"
"mateen"
Special Symbols:
~`!@#$%^&*()_-+={[}]\|:;"'<,>.?/
Tokens in C language
Tokens in C language:
Tokens is a smallest individual unit of a program .
In c language have followings types of tokens
Tokens is a smallest individual unit of a program .
In c language have followings types of tokens
- Keywords
- Identifiers
- Operators
- Constant
- String
- Special symbols
keywords
keywords are reserve word in a program which meaning reserved in compiler.
in c language has 32 key words.
Identifiers
Identifier refers to name of variables pointers functions structure union etc.
Rules for naming Identifier :
- Identifier can not be numeric and can not be start from numeric
- Identifier can not be any special character or can not be start from any special character.
- Identifier can not be keywords.
- Identifier length can not be more then 32 character long.
- Upper case and lower case letter are distinct.
Operators:
operators are the symbols that used on the operands for the specific purpose.
like
A+B
where A and B are the operands and + is a operator .
Constants
Constants refers to a fixed values that don't change during the executions of programs.
like:
234 integer constant
34.9 float constant
'A' character constant
etc.
String:
String are the collections of the character enclosed within double codes.
like:
"sheikh"
"abdul"
"mateen"
Special Symbols:
~`!@#$%^&*()_-+={[}]\|:;"'<,>.?/
Monday, 17 August 2015
Full Project C# Dot Net Insert Update Del Window Based
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace alhuda_marksheet
{
public partial class editupdatedel : Form
{
public editupdatedel()
{
InitializeComponent();
}
connection c = new connection();
OleDbConnection con;
OleDbCommand cmd;
OleDbDataReader dr;
private void editupdatedel_Load(object sender, EventArgs e)
{
}
private void button4_Click(object sender, EventArgs e)
{
lblmsg.Text = "";
con = new OleDbConnection();
con.ConnectionString = c.con();
if (Csection.Text == "Preprimary")
{
try
{
con.Open();
//DataTable dt = new DataTable();
//OleDbDataAdapter da = new OleDbDataAdapter("select * from basic", con);
//da.Fill(dt);
cmd = new OleDbCommand("select * from ppbasic where srno=" + txtsrno.Text + " ", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
stdname.Text = dr[1].ToString();
stdroll.Text = dr[3].ToString();
stdclass.Text = dr[4].ToString();
stddob.Text = dr[5].ToString();
stdlinstitute.Text = dr[6].ToString();
stdfathername.Text = dr[7].ToString();
stdmothername.Text = dr[8].ToString();
txtoccupation.Text = dr[9].ToString();
txtreligion.Text = dr[10].ToString();
txtcontact.Text = dr[11].ToString();
txtadd.Text = dr[12].ToString();
}
else
MessageBox.Show("Data not found In database.");
}
catch (Exception ex)
{
MessageBox.Show("Please Check Values" + ex.Message);
}
finally
{
dr.Close();
con.Close();
}
}
else
if (Csection.Text == "Primary")
{
try
{
con.Open();
//DataTable dt = new DataTable();
//OleDbDataAdapter da = new OleDbDataAdapter("select * from basic", con);
//da.Fill(dt);
cmd = new OleDbCommand("select * from pbasic where srno=" + txtsrno.Text + " ", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
stdname.Text = dr[1].ToString();
stdroll.Text = dr[3].ToString();
stdclass.Text = dr[4].ToString();
stddob.Text = dr[5].ToString();
stdlinstitute.Text = dr[6].ToString();
stdfathername.Text = dr[7].ToString();
stdmothername.Text = dr[8].ToString();
txtoccupation.Text = dr[9].ToString();
txtreligion.Text = dr[10].ToString();
txtcontact.Text = dr[11].ToString();
txtadd.Text = dr[12].ToString();
}
else
MessageBox.Show("Data not found In database.");
}
catch (Exception ex)
{
MessageBox.Show("Please Check Values" + ex.Message);
}
finally
{
dr.Close();
con.Close();
}
}
else if (Csection.Text == "Junior")
{
try
{
con.Open();
//DataTable dt = new DataTable();
//OleDbDataAdapter da = new OleDbDataAdapter("select * from basic", con);
//da.Fill(dt);
cmd = new OleDbCommand("select * from jbasic where srno=" + txtsrno.Text + " ", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
stdname.Text = dr[1].ToString();
stdroll.Text = dr[3].ToString();
stdclass.Text = dr[4].ToString();
stddob.Text = dr[5].ToString();
stdlinstitute.Text = dr[6].ToString();
stdfathername.Text = dr[7].ToString();
stdmothername.Text = dr[8].ToString();
txtoccupation.Text = dr[9].ToString();
txtreligion.Text = dr[10].ToString();
txtcontact.Text = dr[11].ToString();
txtadd.Text = dr[12].ToString();
}
else
MessageBox.Show("Data not found In database.");
}
catch (Exception ex)
{
MessageBox.Show("Please Check Values" + ex.Message);
}
finally
{
dr.Close();
con.Close();
}
}
else
if (Csection.Text == "HighSchool")
{
try
{
con.Open();
//DataTable dt = new DataTable();
//OleDbDataAdapter da = new OleDbDataAdapter("select * from basic", con);
//da.Fill(dt);
cmd = new OleDbCommand("select * from hsbasic where srno=" + txtsrno.Text + " ", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
stdname.Text = dr[1].ToString();
stdroll.Text = dr[3].ToString();
stdclass.Text = dr[4].ToString();
stddob.Text = dr[5].ToString();
stdlinstitute.Text = dr[6].ToString();
stdfathername.Text = dr[7].ToString();
stdmothername.Text = dr[8].ToString();
txtoccupation.Text = dr[9].ToString();
txtreligion.Text = dr[10].ToString();
txtcontact.Text = dr[11].ToString();
txtadd.Text = dr[12].ToString();
}
else
MessageBox.Show("Data not found In database.");
}
catch (Exception ex)
{
MessageBox.Show("Please Check Values" + ex.Message);
}
finally
{
dr.Close();
con.Close();
}
}
else
MessageBox.Show("Please select section First..");
}
private void button5_Click(object sender, EventArgs e)
{
try
{
con = new OleDbConnection();
con.ConnectionString = c.con();
con.Open();
if (Csection.Text == "Preprimary")
{
cmd = new OleDbCommand("update ppbasic set sname='" + stdname.Text + "', rollno=" + stdroll.Text + ", class=" + stdclass.Text + ",dob='" + stddob.Text + "',linstitute='" + stdlinstitute.Text + "',fathername='" + stdfathername.Text + "',mothername='" + stdmothername.Text + "',occupation='" + txtoccupation.Text + "',religion='" + txtreligion.Text + "',contactno=" + txtcontact.Text + ",address='" + txtadd.Text + "' where srno=" + txtsrno.Text + "", con);
cmd.ExecuteNonQuery();
lblmsg.Text = "Your data Update Success fully..";
stdname.Text = "";
stdroll.Text = "";
stdclass.Text = "";
stddob.Text = "";
stdlinstitute.Text = "";
stdfathername.Text = "";
stdmothername.Text = "";
txtoccupation.Text = "";
txtreligion.Text = "";
txtcontact.Text = "";
txtadd.Text = "";
}
else
if (Csection.Text == "Primary")
{
cmd = new OleDbCommand("update pbasic set sname='" + stdname.Text + "', rollno=" + stdroll.Text + ", class=" + stdclass.Text + ",dob='" + stddob.Text + "',linstitute='" + stdlinstitute.Text + "',fathername='" + stdfathername.Text + "',mothername='" + stdmothername.Text + "',occupation='" + txtoccupation.Text + "',religion='" + txtreligion.Text + "',contactno=" + txtcontact.Text + ",address='" + txtadd.Text + "' where srno=" + txtsrno.Text + "", con);
cmd.ExecuteNonQuery();
lblmsg.Text = "Your data Update Success fully..";
stdname.Text = "";
stdroll.Text = "";
stdclass.Text = "";
stddob.Text = "";
stdlinstitute.Text = "";
stdfathername.Text = "";
stdmothername.Text = "";
txtoccupation.Text = "";
txtreligion.Text = "";
txtcontact.Text = "";
txtadd.Text = "";
}
else
if (Csection.Text == "Junior")
{
cmd = new OleDbCommand("update jbasic set sname='" + stdname.Text + "', rollno=" + stdroll.Text + ", class=" + stdclass.Text + ",dob='" + stddob.Text + "',linstitute='" + stdlinstitute.Text + "',fathername='" + stdfathername.Text + "',mothername='" + stdmothername.Text + "',occupation='" + txtoccupation.Text + "',religion='" + txtreligion.Text + "',contactno=" + txtcontact.Text + ",address='" + txtadd.Text + "' where srno=" + txtsrno.Text + "", con);
cmd.ExecuteNonQuery();
lblmsg.Text = "Your data Update Success fully..";
stdname.Text = "";
stdroll.Text = "";
stdclass.Text = "";
stddob.Text = "";
stdlinstitute.Text = "";
stdfathername.Text = "";
stdmothername.Text = "";
txtoccupation.Text = "";
txtreligion.Text = "";
txtcontact.Text = "";
txtadd.Text = "";
}
else
if (Csection.Text == "HighSchool")
{
cmd = new OleDbCommand("update hsbasic set sname='" + stdname.Text + "', rollno=" + stdroll.Text + ", class=" + stdclass.Text + ",dob='" + stddob.Text + "',linstitute='" + stdlinstitute.Text + "',fathername='" + stdfathername.Text + "',mothername='" + stdmothername.Text + "',occupation='" + txtoccupation.Text + "',religion='" + txtreligion.Text + "',contactno=" + txtcontact.Text + ",address='" + txtadd.Text + "' where srno=" + txtsrno.Text + "", con);
cmd.ExecuteNonQuery();
lblmsg.Text = "Your data Update Success fully..";
stdname.Text = "";
stdroll.Text = "";
stdclass.Text = "";
stddob.Text = "";
stdlinstitute.Text = "";
stdfathername.Text = "";
stdmothername.Text = "";
txtoccupation.Text = "";
txtreligion.Text = "";
txtcontact.Text = "";
txtadd.Text = "";
}
else
MessageBox.Show("Please select Section first");
}
catch (Exception ex)
{ MessageBox.Show("" + ex); }
finally
{
con.Close();
}
}
private void button2_Click(object sender, EventArgs e)
{
if (dsection.Text == "Preprimary")
{
try
{
con = new OleDbConnection();
con.ConnectionString = c.con();
con.Open();
cmd = new OleDbCommand("delete from ppbasic where srno=" +txtsrno.Text + "", con);
cmd.ExecuteNonQuery();
delmsg.Text = "Data Delete Success Fully..";
txtrollnodel.Text ="";
}
catch (Exception ex)
{
MessageBox.Show("S.R.NO Not Found Please Enter Valid Number..."+ex);
}
finally
{
con.Close();
}
}
else
if (dsection.Text == "Primary")
{
try
{
con = new OleDbConnection();
con.ConnectionString = c.con();
con.Open();
cmd = new OleDbCommand("delete from pbasic where srno=" + txtsrno.Text + "", con);
cmd.ExecuteNonQuery();
delmsg.Text = "Data Delete Success Fully..";
txtrollnodel.Text = "";
}
catch (Exception ex)
{
MessageBox.Show("S.R.NO Not Found Please Enter Valid Number..."+ex);
}
finally
{
con.Close();
}}
else
if (dsection.Text == "Junior")
{
try
{
con = new OleDbConnection();
con.ConnectionString = c.con();
con.Open();
cmd = new OleDbCommand("delete from jbasic where srno=" + txtsrno.Text + "", con);
cmd.ExecuteNonQuery();
delmsg.Text = "Data Delete Success Fully..";
txtrollnodel.Text = "";
}
catch (Exception ex)
{
MessageBox.Show("S.R.NO Not Found Please Enter Valid Number..."+ex);
}
finally
{
con.Close();
}}
else
if (dsection.Text == "HighSchool")
{
try
{
con = new OleDbConnection();
con.ConnectionString = c.con();
con.Open();
cmd = new OleDbCommand("delete from hsbasic where rollno=" + txtsrno.Text + "", con);
cmd.ExecuteNonQuery();
delmsg.Text = "Data Delete Success Fully..";
txtrollnodel.Text = "";
}
catch (Exception ex)
{
MessageBox.Show("S.R.NO Not Found Please Enter Valid Number..."+ex);
}
finally
{
con.Close();
}}
else
MessageBox.Show("Please Select Section First..");
}
private void panel2_Paint(object sender, PaintEventArgs e)
{
}
}
}
Login from with C# ,sqlserver 2008r2 window based
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace alhuda_marksheet
{
public partial class login : Form
{
public login()
{
InitializeComponent();
}
connection c = new connection();
string connectionString = null;
OleDbConnection connection;
OleDbDataAdapter oledbAdapter;
DataSet ds = new DataSet();
string sql = null;
int i = 0;
int a;
private void button1_Click(object sender, EventArgs e)
{
// connection= new OleDbConnection();
//connection.ConnectionString = c.con();
connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\data\lucknowacademy.accdb";
connection = new OleDbConnection(connectionString);
try
{
sql = "select username,password,type from admin where type='"+comboBox1.Text+"'";
connection.Open();
oledbAdapter = new OleDbDataAdapter(sql, connection);
oledbAdapter.Fill(ds);
oledbAdapter.Dispose();
connection.Close();
for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
if ((ds.Tables[0].Rows[i].ItemArray[0]).ToString() == textBox1.Text && (ds.Tables[0].Rows[i].ItemArray[1]).ToString() == textBox2.Text)
{
MDIParent1 obj = new MDIParent1();
if ((ds.Tables[0].Rows[i].ItemArray[2]).ToString() == "Admin")
{
obj.Show();
a++;
this.Hide();
break;
}
else
if ((ds.Tables[0].Rows[i].ItemArray[2]).ToString() == "User")
{
MDIParentuser obj1 = new MDIParentuser();
obj1.Show();
a++;
this.Hide();
break;
}
}
}
if (a == 0)
{
MessageBox.Show("Wrong User name and Password");
}
}
catch (Exception ex)
{
MessageBox.Show("Can not open connection ! " + ex.Message);
}
}
}
}
Insert Update Delete In C# Dot net full project
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace alhuda_marksheet
{
public partial class editupdatedel : Form
{
public editupdatedel()
{
InitializeComponent();
}
connection c = new connection();
OleDbConnection con;
OleDbCommand cmd;
OleDbDataReader dr;
private void editupdatedel_Load(object sender, EventArgs e)
{
}
private void button4_Click(object sender, EventArgs e)
{
lblmsg.Text = "";
con = new OleDbConnection();
con.ConnectionString = c.con();
if (Csection.Text == "Preprimary")
{
try
{
con.Open();
//DataTable dt = new DataTable();
//OleDbDataAdapter da = new OleDbDataAdapter("select * from basic", con);
//da.Fill(dt);
cmd = new OleDbCommand("select * from ppbasic where srno=" + txtsrno.Text + " ", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
stdname.Text = dr[1].ToString();
stdroll.Text = dr[3].ToString();
stdclass.Text = dr[4].ToString();
stddob.Text = dr[5].ToString();
stdlinstitute.Text = dr[6].ToString();
stdfathername.Text = dr[7].ToString();
stdmothername.Text = dr[8].ToString();
txtoccupation.Text = dr[9].ToString();
txtreligion.Text = dr[10].ToString();
txtcontact.Text = dr[11].ToString();
txtadd.Text = dr[12].ToString();
}
else
MessageBox.Show("Data not found In database.");
}
catch (Exception ex)
{
MessageBox.Show("Please Check Values" + ex.Message);
}
finally
{
dr.Close();
con.Close();
}
}
else
if (Csection.Text == "Primary")
{
try
{
con.Open();
//DataTable dt = new DataTable();
//OleDbDataAdapter da = new OleDbDataAdapter("select * from basic", con);
//da.Fill(dt);
cmd = new OleDbCommand("select * from pbasic where srno=" + txtsrno.Text + " ", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
stdname.Text = dr[1].ToString();
stdroll.Text = dr[3].ToString();
stdclass.Text = dr[4].ToString();
stddob.Text = dr[5].ToString();
stdlinstitute.Text = dr[6].ToString();
stdfathername.Text = dr[7].ToString();
stdmothername.Text = dr[8].ToString();
txtoccupation.Text = dr[9].ToString();
txtreligion.Text = dr[10].ToString();
txtcontact.Text = dr[11].ToString();
txtadd.Text = dr[12].ToString();
}
else
MessageBox.Show("Data not found In database.");
}
catch (Exception ex)
{
MessageBox.Show("Please Check Values" + ex.Message);
}
finally
{
dr.Close();
con.Close();
}
}
else if (Csection.Text == "Junior")
{
try
{
con.Open();
//DataTable dt = new DataTable();
//OleDbDataAdapter da = new OleDbDataAdapter("select * from basic", con);
//da.Fill(dt);
cmd = new OleDbCommand("select * from jbasic where srno=" + txtsrno.Text + " ", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
stdname.Text = dr[1].ToString();
stdroll.Text = dr[3].ToString();
stdclass.Text = dr[4].ToString();
stddob.Text = dr[5].ToString();
stdlinstitute.Text = dr[6].ToString();
stdfathername.Text = dr[7].ToString();
stdmothername.Text = dr[8].ToString();
txtoccupation.Text = dr[9].ToString();
txtreligion.Text = dr[10].ToString();
txtcontact.Text = dr[11].ToString();
txtadd.Text = dr[12].ToString();
}
else
MessageBox.Show("Data not found In database.");
}
catch (Exception ex)
{
MessageBox.Show("Please Check Values" + ex.Message);
}
finally
{
dr.Close();
con.Close();
}
}
else
if (Csection.Text == "HighSchool")
{
try
{
con.Open();
//DataTable dt = new DataTable();
//OleDbDataAdapter da = new OleDbDataAdapter("select * from basic", con);
//da.Fill(dt);
cmd = new OleDbCommand("select * from hsbasic where srno=" + txtsrno.Text + " ", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
stdname.Text = dr[1].ToString();
stdroll.Text = dr[3].ToString();
stdclass.Text = dr[4].ToString();
stddob.Text = dr[5].ToString();
stdlinstitute.Text = dr[6].ToString();
stdfathername.Text = dr[7].ToString();
stdmothername.Text = dr[8].ToString();
txtoccupation.Text = dr[9].ToString();
txtreligion.Text = dr[10].ToString();
txtcontact.Text = dr[11].ToString();
txtadd.Text = dr[12].ToString();
}
else
MessageBox.Show("Data not found In database.");
}
catch (Exception ex)
{
MessageBox.Show("Please Check Values" + ex.Message);
}
finally
{
dr.Close();
con.Close();
}
}
else
MessageBox.Show("Please select section First..");
}
private void button5_Click(object sender, EventArgs e)
{
try
{
con = new OleDbConnection();
con.ConnectionString = c.con();
con.Open();
if (Csection.Text == "Preprimary")
{
cmd = new OleDbCommand("update ppbasic set sname='" + stdname.Text + "', rollno=" + stdroll.Text + ", class=" + stdclass.Text + ",dob='" + stddob.Text + "',linstitute='" + stdlinstitute.Text + "',fathername='" + stdfathername.Text + "',mothername='" + stdmothername.Text + "',occupation='" + txtoccupation.Text + "',religion='" + txtreligion.Text + "',contactno=" + txtcontact.Text + ",address='" + txtadd.Text + "' where srno=" + txtsrno.Text + "", con);
cmd.ExecuteNonQuery();
lblmsg.Text = "Your data Update Success fully..";
stdname.Text = "";
stdroll.Text = "";
stdclass.Text = "";
stddob.Text = "";
stdlinstitute.Text = "";
stdfathername.Text = "";
stdmothername.Text = "";
txtoccupation.Text = "";
txtreligion.Text = "";
txtcontact.Text = "";
txtadd.Text = "";
}
else
if (Csection.Text == "Primary")
{
cmd = new OleDbCommand("update pbasic set sname='" + stdname.Text + "', rollno=" + stdroll.Text + ", class=" + stdclass.Text + ",dob='" + stddob.Text + "',linstitute='" + stdlinstitute.Text + "',fathername='" + stdfathername.Text + "',mothername='" + stdmothername.Text + "',occupation='" + txtoccupation.Text + "',religion='" + txtreligion.Text + "',contactno=" + txtcontact.Text + ",address='" + txtadd.Text + "' where srno=" + txtsrno.Text + "", con);
cmd.ExecuteNonQuery();
lblmsg.Text = "Your data Update Success fully..";
stdname.Text = "";
stdroll.Text = "";
stdclass.Text = "";
stddob.Text = "";
stdlinstitute.Text = "";
stdfathername.Text = "";
stdmothername.Text = "";
txtoccupation.Text = "";
txtreligion.Text = "";
txtcontact.Text = "";
txtadd.Text = "";
}
else
if (Csection.Text == "Junior")
{
cmd = new OleDbCommand("update jbasic set sname='" + stdname.Text + "', rollno=" + stdroll.Text + ", class=" + stdclass.Text + ",dob='" + stddob.Text + "',linstitute='" + stdlinstitute.Text + "',fathername='" + stdfathername.Text + "',mothername='" + stdmothername.Text + "',occupation='" + txtoccupation.Text + "',religion='" + txtreligion.Text + "',contactno=" + txtcontact.Text + ",address='" + txtadd.Text + "' where srno=" + txtsrno.Text + "", con);
cmd.ExecuteNonQuery();
lblmsg.Text = "Your data Update Success fully..";
stdname.Text = "";
stdroll.Text = "";
stdclass.Text = "";
stddob.Text = "";
stdlinstitute.Text = "";
stdfathername.Text = "";
stdmothername.Text = "";
txtoccupation.Text = "";
txtreligion.Text = "";
txtcontact.Text = "";
txtadd.Text = "";
}
else
if (Csection.Text == "HighSchool")
{
cmd = new OleDbCommand("update hsbasic set sname='" + stdname.Text + "', rollno=" + stdroll.Text + ", class=" + stdclass.Text + ",dob='" + stddob.Text + "',linstitute='" + stdlinstitute.Text + "',fathername='" + stdfathername.Text + "',mothername='" + stdmothername.Text + "',occupation='" + txtoccupation.Text + "',religion='" + txtreligion.Text + "',contactno=" + txtcontact.Text + ",address='" + txtadd.Text + "' where srno=" + txtsrno.Text + "", con);
cmd.ExecuteNonQuery();
lblmsg.Text = "Your data Update Success fully..";
stdname.Text = "";
stdroll.Text = "";
stdclass.Text = "";
stddob.Text = "";
stdlinstitute.Text = "";
stdfathername.Text = "";
stdmothername.Text = "";
txtoccupation.Text = "";
txtreligion.Text = "";
txtcontact.Text = "";
txtadd.Text = "";
}
else
MessageBox.Show("Please select Section first");
}
catch (Exception ex)
{ MessageBox.Show("" + ex); }
finally
{
con.Close();
}
}
private void button2_Click(object sender, EventArgs e)
{
if (dsection.Text == "Preprimary")
{
try
{
con = new OleDbConnection();
con.ConnectionString = c.con();
con.Open();
cmd = new OleDbCommand("delete from ppbasic where srno=" +txtsrno.Text + "", con);
cmd.ExecuteNonQuery();
delmsg.Text = "Data Delete Success Fully..";
txtrollnodel.Text ="";
}
catch (Exception ex)
{
MessageBox.Show("S.R.NO Not Found Please Enter Valid Number..."+ex);
}
finally
{
con.Close();
}
}
else
if (dsection.Text == "Primary")
{
try
{
con = new OleDbConnection();
con.ConnectionString = c.con();
con.Open();
cmd = new OleDbCommand("delete from pbasic where srno=" + txtsrno.Text + "", con);
cmd.ExecuteNonQuery();
delmsg.Text = "Data Delete Success Fully..";
txtrollnodel.Text = "";
}
catch (Exception ex)
{
MessageBox.Show("S.R.NO Not Found Please Enter Valid Number..."+ex);
}
finally
{
con.Close();
}}
else
if (dsection.Text == "Junior")
{
try
{
con = new OleDbConnection();
con.ConnectionString = c.con();
con.Open();
cmd = new OleDbCommand("delete from jbasic where srno=" + txtsrno.Text + "", con);
cmd.ExecuteNonQuery();
delmsg.Text = "Data Delete Success Fully..";
txtrollnodel.Text = "";
}
catch (Exception ex)
{
MessageBox.Show("S.R.NO Not Found Please Enter Valid Number..."+ex);
}
finally
{
con.Close();
}}
else
if (dsection.Text == "HighSchool")
{
try
{
con = new OleDbConnection();
con.ConnectionString = c.con();
con.Open();
cmd = new OleDbCommand("delete from hsbasic where rollno=" + txtsrno.Text + "", con);
cmd.ExecuteNonQuery();
delmsg.Text = "Data Delete Success Fully..";
txtrollnodel.Text = "";
}
catch (Exception ex)
{
MessageBox.Show("S.R.NO Not Found Please Enter Valid Number..."+ex);
}
finally
{
con.Close();
}}
else
MessageBox.Show("Please Select Section First..");
}
private void panel2_Paint(object sender, PaintEventArgs e)
{
}
}
}
Subscribe to:
Posts (Atom)