private void Bind() { string strTrackingNo = ucSearchControl.TrackingNo; string strCode = ucSearchControl.Code; List <UnloadingBLL> list = new List <UnloadingBLL>(); UnloadingBLL obj = new UnloadingBLL(); list = obj.Search(strCode, strTrackingNo); if (list != null) { if (list.Count > 0) { this.gvUnloading.DataSource = list; this.gvUnloading.DataBind(); } else { this.lblmsg.Text = "No Matching Records Found"; } } else { this.lblmsg.Text = "No Matching Records Found"; } }
protected void gvUnloading_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { UnloadingBLL obj = (UnloadingBLL)e.Row.DataItem; Label lblCG = (Label)e.Row.Cells[2].FindControl("lblCommodityGrade"); lblCG.Text = CommodityGradeBLL.GetCommodityGradeNameById(obj.CommodityGradeId); } }
private void LoadUnloading(Guid commDepositeId) { UnloadingBLL objUnloading = new UnloadingBLL(); objUnloading = objUnloading.GetApprovedUnloadingByCommodityDepositeId(commDepositeId); if (objUnloading != null) { this.lblBags.Text = objUnloading.TotalNumberOfBags.ToString(); this.lblDateDeposited.Text = objUnloading.DateDeposited.ToShortDateString(); this.hfBagTypeId.Value = objUnloading.BagTypeId.ToString(); this.hfUnloadingId.Value = objUnloading.Id.ToString(); BagTypeBLL objBagType = new BagTypeBLL(); //this.lblBagType.Text = objUnloading. } }
public static Nullable <Guid> InsertUnloadingInformation(UnloadingBLL obj, SqlTransaction tran) { Nullable <Guid> Id = null; string strSql = "spInsertUnloading"; SqlParameter[] arPar = new SqlParameter[8]; try { arPar[0] = new SqlParameter("@GradingResultId", SqlDbType.UniqueIdentifier); arPar[0].Value = obj.GradingResultId; arPar[1] = new SqlParameter("@ReceivigRequestId", SqlDbType.UniqueIdentifier); arPar[1].Value = obj.ReceivigRequestId; arPar[2] = new SqlParameter("@TotalNumberOfBags", SqlDbType.Int); arPar[2].Value = obj.TotalNumberOfBags; arPar[3] = new SqlParameter("@DateDeposited", SqlDbType.DateTime); arPar[3].Value = obj.DateDeposited; arPar[4] = new SqlParameter("@Remark", SqlDbType.Text); arPar[4].Value = obj.Remark; arPar[5] = new SqlParameter("@Status", SqlDbType.Int); arPar[5].Value = (int)UnloadingStatus.New; arPar[6] = new SqlParameter("@CreatedBy", SqlDbType.UniqueIdentifier); arPar[6].Value = UserBLL.GetCurrentUser(); arPar[7] = new SqlParameter("@BagTypeId", SqlDbType.UniqueIdentifier); arPar[7].Value = obj.BagTypeId; SqlConnection conn = new SqlConnection(); conn = Connection.getConnection(); Id = new Guid(SqlHelper.ExecuteScalar(tran, strSql, arPar).ToString()); return(Id); } catch (Exception ex) { tran.Rollback(); throw new Exception("Unable to insert Unloading Information.", ex); } }
public static bool UpdateUnloading(UnloadingBLL obj, SqlTransaction tran) { int Affectedrow = 0; string strSql = "spUpdateUnloading"; SqlParameter[] arPar = new SqlParameter[5]; try { arPar[0] = new SqlParameter("@Id", SqlDbType.UniqueIdentifier); arPar[0].Value = obj.Id; arPar[1] = new SqlParameter("@TotalNumberofBags", SqlDbType.Int); arPar[1].Value = obj.TotalNumberOfBags; arPar[2] = new SqlParameter("@DateDeposited", SqlDbType.DateTime); arPar[2].Value = obj.DateDeposited; arPar[3] = new SqlParameter("@Status", SqlDbType.Int); arPar[3].Value = (int)obj.Status; arPar[4] = new SqlParameter("@LastModifiedBy", SqlDbType.UniqueIdentifier); arPar[4].Value = UserBLL.GetCurrentUser(); Affectedrow = SqlHelper.ExecuteNonQuery(tran, strSql, arPar); if (Affectedrow == 1) { return(true); } else { return(false); } } catch (Exception ex) { throw new Exception("Unable to Update Unloading Information.", ex); } }
private void LoadUnloading(Guid GradingId) { UnloadingBLL objUnloading = new UnloadingBLL(); objUnloading = objUnloading.GetApprovedUnloadingByGradingId(GradingId); if (objUnloading != null) { this.lblBags.Text = objUnloading.TotalNumberOfBags.ToString(); this.lblDateDeposited.Text = objUnloading.DateDeposited.ToShortDateString(); this.hfBagTypeId.Value = objUnloading.BagTypeId.ToString(); this.hfUnloadingId.Value = objUnloading.Id.ToString(); //Get Bag Info BagTypeBLL objBagType = new BagTypeBLL(); if (string.IsNullOrEmpty(objUnloading.BagTypeId.ToString()) != true) { objBagType.GetBagTypeById(objUnloading.BagTypeId); if (objBagType != null) { if (objBagType.BagTypeName != "") { this.lblBagType.Text = objBagType.BagTypeName.ToString(); } else { this.lblmsg.Text = "Unable To get Bag Type"; return; } } else { this.lblmsg.Text = "Unable To get Bag Type"; return; } } } }
protected void btnSave_Click(object sender, EventArgs e) { this.lblMsg2.Text = ""; this.lblmsg.Text = ""; List <StackUnloadedBLL> listtoBeUpdated = null; List <StackUnloadedBLL> listOriginal = null; if (ViewState["vwStackUnloaded"] == null) { this.lblmsg.Text = "An error has occured please try again.If the error persists contact the administrators"; return; } else { listtoBeUpdated = (List <StackUnloadedBLL>)ViewState["vwStackUnloaded"]; } if (ViewState["vwStackUnloadedOriginal"] == null) { this.lblmsg.Text = "An error has occured please try again.If the error persists contact the administrators"; return; } else { listOriginal = (List <StackUnloadedBLL>)ViewState["vwStackUnloadedOriginal"]; } float remainder; int lotsizeInBags = 0; Guid CommGradeId = new Guid(ViewState["UnloadingCommGradeId"].ToString()); lotsizeInBags = CommodityGradeBLL.GetCommodityGradeLotSizeInBagsById(CommGradeId); UnloadingBLL obj = new UnloadingBLL(); try { obj.Id = new Guid(this.hfUnloadingId.Value.ToString()); } catch { this.lblmsg.Text = "Unable to update this record please try agian"; return; } Nullable <int> totbag = null; if (DataValidationBLL.isInteger(this.txtNumberOfBags.Text, out totbag) == true) { obj.TotalNumberOfBags = (int)totbag; } else { this.lblmsg.Text = "Please Enter Number of bags."; this.txtNumberOfBags.Focus(); return; } //checking that the Number of Bags aree within ecx lot defn. remainder = ((int)totbag) % lotsizeInBags; int SamplerNoBags = -1; int.TryParse(ViewState["SamplingNoBags"].ToString(), out SamplerNoBags); if (SamplerNoBags != -1) { if (((int)totbag) != SamplerNoBags) { //Check string str = " The number of bags counted by the sampler is " + SamplerNoBags.ToString() + " which is different from what you entered. Are you sure you want to save this record?"; lblModalMsg.Text = str; //TODO: Remove Comment //ModalPopupExtender1.Show(); } } //TODO: Remove //ModalPopupExtender mdl = new ModalPopupExtender(); //mdl = ModalPopupExtender1; remainder = ((int)totbag) % lotsizeInBags; if (((int)remainder) != 0) { lblModalMsg.Text = "Per ECX rule, the number of bags entered is not acceptable. Do you still want to save?"; //TODO: Remove Comment //ModalPopupExtender1.Show(); } int totBagCount = 0; if (ViewState["totBagCount"] != null) { if ((int.TryParse(ViewState["totBagCount"].ToString(), out totBagCount)) != true) { this.lblmsg.Text = "Unable to get the total sum of the bags in each stack unloaded.Please return to the search page and try again."; return; } } if (totBagCount != (int)totbag) { this.lblmsg.Text = "The Total Number of bags doesn't match the sum of bags unloaded in each stack."; return; } Nullable <DateTime> depositeddate = null; if (DataValidationBLL.isDate(this.txtDateDeposited.Text, out depositeddate) == true) { obj.DateDeposited = (DateTime)depositeddate; } else { this.lblmsg.Text = "Please select date deposited."; this.txtDateDeposited.Focus(); return; } Nullable <Int32> status = null; if (DataValidationBLL.isInteger(this.cboStatus.SelectedValue.ToString(), out status) == true) { obj.Status = (UnloadingStatus)(Int32)status; } else { this.lblmsg.Text = "Please select Status."; this.cboStatus.Focus(); return; } try { if (ViewState["vwStackUnloaded"] == null) { this.lblmsg.Text = "An error has occured please try agian.If the error persists contact the administrator"; return; } if (obj.Update(listtoBeUpdated, listOriginal) == true) { this.lblmsg.Text = "Data updated Successfully."; } else { this.lblmsg.Text = "Unable to update data please try again."; } } catch (Exception ex) { throw ex; } }
private void BindUnloading() { try { Guid UnloadingId = new Guid(Request.QueryString["Id"].ToString()); this.hfUnloadingId.Value = UnloadingId.ToString(); UnloadingBLL obj = new UnloadingBLL(); CommodityGradeBLL objCommodityGrade = new CommodityGradeBLL(); obj.Id = UnloadingId; obj = obj.GetById(); if (obj != null) { this.lblGradingCode.Text = obj.GradingCode.ToString(); string CommodityGradeName = CommodityGradeBLL.GetCommodityGradeNameById(obj.CommodityGradeId); this.lblCommodityGrade.Text = CommodityGradeName; this.txtNumberOfBags.Text = obj.TotalNumberOfBags.ToString(); this.txtDateDeposited.Text = obj.DateDeposited.ToShortDateString(); this.cboStatus.SelectedValue = ((int)obj.Status).ToString(); ViewState["UnloadingCommGradeId"] = obj.CommodityGradeId; ViewState["totBagCount"] = obj.TotalNumberOfBags.ToString(); // Get Grading Id GradingResultBLL objGradingResult = new GradingResultBLL(); objGradingResult = objGradingResult.GetGradingResultById(obj.GradingResultId); if (objGradingResult != null) { GradingBLL objGrading = new GradingBLL(); objGrading = objGrading.GetById(objGradingResult.GradingId); if (objGrading != null) { SamplingResultBLL objSamplingResult = new SamplingResultBLL(); objSamplingResult = objSamplingResult.GetSamplingResultById(objGrading.SamplingResultId); if (objSamplingResult != null) { ViewState["SamplingNoBags"] = objSamplingResult.NumberOfBags; } else { this.lblmsg.Text = "An error has occured please try again.If the error persists contact the administrator"; return; } } else { this.lblmsg.Text = "An error has occured please try agin.If the error persists contact the administrator"; return; } } } //TODO :Remove the ff // this.cboStackNo.Items.Add(new ListItem("Stack No 1", "eaf7ebcc-f39a-4c7d-b855-1e5d5578dbcb")); //TODO Remove Comment Guid warehouseId = UserBLL.GetCurrentWarehouse(); // Loading shedby warehouse. ShedBLL shed = new ShedBLL(); List <ShedBLL> shedlist = new List <ShedBLL>(); shedlist = shed.GetActiveShedByWarehouseId(warehouseId); cboShed.Items.Add(new ListItem("Please select Shed", "")); if (shedlist.Count > 0) { foreach (ShedBLL o in shedlist) { cboShed.Items.Add(new ListItem(o.ShedNumber, o.Id.ToString())); } } else { this.btnAdd.Enabled = false; } GRNBLL objGRN = new GRNBLL(); string strE = " UnLoadingId='" + UnloadingId.ToString() + "' "; if (objGRN.IsEditableGRN(strE) == false) { this.btnAdd.Enabled = false; this.btnSave.Enabled = false; this.lblmsg.Text = "You can't edit this information as GRN has already been created using this Unloading Information."; } } catch (Exception ex) { throw ex; } }
public static List <UnloadingBLL> SearchUnloadingInformation(string Code, string TrackingNo) { string strSql = "spGetUnloadingInformationBySearchParameter"; List <UnloadingBLL> list; SqlDataReader reader; SqlParameter[] arPar = new SqlParameter[3]; arPar[0] = new SqlParameter("@GradingCode", SqlDbType.NVarChar, 50); arPar[0].Value = Code; arPar[1] = new SqlParameter("@TransactionId", SqlDbType.NVarChar, 50); arPar[1].Value = TrackingNo; arPar[2] = new SqlParameter("@WarehouseId", SqlDbType.UniqueIdentifier); arPar[2].Value = UserBLL.GetCurrentWarehouse(); SqlConnection conn = null; try { conn = Connection.getConnection(); reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar); if (reader.HasRows) { list = new List <UnloadingBLL>(); while (reader.Read()) { int inserttolist = 0; UnloadingBLL obj = new UnloadingBLL(); try { obj.Id = new Guid(reader["Id"].ToString()); } catch { inserttolist = -1; } try { obj.CommodityGradeId = new Guid(reader["CommodityGradeId"].ToString()); } catch { inserttolist = -1; } obj.TrackingNo = reader["TrackingNo"].ToString(); obj.GradingCode = reader["GradingCode"].ToString(); try { obj.Status = (UnloadingStatus)int.Parse(reader["Status"].ToString()); } catch { } try { obj.TotalNumberOfBags = int.Parse(reader["TotalNumberOfBags"].ToString()); } catch { } try { obj.DateDeposited = DateTime.Parse(reader["DateDeposited"].ToString()); } catch { } if (inserttolist != -1) { list.Add(obj); } } return(list); } else { return(null); } } catch (Exception ex) { throw ex; } finally { if (conn != null) { if (conn.State == ConnectionState.Open) { conn.Close(); } } } }
public static UnloadingBLL GetApprovedUnloadingInformationByGradingResultId(Guid Id) { string strSql = "spGetApprovedUnloadingInformationByGradingResultId"; UnloadingBLL obj; SqlDataReader reader; SqlParameter[] arPar = new SqlParameter[1]; arPar[0] = new SqlParameter("@Id", SqlDbType.UniqueIdentifier); arPar[0].Value = Id; SqlConnection conn = null; try { conn = Connection.getConnection(); reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar); if (reader.HasRows) { obj = new UnloadingBLL(); while (reader.Read()) { obj = new UnloadingBLL(); Nullable <Guid> UnloadingId = null; if (DataValidationBLL.isGUID(reader["Id"].ToString(), out UnloadingId) == true) { obj.Id = (Guid)UnloadingId; } else { throw new Exception("Invalid Id Exception"); } Nullable <Guid> CommodityGradeId = null; if (DataValidationBLL.isGUID(reader["CommodityGradeId"].ToString(), out CommodityGradeId) == true) { obj.CommodityGradeId = (Guid)CommodityGradeId; } obj.TrackingNo = reader["TrackingNo"].ToString(); obj.GradingCode = reader["GradingCode"].ToString(); Nullable <int> status = null; if (DataValidationBLL.isInteger(reader["Status"].ToString(), out status) == true) { obj.Status = (UnloadingStatus)(int)status; } Nullable <int> TotBags = null; if (DataValidationBLL.isInteger(reader["TotalNumberOfBags"].ToString(), out TotBags) == true) { obj.TotalNumberOfBags = (int)TotBags; } Nullable <DateTime> dateDep = null; if (DataValidationBLL.isDate(reader["DateDeposited"].ToString(), out dateDep) == true) { obj.DateDeposited = (DateTime)dateDep; } Nullable <Guid> BagType = null; if (DataValidationBLL.isGUID(reader["BagTypeId"].ToString(), out BagType) == true) { obj.BagTypeId = (Guid)BagType; } } return(obj); } else { return(null); } } catch (Exception ex) { throw ex; } finally { if (conn != null) { if (conn.State == ConnectionState.Open) { conn.Close(); } } } }
private void LoadTruckInformation() { if (this.cboGradingCode.SelectedValue.ToString() == "") { this.lblmsg.Text = "Please select Tracking No."; this.cboGradingCode.SelectedIndex = -1; return; } string str = this.cboGradingCode.SelectedValue.ToString(); string[] temp = new string[2]; temp = str.Split('/'); if (temp[0] == "" || temp[0] == null) { this.lblmsg.Text = "Please try agian."; this.cboGradingCode.SelectedIndex = -1; return; } Guid ReceivigRequestId; try { ReceivigRequestId = new Guid(temp[0].ToString()); } catch { this.lblmsg.Text = "Please try agian."; this.cboGradingCode.SelectedIndex = -1; return; } try { this.hfGradingResultId.Value = temp[1].ToString(); } catch { this.lblmsg.Text = "An error occured, please try agian."; this.cboGradingCode.SelectedIndex = -1; return; } this.hfReceivigRequestId.Value = ReceivigRequestId.ToString(); List <DriverInformationBLL> list = new List <DriverInformationBLL>(); DriverInformationBLL objTruck = new DriverInformationBLL(); list = objTruck.GetActiveDriverInformationByReceivigRequestId(ReceivigRequestId); this.gvDriverInformation.DataSource = list; this.gvDriverInformation.DataBind(); //Get detail gradingResult GradingResultBLL objGradingResult = new GradingResultBLL(); objGradingResult = objGradingResult.GetGradingResultById(new Guid(temp[1].ToString())); UnloadingBLL objUnloading = new UnloadingBLL(); objUnloading = objUnloading.GetApprovedUnloadingByGradingResultId(objGradingResult.ID); if (objUnloading != null) { this.lblDateUnloaded.Text = objUnloading.DateDeposited.ToShortDateString(); this.cmpSampGen.ValueToCompare = objUnloading.DateDeposited.ToShortDateString(); } this.hfTrackingNo.Value = objGradingResult.TrackingNo; }
protected void btnSave_Click(object sender, EventArgs e) { // Get the one lotsize. if (ViewState["UnloadingCommGradeId"] == null) { this.lblmsg.Text = "An error has occured please try again, if the error persists contact the administrator"; return; } int lotsizeInBags = 0; Guid CommGradeId = new Guid(ViewState["UnloadingCommGradeId"].ToString()); lotsizeInBags = CommodityGradeBLL.GetCommodityGradeLotSizeInBagsById(CommGradeId); if (lotsizeInBags == 0) { this.lblmsg.Text = "Unbale to get lot size in bags."; return; } Nullable <int> totalnumberofBags = null; totalnumberofBags = int.Parse(this.txtNumberOfBags.Text); int remainder; this.lblMsg2.Text = ""; this.lblmsg.Text = ""; Nullable <Guid> gradingresultid = null; if (DataValidationBLL.isGUID(this.cboGradingCode.SelectedValue.ToString(), out gradingresultid) == false) { this.lblmsg.Text = "please select Grading Code."; return; } DateTime depositedate; if ((DateTime.TryParse((this.txtDateDeposited.Text) + " " + this.txtTimeDeposited.Text, out depositedate)) == false) { this.lblmsg.Text = "Invalid Date Deposited."; return; } if (string.IsNullOrEmpty(hfTrackingNo.Value) == true) { this.lblmsg.Text = "Unable to get tracking No Please try again."; return; } Guid BagTypeId = Guid.Empty; if (string.IsNullOrEmpty(this.cboBagType.SelectedValue.ToString()) == true) { this.lblmsg.Text = "Unable to get Bag Type No Please try again."; return; } else { try { BagTypeId = new Guid(this.cboBagType.SelectedValue.ToString()); } catch { this.lblmsg.Text = "Unable to get Bag Type No Please try again."; return; } } // UnloadingBLL obj = new UnloadingBLL(); obj.GradingResultId = (Guid)gradingresultid; obj.TotalNumberOfBags = (int)totalnumberofBags; obj.DateDeposited = (DateTime)depositedate; obj.CreatedBy = UserBLL.GetCurrentUser(); obj.ReceivigRequestId = new Guid(this.hfRecivingRequestId.Value.ToString()); obj.TrackingNo = hfTrackingNo.Value; obj.BagTypeId = BagTypeId; List <StackUnloadedBLL> list = new List <StackUnloadedBLL>(); list = (List <StackUnloadedBLL>)ViewState["StackUnloaded"]; int totCount = 0; if (list != null) { foreach (StackUnloadedBLL i in list) { totCount = totCount + i.NumberOfbags; } } if (totCount != totalnumberofBags) { this.lblmsg.Text = "Please Check Total Number of bags against Bags Unloaded in each stack"; bindGrid(); return; } int SamplerNoBags = -1;; if (ViewState["SamplingNoBags"] != null) { SamplerNoBags = int.Parse(ViewState["SamplingNoBags"].ToString()); } if (SamplerNoBags != -1) { if (((int)totalnumberofBags) != SamplerNoBags) { //Check string str = " The number of bags counted by the sampler is " + SamplerNoBags.ToString() + " which is different from what you entered. Are you sure you want to save this record?"; txtReason.InnerText = str; ModalPopupExtender1.Show(); } } ModalPopupExtender mdl = new ModalPopupExtender(); mdl = ModalPopupExtender1; remainder = ((int)totalnumberofBags) % lotsizeInBags; if (((int)remainder) != 0) { txtReason.InnerText = "Per ECX rule, the number of bags entered is not acceptable. Do you still want to save?"; ModalPopupExtender1.Show(); } if (obj.Add(list) == true) { this.lblmsg.Text = "Data Successfully Updated"; Response.Redirect("ListInbox.aspx"); } else { this.lblmsg.Text = "Data can't be added.Please try again."; } }