protected override void Page_Load(object sender, EventArgs e) { EmployeeFormUI employeeFormUI = new EmployeeFormUI(); if (!Page.IsPostBack) { if (Request.QueryString["EmployeeId"] != null) { employeeFormUI.Tbl_EmployeeId = Request.QueryString["EmployeeId"]; BindStatuDropDown(); FillForm(employeeFormUI); btnSave.Visible = false; btnClear.Visible = false; btnUpdate.Visible = true; btnDelete.Visible = true; lblHeading.Text = "Update Employee"; } else { BindStatuDropDown(); btnSave.Visible = true; btnClear.Visible = true; btnUpdate.Visible = false; btnDelete.Visible = false; lblHeading.Text = "Add New Employee"; } } }
protected void btnUpdate_Click(object sender, EventArgs e) { EmployeeFormUI employeeFormUI = new EmployeeFormUI(); try { employeeFormUI.ModifiedBy = SessionContext.UserGuid; employeeFormUI.Tbl_OrganizationId = SessionContext.OrganizationId; employeeFormUI.Tbl_EmployeeId = Request.QueryString["EmployeeId"]; employeeFormUI.EmployeeCode = txtEmployeeCode.Text; employeeFormUI.Name = txtName.Text; employeeFormUI.ShortName = txtShortName.Text; employeeFormUI.ChequeName = txtChequeName.Text; employeeFormUI.Contact = txtContact.Text; employeeFormUI.Address = txtAddress.Text; employeeFormUI.City = txtCity.Text; employeeFormUI.ZipCode = txtZipCode.Text; employeeFormUI.Tbl_CountryId = txtCountryGuid.Text; employeeFormUI.Phone = txtPhone.Text; employeeFormUI.Mobile = txtMobile.Text; employeeFormUI.FaxNo = txtFaxNo.Text; employeeFormUI.Email = txtEmail.Text; employeeFormUI.Comment1 = txtComment1.Text; employeeFormUI.Comment2 = txtComment2.Text; employeeFormUI.Opt_Status = Convert.ToInt32(ddlStatus.SelectedValue); employeeFormUI.Tbl_EmployeeGroupId = txtEmployeeGroupGuid.Text; if (chkOnHold.Checked == true) { employeeFormUI.OnHold = true; } else { employeeFormUI.OnHold = false; } if (employeeFormBAL.UpdateEmployee(employeeFormUI) == 1) { divSuccess.Visible = true; lblSuccess.Text = Resources.GlobalResource.msgRecordUpdatedSuccessfully; } else { divError.Visible = true; lblError.Text = Resources.GlobalResource.msgCouldNotUpdateRecord; } } catch (Exception exp) { logExcpUIobj.MethodName = "btnUpdate_Click()"; logExcpUIobj.ResourceName = "System_Settings_BatchForm.CS"; logExcpUIobj.RecordId = employeeFormUI.Tbl_EmployeeId; logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString(); logExcpDALobj.SaveExceptionToDB(logExcpUIobj); log.Error("[System_Settings_BatchForm : btnUpdate_Click] An error occured in the processing of Record Id : " + employeeFormUI.Tbl_EmployeeId + ". Details : [" + exp.ToString() + "]"); } }
protected void btnDelete_Click(object sender, EventArgs e) { EmployeeFormUI employeeFormUI = new EmployeeFormUI(); try { employeeFormUI.Tbl_EmployeeId = Request.QueryString["EmployeeId"]; if (employeeFormBAL.DeleteEmployee(employeeFormUI) == 1) { divSuccess.Visible = true; lblSuccess.Text = Resources.GlobalResource.msgRecordDeleteSuccessfully; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "clearform", "ClearForm();", true); } else { divError.Visible = true; lblError.Text = Resources.GlobalResource.msgCouldNotDeleteRecord; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "clearform", "ClearForm();", true); } } catch (Exception exp) { logExcpUIobj.MethodName = "btnDelete_Click()"; logExcpUIobj.ResourceName = "System_Settings_BatchForm.CS"; logExcpUIobj.RecordId = employeeFormUI.Tbl_EmployeeId; logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString(); logExcpDALobj.SaveExceptionToDB(logExcpUIobj); log.Error("[System_Settings_BatchForm : btnDelete_Click] An error occured in the processing of Record Id : " + employeeFormUI.Tbl_EmployeeId + ". Details : [" + exp.ToString() + "]"); } }
public int UpdateEmployee(EmployeeFormUI employeeFormUI) { int resutl = 0; resutl = employeeFormDAL.UpdateEmployee(employeeFormUI); return(resutl); }
public int DeleteEmployee(EmployeeFormUI employeeFormUI) { int resutl = 0; resutl = employeeFormDAL.DeleteEmployee(employeeFormUI); return(resutl); }
public int AddEmployee(EmployeeFormUI employeeFormUI) { int resutl = 0; resutl = employeeFormDAL.AddEmployee(employeeFormUI); return(resutl); }
public DataTable GetEmployeeListById(EmployeeFormUI employeeFormUI) { DataTable dtb = new DataTable(); dtb = employeeFormDAL.GetEmployeeListById(employeeFormUI); return(dtb); }
private void FillForm(EmployeeFormUI employeeFormUI) { try { DataTable dtb = employeeFormBAL.GetEmployeeListById(employeeFormUI); if (dtb.Rows.Count > 0) { txtEmployeeCode.Text = dtb.Rows[0]["EmployeeCode"].ToString(); txtName.Text = dtb.Rows[0]["Name"].ToString(); txtShortName.Text = dtb.Rows[0]["ShortName"].ToString(); txtChequeName.Text = dtb.Rows[0]["ChequeName"].ToString(); txtContact.Text = dtb.Rows[0]["Contact"].ToString(); txtAddress.Text = dtb.Rows[0]["Address"].ToString(); txtCity.Text = dtb.Rows[0]["City"].ToString(); txtZipCode.Text = dtb.Rows[0]["ZipCode"].ToString(); txtCountryGuid.Text = dtb.Rows[0]["tbl_CountryId"].ToString(); txtCountry.Text = dtb.Rows[0]["CountryName"].ToString(); txtPhone.Text = dtb.Rows[0]["Phone"].ToString(); txtMobile.Text = dtb.Rows[0]["Mobile"].ToString(); txtFaxNo.Text = dtb.Rows[0]["FaxNo"].ToString(); txtEmail.Text = dtb.Rows[0]["Email"].ToString(); txtComment1.Text = dtb.Rows[0]["Comment1"].ToString(); txtComment2.Text = dtb.Rows[0]["Comment2"].ToString(); ddlStatus.SelectedValue = dtb.Rows[0]["Opt_Status"].ToString(); txtEmployeeGroupGuid.Text = dtb.Rows[0]["tbl_EmployeeGroupId"].ToString(); txtEmployeeGroup.Text = dtb.Rows[0]["EmployeeGroupName"].ToString(); if (Convert.ToBoolean(dtb.Rows[0]["OnHold"]) == true) { chkOnHold.Checked = true; } else { chkOnHold.Checked = false; } } else { lblError.Text = Resources.GlobalResource.msgCouldNotLoadData; divError.Visible = true; } } catch (Exception exp) { logExcpUIobj.MethodName = "FillForm()"; logExcpUIobj.ResourceName = "Finance_Accounts_Payable_Employee_Supplier_Master_Creation_EmployeeForm.CS"; logExcpUIobj.RecordId = employeeFormUI.Tbl_EmployeeGroupId; logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString(); logExcpDALobj.SaveExceptionToDB(logExcpUIobj); log.Error("[Finance_Accounts_Payable_Employee_Supplier_Master_Creation_EmployeeForm : FillForm] An error occured in the processing of Record Id : " + employeeFormUI.Tbl_EmployeeGroupId + ". Details : [" + exp.ToString() + "]"); } }
public DataTable GetEmployeeListById(EmployeeFormUI employeeFormUI) { DataSet ds = new DataSet(); DataTable dtbl = new DataTable(); try { using (SqlConnection SupportCon = new SqlConnection(connectionString)) { SqlCommand sqlCmd = new SqlCommand("SP_Employee_SelectById", SupportCon); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.CommandTimeout = commandTimeout; sqlCmd.Parameters.Add("@tbl_EmployeeId", SqlDbType.NVarChar); sqlCmd.Parameters["@tbl_EmployeeId"].Value = employeeFormUI.Tbl_EmployeeId; using (SqlDataAdapter adapter = new SqlDataAdapter(sqlCmd)) { adapter.Fill(ds); } } if (ds.Tables.Count > 0) { dtbl = ds.Tables[0]; } } catch (Exception exp) { logExcpUIobj.MethodName = "getEmployeeListById()"; logExcpUIobj.ResourceName = "EmployeeFormDAL.CS"; logExcpUIobj.RecordId = employeeFormUI.Tbl_EmployeeId; logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString(); logExcpDALobj.SaveExceptionToDB(logExcpUIobj); log.Error("[EmployeeFormDAL : getEmployeeListById] An error occured in the processing of Record Id : " + employeeFormUI.Tbl_EmployeeId + ". Details : [" + exp.ToString() + "]"); } finally { ds.Dispose(); } return(dtbl); }
public int DeleteEmployee(EmployeeFormUI employeeFormUI) { int result = 0; try { using (SqlConnection SupportCon = new SqlConnection(connectionString)) { SupportCon.Open(); SqlCommand sqlCmd = new SqlCommand("SP_Employee_Delete", SupportCon); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.CommandTimeout = commandTimeout; sqlCmd.Parameters.Add("@tbl_EmployeeId", SqlDbType.NVarChar); sqlCmd.Parameters["@tbl_EmployeeId"].Value = employeeFormUI.Tbl_EmployeeId; result = sqlCmd.ExecuteNonQuery(); sqlCmd.Dispose(); SupportCon.Close(); } } catch (Exception exp) { logExcpUIobj.MethodName = "DeleteEmployee()"; logExcpUIobj.ResourceName = "EmployeeFormDAL.CS"; logExcpUIobj.RecordId = employeeFormUI.Tbl_EmployeeId; logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString(); logExcpDALobj.SaveExceptionToDB(logExcpUIobj); log.Error("[EmployeeFormDAL : DeleteEmployee] An error occured in the processing of Record Id : " + employeeFormUI.Tbl_EmployeeId + ". Details : [" + exp.ToString() + "]"); } return(result); }
protected void btnSave_Click(object sender, EventArgs e) { EmployeeFormUI employeeFormUI = new EmployeeFormUI(); try { employeeFormUI.CreatedBy = SessionContext.UserGuid; employeeFormUI.Tbl_OrganizationId = SessionContext.OrganizationId; employeeFormUI.EmployeeCode = txtEmployeeCode.Text; employeeFormUI.Name = txtName.Text; employeeFormUI.ShortName = txtShortName.Text; employeeFormUI.ChequeName = txtChequeName.Text; employeeFormUI.Contact = txtContact.Text; employeeFormUI.Address = txtAddress.Text; employeeFormUI.City = txtCity.Text; employeeFormUI.ZipCode = txtZipCode.Text; employeeFormUI.Tbl_CountryId = txtCountryGuid.Text; employeeFormUI.Phone = txtPhone.Text; employeeFormUI.Mobile = txtMobile.Text; employeeFormUI.FaxNo = txtFaxNo.Text; employeeFormUI.Email = txtEmail.Text; employeeFormUI.Comment1 = txtComment1.Text; employeeFormUI.Comment2 = txtComment2.Text; employeeFormUI.Opt_Status = Convert.ToInt32(ddlStatus.SelectedValue); if (txtEmployeeGroupGuid.Text != "") { employeeFormUI.Tbl_EmployeeGroupId = txtEmployeeGroupGuid.Text; } else { employeeFormUI.Tbl_EmployeeGroupId = null; } if (chkOnHold.Checked == true) { employeeFormUI.OnHold = true; } else { employeeFormUI.OnHold = false; } if (employeeFormBAL.AddEmployee(employeeFormUI) == 1) { divSuccess.Visible = true; divError.Visible = false; lblSuccess.Text = Resources.GlobalResource.msgRecordInsertedSuccessfully; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "clearform", "ClearForm();", true); } else { divSuccess.Visible = false; divError.Visible = true; lblError.Text = Resources.GlobalResource.msgCouldNotInsertRecord; } } catch (Exception exp) { logExcpUIobj.MethodName = "btnSave_Click()"; logExcpUIobj.ResourceName = "System_Settings_BatchForm.CS"; logExcpUIobj.RecordId = "New Record"; logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString(); logExcpDALobj.SaveExceptionToDB(logExcpUIobj); log.Error("[System_Settings_BatchForm : btnSave_Click] An error occured in the processing of Record Details : [" + exp.ToString() + "]"); } }
public int AddEmployee(EmployeeFormUI employeeFormUI) { int result = 0; try { using (SqlConnection SupportCon = new SqlConnection(connectionString)) { SupportCon.Open(); SqlCommand sqlCmd = new SqlCommand("SP_Employee_Insert", SupportCon); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.CommandTimeout = commandTimeout; sqlCmd.Parameters.Add("@CreatedBy", SqlDbType.NVarChar); sqlCmd.Parameters["@CreatedBy"].Value = employeeFormUI.CreatedBy; sqlCmd.Parameters.Add("@tbl_OrganizationId", SqlDbType.NVarChar); sqlCmd.Parameters["@tbl_OrganizationId"].Value = employeeFormUI.Tbl_OrganizationId; sqlCmd.Parameters.Add("@EmployeeCode", SqlDbType.NVarChar); sqlCmd.Parameters["@EmployeeCode"].Value = employeeFormUI.EmployeeCode; sqlCmd.Parameters.Add("@Name", SqlDbType.NVarChar); sqlCmd.Parameters["@Name"].Value = employeeFormUI.Name; sqlCmd.Parameters.Add("@ShortName", SqlDbType.NVarChar); sqlCmd.Parameters["@ShortName"].Value = employeeFormUI.ShortName; sqlCmd.Parameters.Add("@ChequeName", SqlDbType.NVarChar); sqlCmd.Parameters["@ChequeName"].Value = employeeFormUI.ChequeName; sqlCmd.Parameters.Add("@Contact", SqlDbType.NVarChar); sqlCmd.Parameters["@Contact"].Value = employeeFormUI.Contact; sqlCmd.Parameters.Add("@Address", SqlDbType.NVarChar); sqlCmd.Parameters["@Address"].Value = employeeFormUI.Address; sqlCmd.Parameters.Add("@City", SqlDbType.NVarChar); sqlCmd.Parameters["@City"].Value = employeeFormUI.City; sqlCmd.Parameters.Add("@ZipCode", SqlDbType.NVarChar); sqlCmd.Parameters["@ZipCode"].Value = employeeFormUI.ZipCode; sqlCmd.Parameters.Add("@tbl_CountryId", SqlDbType.NVarChar); sqlCmd.Parameters["@tbl_CountryId"].Value = employeeFormUI.Tbl_CountryId; sqlCmd.Parameters.Add("@Phone", SqlDbType.NVarChar); sqlCmd.Parameters["@Phone"].Value = employeeFormUI.Phone; sqlCmd.Parameters.Add("@Mobile", SqlDbType.NVarChar); sqlCmd.Parameters["@Mobile"].Value = employeeFormUI.Mobile; sqlCmd.Parameters.Add("@FaxNo", SqlDbType.NVarChar); sqlCmd.Parameters["@FaxNo"].Value = employeeFormUI.FaxNo; sqlCmd.Parameters.Add("@Email", SqlDbType.NVarChar); sqlCmd.Parameters["@Email"].Value = employeeFormUI.Email; sqlCmd.Parameters.Add("@Comment1", SqlDbType.NVarChar); sqlCmd.Parameters["@Comment1"].Value = employeeFormUI.Comment1; sqlCmd.Parameters.Add("@Comment2", SqlDbType.NVarChar); sqlCmd.Parameters["@Comment2"].Value = employeeFormUI.Comment2; sqlCmd.Parameters.Add("@Status", SqlDbType.TinyInt); sqlCmd.Parameters["@Status"].Value = employeeFormUI.Opt_Status; sqlCmd.Parameters.Add("@tbl_EmployeeGroupId", SqlDbType.NVarChar); sqlCmd.Parameters["@tbl_EmployeeGroupId"].Value = employeeFormUI.Tbl_EmployeeGroupId; sqlCmd.Parameters.Add("@OnHold", SqlDbType.Bit); sqlCmd.Parameters["@OnHold"].Value = employeeFormUI.OnHold; result = sqlCmd.ExecuteNonQuery(); sqlCmd.Dispose(); SupportCon.Close(); } } catch (Exception exp) { logExcpUIobj.MethodName = "AddEmployee()"; logExcpUIobj.ResourceName = "EmployeeFormDAL.CS"; logExcpUIobj.RecordId = ""; logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString(); logExcpDALobj.SaveExceptionToDB(logExcpUIobj); log.Error("[EmployeeFormDAL : AddEmployee] An error occured in the processing of Record. Details : [" + exp.ToString() + "]"); } return(result); }