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)
{
}
}
}
No comments:
Post a Comment