You are on page 1of 11

CODING

HR Details:

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

using System.Windows.Forms;

public partial class HR_Details : System.Web.UI.Page

SqlConnection con = new SqlConnection("server=DATASERVER;Initial


Catalog=gvenu;user id=sa;password=sqlserver");

SqlDataAdapter ad1, ad2;

DataSet ds = new DataSet();

int k;

protected void Button1_Click(object sender, EventArgs e)

{
con.Open();

string str = "select * from hrdetails where hrid=" + TxtHRid.Text +


"";

SqlCommand cmd = new SqlCommand(str, con);

SqlDataReader dr = cmd.ExecuteReader();

while (dr.Read())

k = int.Parse(dr[0].ToString());

dr.Close();

if (TxtHRid.Text == k.ToString())

string s1 = "";

for (int i = 0; i < RBLGender.Items.Count; i++)

if (RBLGender.Items[i].Selected == true)

s1 = RBLGender.Items[i].Text;

string str1 = "update hrdetails set hrname='" + TxtHRname.Text +


"',qualification='" + TxtQual.Text + "',dob=" + TxtDob.Text + ",skills='" +
TxtSkills.Text + "',gender='" + s1 + "',address='" + TxtAdd.Text +
"',contactno='" + TxtCno.Text + "',doj=" + TxtDoj.Text + ",projname='" +
TxtPname.Text + "' where hrid=" + TxtHRid.Text + " ";

ad1 = new SqlDataAdapter(str1, con);

ad1.Fill(ds);
MessageBox.Show("Your Values Are Updated");

else

MessageBox.Show("No Details are present With This ID");

con.Close();

protected void Button2_Click(object sender, EventArgs e)

con.Open();

string str = "select * from hrdetails where hrid=" + TxtHRid.Text +


"";

SqlCommand cmd = new SqlCommand(str, con);

SqlDataReader dr = cmd.ExecuteReader();

while (dr.Read())

k = int.Parse(dr[0].ToString());

dr.Close();

if (TxtHRid.Text == k.ToString())

string s1 = "delete hrdetails where hrid=" + TxtHRid.Text + " ";

ad2 = new SqlDataAdapter(s1, con);

ad2.Fill(ds);

MessageBox.Show("One Row Deleted");

else
{

MessageBox.Show("Invalid HR ID");

con.Close();

protected void Button3_Click(object sender, EventArgs e)

con.Open();

string s2 = "select * from hrdetails where hrid=" + TxtHRid.Text + "


";

SqlCommand cmd = new SqlCommand(s2, con);

SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())

TxtHRname.Text = dr[1].ToString();

TxtQual.Text = dr[2].ToString();

TxtDob.Text = dr[3].ToString();

TxtSkills.Text = dr[4].ToString();

TxtAdd.Text = dr[6].ToString();

TxtCno.Text = dr[7].ToString();

TxtDoj.Text = dr[8].ToString();

TxtPname.Text = dr[9].ToString();

for (int i = 0; i < RBLGender.Items.Count; i++)

if (RBLGender.Items[i].Text == dr[5].ToString())

RBLGender.Items[i].Selected = true;

else

MessageBox.Show("Enter Valid HRID");

con.Close();

}
}

You might also like