protected override void Page_Load(object sender, EventArgs e) { CustomerFormUI customerFormUI = new CustomerFormUI(); if (!Page.IsPostBack) { if (Request.QueryString["CustomerId"] != null) { customerFormUI.Tbl_CustomerId = Request.QueryString["CustomerId"]; BindStatuDropDown(); FillForm(customerFormUI); btnSave.Visible = false; btnClear.Visible = false; btnUpdate.Visible = true; btnDelete.Visible = true; lblHeading.Text = "Update Customer"; } else { BindStatuDropDown(); btnSave.Visible = true; btnClear.Visible = true; btnUpdate.Visible = false; btnDelete.Visible = false; lblHeading.Text = "Add New Customer"; } } }
protected void btnUpdate_Click(object sender, EventArgs e) { CustomerFormUI customerFormUI = new CustomerFormUI(); try { customerFormUI.ModifiedBy = SessionContext.UserGuid; customerFormUI.Tbl_OrganizationId = SessionContext.OrganizationId; customerFormUI.Tbl_CustomerId = Request.QueryString["CustomerId"]; customerFormUI.CustomerCode = txtCustomerCode.Text; customerFormUI.Name = txtName.Text; customerFormUI.ShortName = txtShortName.Text; customerFormUI.StatementName = txtStatementName.Text; customerFormUI.Contact = txtContact.Text; customerFormUI.Address = txtAddress.Text; customerFormUI.City = txtCity.Text; customerFormUI.ZipCode = txtZipCode.Text; customerFormUI.Tbl_CountryId = txtCountryGuid.Text; customerFormUI.Phone = txtPhone.Text; customerFormUI.Mobile = txtMobile.Text; customerFormUI.FaxNo = txtFaxNo.Text; customerFormUI.Email = txtEmail.Text; customerFormUI.Comment1 = txtComment1.Text; customerFormUI.Comment2 = txtComment2.Text; customerFormUI.Opt_Status = Convert.ToInt32(ddlStatus.SelectedValue); customerFormUI.Tbl_CustomerGroupId = txtCustomerGroupGuid.Text; if (chkOnHold.Checked == true) { customerFormUI.OnHold = true; } else { customerFormUI.OnHold = false; } if (customerFormBAL.UpdateCustomer(customerFormUI) == 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 = customerFormUI.Tbl_CustomerId; 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 : " + customerFormUI.Tbl_CustomerId + ". Details : [" + exp.ToString() + "]"); } }
protected void btnDelete_Click(object sender, EventArgs e) { CustomerFormUI customerFormUI = new CustomerFormUI(); try { customerFormUI.Tbl_CustomerId = Request.QueryString["CustomerId"]; if (customerFormBAL.DeleteCustomer(customerFormUI) == 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 = customerFormUI.Tbl_CustomerId; 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 : " + customerFormUI.Tbl_CustomerId + ". Details : [" + exp.ToString() + "]"); } }
public int UpdateCustomer(CustomerFormUI customerFormUI) { int resutl = 0; resutl = customerFormDAL.UpdateCustomer(customerFormUI); return(resutl); }
public int DeleteCustomer(CustomerFormUI customerFormUI) { int resutl = 0; resutl = customerFormDAL.DeleteCustomer(customerFormUI); return(resutl); }
public int AddCustomer(CustomerFormUI customerFormUI) { int resutl = 0; resutl = customerFormDAL.AddCustomer(customerFormUI); return(resutl); }
public DataTable GetCustomerListById(CustomerFormUI customerFormUI) { DataTable dtb = new DataTable(); dtb = customerFormDAL.GetCustomerListById(customerFormUI); return(dtb); }
private void FillForm(CustomerFormUI customerFormUI) { try { DataTable dtb = customerFormBAL.GetCustomerListById(customerFormUI); if (dtb.Rows.Count > 0) { txtCustomerCode.Text = dtb.Rows[0]["CustomerCode"].ToString(); txtName.Text = dtb.Rows[0]["Name"].ToString(); txtShortName.Text = dtb.Rows[0]["ShortName"].ToString(); txtStatementName.Text = dtb.Rows[0]["StatementName"].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(); txtCustomerGroupGuid.Text = dtb.Rows[0]["tbl_CustomerGroupId"].ToString(); txtCustomerGroup.Text = dtb.Rows[0]["CustomerGroupName"].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_Customer_Supplier_Master_Creation_CustomerForm.CS"; logExcpUIobj.RecordId = customerFormUI.Tbl_CustomerGroupId; logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString(); logExcpDALobj.SaveExceptionToDB(logExcpUIobj); log.Error("[Finance_Accounts_Payable_Customer_Supplier_Master_Creation_CustomerForm : FillForm] An error occured in the processing of Record Id : " + customerFormUI.Tbl_CustomerGroupId + ". Details : [" + exp.ToString() + "]"); } }
public DataTable GetCustomerListById(CustomerFormUI customerFormUI) { DataSet ds = new DataSet(); DataTable dtbl = new DataTable(); try { using (SqlConnection SupportCon = new SqlConnection(connectionString)) { SqlCommand sqlCmd = new SqlCommand("SP_Customer_SelectById", SupportCon); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.CommandTimeout = commandTimeout; sqlCmd.Parameters.Add("@tbl_CustomerId", SqlDbType.NVarChar); sqlCmd.Parameters["@tbl_CustomerId"].Value = customerFormUI.Tbl_CustomerId; using (SqlDataAdapter adapter = new SqlDataAdapter(sqlCmd)) { adapter.Fill(ds); } } if (ds.Tables.Count > 0) { dtbl = ds.Tables[0]; } } catch (Exception exp) { logExcpUIobj.MethodName = "getCustomerListById()"; logExcpUIobj.ResourceName = "CustomerFormDAL.CS"; logExcpUIobj.RecordId = customerFormUI.Tbl_CustomerId; logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString(); logExcpDALobj.SaveExceptionToDB(logExcpUIobj); log.Error("[CustomerFormDAL : getCustomerListById] An error occured in the processing of Record Id : " + customerFormUI.Tbl_CustomerId + ". Details : [" + exp.ToString() + "]"); } finally { ds.Dispose(); } return(dtbl); }
public int DeleteCustomer(CustomerFormUI customerFormUI) { int result = 0; try { using (SqlConnection SupportCon = new SqlConnection(connectionString)) { SupportCon.Open(); SqlCommand sqlCmd = new SqlCommand("SP_Customer_Delete", SupportCon); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.CommandTimeout = commandTimeout; sqlCmd.Parameters.Add("@tbl_CustomerId", SqlDbType.NVarChar); sqlCmd.Parameters["@tbl_CustomerId"].Value = customerFormUI.Tbl_CustomerId; result = sqlCmd.ExecuteNonQuery(); sqlCmd.Dispose(); SupportCon.Close(); } } catch (Exception exp) { logExcpUIobj.MethodName = "DeleteCustomer()"; logExcpUIobj.ResourceName = "CustomerFormDAL.CS"; logExcpUIobj.RecordId = customerFormUI.Tbl_CustomerId; logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString(); logExcpDALobj.SaveExceptionToDB(logExcpUIobj); log.Error("[CustomerFormDAL : DeleteCustomer] An error occured in the processing of Record Id : " + customerFormUI.Tbl_CustomerId + ". Details : [" + exp.ToString() + "]"); } return(result); }
public int AddCustomer(CustomerFormUI customerFormUI) { int result = 0; try { using (SqlConnection SupportCon = new SqlConnection(connectionString)) { SupportCon.Open(); SqlCommand sqlCmd = new SqlCommand("SP_Customer_Insert", SupportCon); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.CommandTimeout = commandTimeout; sqlCmd.Parameters.Add("@CreatedBy", SqlDbType.NVarChar); sqlCmd.Parameters["@CreatedBy"].Value = customerFormUI.CreatedBy; sqlCmd.Parameters.Add("@tbl_OrganizationId", SqlDbType.NVarChar); sqlCmd.Parameters["@tbl_OrganizationId"].Value = customerFormUI.Tbl_OrganizationId; sqlCmd.Parameters.Add("@CustomerCode", SqlDbType.NVarChar); sqlCmd.Parameters["@CustomerCode"].Value = customerFormUI.CustomerCode; sqlCmd.Parameters.Add("@Name", SqlDbType.NVarChar); sqlCmd.Parameters["@Name"].Value = customerFormUI.Name; sqlCmd.Parameters.Add("@ShortName", SqlDbType.NVarChar); sqlCmd.Parameters["@ShortName"].Value = customerFormUI.ShortName; sqlCmd.Parameters.Add("@StatementName", SqlDbType.NVarChar); sqlCmd.Parameters["@StatementName"].Value = customerFormUI.StatementName; sqlCmd.Parameters.Add("@Contact", SqlDbType.NVarChar); sqlCmd.Parameters["@Contact"].Value = customerFormUI.Contact; sqlCmd.Parameters.Add("@Address", SqlDbType.NVarChar); sqlCmd.Parameters["@Address"].Value = customerFormUI.Address; sqlCmd.Parameters.Add("@City", SqlDbType.NVarChar); sqlCmd.Parameters["@City"].Value = customerFormUI.City; sqlCmd.Parameters.Add("@ZipCode", SqlDbType.NVarChar); sqlCmd.Parameters["@ZipCode"].Value = customerFormUI.ZipCode; sqlCmd.Parameters.Add("@tbl_CountryId", SqlDbType.NVarChar); sqlCmd.Parameters["@tbl_CountryId"].Value = customerFormUI.Tbl_CountryId; sqlCmd.Parameters.Add("@Phone", SqlDbType.NVarChar); sqlCmd.Parameters["@Phone"].Value = customerFormUI.Phone; sqlCmd.Parameters.Add("@Mobile", SqlDbType.NVarChar); sqlCmd.Parameters["@Mobile"].Value = customerFormUI.Mobile; sqlCmd.Parameters.Add("@FaxNo", SqlDbType.NVarChar); sqlCmd.Parameters["@FaxNo"].Value = customerFormUI.FaxNo; sqlCmd.Parameters.Add("@Email", SqlDbType.NVarChar); sqlCmd.Parameters["@Email"].Value = customerFormUI.Email; sqlCmd.Parameters.Add("@Comment1", SqlDbType.NVarChar); sqlCmd.Parameters["@Comment1"].Value = customerFormUI.Comment1; sqlCmd.Parameters.Add("@Comment2", SqlDbType.NVarChar); sqlCmd.Parameters["@Comment2"].Value = customerFormUI.Comment2; sqlCmd.Parameters.Add("@Status", SqlDbType.TinyInt); sqlCmd.Parameters["@Status"].Value = customerFormUI.Opt_Status; sqlCmd.Parameters.Add("@tbl_CustomerGroupId", SqlDbType.NVarChar); sqlCmd.Parameters["@tbl_CustomerGroupId"].Value = customerFormUI.Tbl_CustomerGroupId; sqlCmd.Parameters.Add("@OnHold", SqlDbType.Bit); sqlCmd.Parameters["@OnHold"].Value = customerFormUI.OnHold; result = sqlCmd.ExecuteNonQuery(); sqlCmd.Dispose(); SupportCon.Close(); } } catch (Exception exp) { logExcpUIobj.MethodName = "AddCustomer()"; logExcpUIobj.ResourceName = "CustomerFormDAL.CS"; logExcpUIobj.RecordId = ""; logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString(); logExcpDALobj.SaveExceptionToDB(logExcpUIobj); log.Error("[CustomerFormDAL : AddCustomer] An error occured in the processing of Record. Details : [" + exp.ToString() + "]"); } return(result); }