protected void Page_Load(object sender, EventArgs e) { PhysicalLocationFormUI physicalLocationFormUI = new PhysicalLocationFormUI(); if (!Page.IsPostBack) { if (Request.QueryString["PhysicalLocationId"] != null) { physicalLocationFormUI.Tbl_PhysicalLocationId = Request.QueryString["PhysicalLocationId"]; FillForm(physicalLocationFormUI); btnSave.Visible = false; btnClear.Visible = false; btnUpdate.Visible = true; btnDelete.Visible = true; lblHeading.Text = "Update Physical Location"; } else { btnSave.Visible = true; btnClear.Visible = true; btnUpdate.Visible = false; btnDelete.Visible = false; lblHeading.Text = "Add New Physical Location"; } } }
private void FillForm(PhysicalLocationFormUI physicalLocationFormUI) { try { DataTable dtb = physicalLocationFormBAL.GetPhysicalLocationListById(physicalLocationFormUI); if (dtb.Rows.Count > 0) { txtLastInventoryDate.Text = dtb.Rows[0]["LastInventoryDate"].ToString(); txtDescription.Text = dtb.Rows[0]["Description"].ToString(); txtLocationGuid.Text = dtb.Rows[0]["tbl_LocationId"].ToString(); txtLocation.Text = dtb.Rows[0]["tbl_Location"].ToString(); } else { lblError.Text = Resources.GlobalResource.msgCouldNotLoadData; divError.Visible = true; } } catch (Exception exp) { logExcpUIobj.MethodName = "FillForm()"; logExcpUIobj.ResourceName = "PhysicalLocation_PhysicalLocationForm.CS"; logExcpUIobj.RecordId = physicalLocationFormUI.Tbl_PhysicalLocationId; logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString(); logExcpDALobj.SaveExceptionToDB(logExcpUIobj); log.Error("[PhysicalLocation_PhysicalLocationForm : FillForm] An error occured in the processing of Record Details : [" + exp.ToString() + "]"); } }
public int DeletePhysicalLocation(PhysicalLocationFormUI physicalLocationFormUI) { int resutl = 0; resutl = physicalLocationFormDAL.DeletePhysicalLocation(physicalLocationFormUI); return(resutl); }
public DataTable GetPhysicalLocationListById(PhysicalLocationFormUI physicalLocationFormUI) { DataTable dtb = new DataTable(); dtb = physicalLocationFormDAL.GetPhysicalLocationListById(physicalLocationFormUI); return(dtb); }
public int UpdatePhysicalLocation(PhysicalLocationFormUI physicalLocationFormUI) { int result = 0; try { using (SqlConnection SupportCon = new SqlConnection(connectionString)) { SupportCon.Open(); SqlCommand sqlCmd = new SqlCommand("SP_PhysicalLocation_Update", SupportCon); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.CommandTimeout = commandTimeout; sqlCmd.Parameters.Add("@ModifiedBy", SqlDbType.NVarChar); sqlCmd.Parameters["@ModifiedBy"].Value = physicalLocationFormUI.ModifiedBy; sqlCmd.Parameters.Add("@tbl_OrganizationId", SqlDbType.NVarChar); sqlCmd.Parameters["@tbl_OrganizationId"].Value = physicalLocationFormUI.Tbl_OrganizationId; sqlCmd.Parameters.Add("@tbl_PhysicalLocationId", SqlDbType.NVarChar); sqlCmd.Parameters["@tbl_PhysicalLocationId"].Value = physicalLocationFormUI.Tbl_PhysicalLocationId; sqlCmd.Parameters.Add("@tbl_LocationId", SqlDbType.NVarChar); sqlCmd.Parameters["@tbl_LocationId"].Value = physicalLocationFormUI.Tbl_LocationId; sqlCmd.Parameters.Add("@Description", SqlDbType.NVarChar); sqlCmd.Parameters["@Description"].Value = physicalLocationFormUI.Description; sqlCmd.Parameters.Add("@LastInventoryDate", SqlDbType.DateTime); sqlCmd.Parameters["@LastInventoryDate"].Value = physicalLocationFormUI.LastInventoryDate; result = sqlCmd.ExecuteNonQuery(); sqlCmd.Dispose(); SupportCon.Close(); } } catch (Exception exp) { logExcpUIobj.MethodName = "UpdatePhysicalLocation()"; logExcpUIobj.ResourceName = "PhysicalLocationFormDAL.CS"; logExcpUIobj.RecordId = physicalLocationFormUI.Tbl_PhysicalLocationId; logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString(); logExcpDALobj.SaveExceptionToDB(logExcpUIobj); log.Error("[PhysicalLocationFormDAL : UpdatePhysicalLocation] An error occured in the processing of Record Id : " + physicalLocationFormUI.Tbl_PhysicalLocationId + ". Details : [" + exp.ToString() + "]"); } return(result); }
public DataTable GetPhysicalLocationListById(PhysicalLocationFormUI physicalLocationFormUI) { DataSet ds = new DataSet(); DataTable dtbl = new DataTable(); try { using (SqlConnection SupportCon = new SqlConnection(connectionString)) { SqlCommand sqlCmd = new SqlCommand("SP_PhysicalLocation_SelectById", SupportCon); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.CommandTimeout = commandTimeout; sqlCmd.Parameters.Add("@tbl_PhysicalLocationId", SqlDbType.NVarChar); sqlCmd.Parameters["@tbl_PhysicalLocationId"].Value = physicalLocationFormUI.Tbl_PhysicalLocationId; using (SqlDataAdapter adapter = new SqlDataAdapter(sqlCmd)) { adapter.Fill(ds); } } if (ds.Tables.Count > 0) { dtbl = ds.Tables[0]; } } catch (Exception exp) { logExcpUIobj.MethodName = "GetPhysicalLocationListById()"; logExcpUIobj.ResourceName = "PhysicalLocationFormDAL.CS"; logExcpUIobj.RecordId = physicalLocationFormUI.Tbl_PhysicalLocationId; logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString(); logExcpDALobj.SaveExceptionToDB(logExcpUIobj); log.Error("[PhysicalLocationFormDAL : GetPhysicalLocationListById] An error occured in the processing of Record Id : " + physicalLocationFormUI.Tbl_PhysicalLocationId + ". Details : [" + exp.ToString() + "]"); } finally { ds.Dispose(); } return(dtbl); }
protected void btnUpdate_Click(object sender, EventArgs e) { PhysicalLocationFormUI physicalLocationFormUI = new PhysicalLocationFormUI(); try { physicalLocationFormUI.ModifiedBy = SessionContext.UserGuid; physicalLocationFormUI.Tbl_OrganizationId = SessionContext.OrganizationId; physicalLocationFormUI.LastInventoryDate = DateTime.Parse(txtLastInventoryDate.Text); physicalLocationFormUI.Description = txtDescription.Text; physicalLocationFormUI.Tbl_LocationId = txtLocationGuid.Text; physicalLocationFormUI.Tbl_PhysicalLocationId = Request.QueryString["PhysicalLocationId"]; if (physicalLocationFormBAL.UpdatePhysicalLocation(physicalLocationFormUI) == 1) { divSuccess.Visible = true; divError.Visible = false; lblSuccess.Text = Resources.GlobalResource.msgRecordUpdatedSuccessfully; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "clearform", "ClearForm();", true); } else { divSuccess.Visible = false; divError.Visible = true; lblError.Text = Resources.GlobalResource.msgCouldNotUpdateRecord; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "clearform", "ClearForm();", true); } } catch (Exception exp) { logExcpUIobj.MethodName = "btnUpdate_Click()"; logExcpUIobj.ResourceName = "PhysicalLocation_PhysicalLocationForm.CS"; logExcpUIobj.RecordId = ""; logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString(); logExcpDALobj.SaveExceptionToDB(logExcpUIobj); log.Error("[PhysicalLocation_PhysicalLocationForm : btnUpdate_Click] An error occured in the processing of Record Id : " + physicalLocationFormUI.Tbl_PhysicalLocationId + ". Details : [" + exp.ToString() + "]"); } }