protected void GVEmp_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "Select") { GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); string CusID = GVEmp.DataKeys[row.RowIndex].Values[0].ToString(); HFUsrNam.Value = CusID; dt_ = DBConnection.GetQueryData("select * from Users where Username = '******' and CompanyId = '" + Session["CompanyID"] + "' and BranchId= '" + Session["BranchID"] + "'"); if (dt_.Rows.Count > 0) { ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "showempyee();", true); TBEmpName.Value = dt_.Rows[0]["Name"].ToString(); TBAdd.Value = dt_.Rows[0]["Address"].ToString(); TBdesig.Value = dt_.Rows[0]["Designation"].ToString(); TBphno.Value = dt_.Rows[0]["TelephoneNo"].ToString(); TBfxno.Value = dt_.Rows[0]["FaxNo"].ToString(); TBmbno.Value = dt_.Rows[0]["MobileNo"].ToString(); TBemal.Value = dt_.Rows[0]["Email"].ToString(); TBSal.Value = dt_.Rows[0]["Salary"].ToString(); DDL_Desig.SelectedValue = dt_.Rows[0]["Level"].ToString(); chkchgpass.Checked = Convert.ToBoolean(dt_.Rows[0]["CanChangePassword"].ToString()); chkaccdisbl.Checked = Convert.ToBoolean(dt_.Rows[0]["AccountDisable"].ToString()); TBEmpName.Focus(); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "Alert();", true); lblalert.Text = "Not Record Found!"; } } } catch (Exception ex) { // throw; ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "Alert();", true); lblalert.Text = ex.Message; } }
protected void btnSubmit_Click(object sender, EventArgs e) { try { if (TBEmpName.Value == "" || TBdesig.Value == "") { if (TBEmpName.Value == "") { v_desc.Text = ""; v_employee.Text = "Enter Employee Name"; TBEmpName.Focus(); } else { v_employee.Text = ""; v_desc.Text = "Enter Designation"; TBdesig.Focus(); } } else if (HFUsrNam.Value == "") { v_desc.Text = ""; v_employee.Text = ""; int a; a = Save(); if (a == 1) { ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "Alert();", true); lblalert.Text = "Employee Has Been Saved!"; Clear(); FillGrid(); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "Alert();", true); lblalert.Text = "Some thing is wrong Call the Administrator!!"; } } else { v_desc.Text = ""; v_employee.Text = ""; int b; b = Update(); if (b == 1) { ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "Alert();", true); lblalert.Text = "Employee Has Been Update!"; Clear(); FillGrid(); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "Alert();", true); lblalert.Text = "Some thing is wrong Call the Administrator!!"; } } } catch (Exception ex) { // throw; ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "Alert();", true); lblalert.Text = ex.Message; } }