private void ClearAll() { lblEmpName.Text = ""; lblEmpDept.Text = ""; lblDesi.Text = ""; lblempDiv.Text = ""; ddlDept.SelectedIndex = -1; ddlDesig.SelectedIndex = -1; ddlDividion.SelectedIndex = -1; (TransActive.FindControl("TextBox1") as TextBox).Text = ""; txtEmpCode.Text = ""; txtEmpCode.Focus(); }
protected void btnSave_Click(object sender, EventArgs e) { string TransferAcciDate = (TransActive.FindControl("TextBox1") as TextBox).Text; con.Open(); SqlCommand cmd = new SqlCommand("insert into tblTransferRecord(EmpCode,OldDeptCode,OldDesigCode,OldDivCode,NewDeptCode,NewDesigCode,NewDivCode,TRActiveDate) values('" + txtEmpCode.Text + "','" + ddlDept.SelectedValue + "','" + ddlDesig.SelectedValue + "','" + ddlDividion.SelectedValue + "','" + ddlDept.SelectedValue + "','" + ddlDesig.SelectedValue + "','" + ddlDividion.SelectedValue + "','" + TransferAcciDate + "')", con); SqlCommand cmd1 = new SqlCommand("update tblEmployee set DeptCode='" + ddlDept.SelectedValue + "',DesigCode='" + ddlDesig.SelectedValue + "',DivCode='" + ddlDividion.SelectedValue + "' where EmpCode='" + txtEmpCode.Text + "'", con); cmd.ExecuteNonQuery(); cmd1.ExecuteNonQuery(); Literal1.Text = "Data saved successfully!!!"; LoadGrid(); ClearAll(); con.Close(); }
protected void btnSearch_Click(object sender, EventArgs e) { SqlDataAdapter sda = new SqlDataAdapter("select EmpName,OldDeptCode,OldDesignationCode,OldDivCode,NewDeptCode,NewDesigtnationCode,NewDivCode,TrActivateDate from tblTransferRecord where EmpCode='" + txtEmpCode.Text + "'", con); DataTable dt = new DataTable(); sda.Fill(dt); lblEmpName.Text = dt.Rows[0]["EmpName"].ToString(); lblEmpDept.Text = dt.Rows[0]["OldDeptCode"].ToString(); lblDesi.Text = dt.Rows[0]["OldDesignationCode"].ToString(); lblempDiv.Text = dt.Rows[0]["OldDivCode"].ToString(); ddlDept.SelectedValue = dt.Rows[0]["NewDeptCode"].ToString(); ddlDesig.SelectedValue = dt.Rows[0]["NewDesigtnationCode"].ToString(); ddlDividion.SelectedValue = dt.Rows[0]["NewDivCode"].ToString(); (TransActive.FindControl("TextBox1") as TextBox).Text = dt.Rows[0]["TrActivateDate"].ToString(); }