private void ScalingInformation(Guid GradingId) { float weight; try { weight = ScalingBLL.GetApprovedWeightByCommoditydeposite(GradingId); this.lblGrossWeight.Text = weight.ToString(); } catch { this.lblmsg.Text = "An error has occured please try again"; return; } Guid ScalingId = Guid.Empty; ScalingBLL objScaling = new ScalingBLL(); try { ScalingId = objScaling.GetScalingIdByGradingId(GradingId); this.hfScalingId.Value = ScalingId.ToString(); this.lblDateScaled.Text = objScaling.GetById(ScalingId).DateWeighed.ToShortDateString(); } catch { this.lblmsg.Text = "An error has occured please try again"; return; } }
protected void btnAdd_Click(object sender, EventArgs e) { ScalingBLL obj = new ScalingBLL(); obj.ReceivigRequestId = new Guid(this.hfReceivigRequestId.Value.ToString()); obj.DriverInformationId = new Guid(this.hfDriverInformationId.Value.ToString()); obj.GradingResultId = new Guid(this.hfGradingResultId.Value.ToString()); obj.ScaleTicketNumber = this.txtScaleTicket.Text; obj.DateWeighed = Convert.ToDateTime((this.txtDateWeighed.Text + " " + this.txtTime.Text)); obj.GrossWeightWithTruck = float.Parse(this.txtGrossTruckWeight.Text); obj.TruckWeight = float.Parse(this.txtTruckWeight.Text); obj.GrossWeight = obj.GrossWeightWithTruck - obj.TruckWeight; obj.Status = ScalingStatus.New; obj.Remark = this.txtRemark.Text; obj.WeigherId = new Guid(this.cboWeigher.SelectedValue.ToString()); if (string.IsNullOrEmpty(this.hfTrackingNo.Value.ToString()) == true) { this.lblmsg.Text = "Unable to get Tracking Number."; return; } if (obj.GrossWeightWithTruck < obj.TruckWeight) { this.lblmsg.Text = "Gross Truck Weight should be greater than Truck Weight."; return; } obj.TrackingNo = this.hfTrackingNo.Value.ToString(); try { if (obj.GetCount() == 0) { if (obj.Add() == true) { this.lblmsg.Text = "Data updated Successfully."; Response.Redirect("ListInbox.aspx"); } else { this.lblmsg.Text = "Please try again."; return; } } else { this.lblmsg.Text = "An active record already exists."; return; } } catch { this.lblmsg.Text = "Unable To add this record please try again."; } finally { Clear(); } }
public static bool Update(ScalingBLL obj, SqlTransaction tran) { int Affectedrow = 0; string strSql = "spUpdateScaling"; SqlParameter[] arPar = new SqlParameter[10]; arPar[0] = new SqlParameter("@Id", SqlDbType.UniqueIdentifier); arPar[0].Value = obj.Id; arPar[1] = new SqlParameter("@ScaleTicketNumber", SqlDbType.NVarChar, 50); arPar[1].Value = obj.ScaleTicketNumber; arPar[2] = new SqlParameter("@DateWeighed", SqlDbType.DateTime); arPar[2].Value = obj.DateWeighed; arPar[3] = new SqlParameter("@GrossWeightWithTruck", SqlDbType.Float); arPar[3].Value = obj.GrossWeightWithTruck; arPar[4] = new SqlParameter("@TruckWeight", SqlDbType.Float); arPar[4].Value = obj.TruckWeight; arPar[5] = new SqlParameter("@GrossWeight", SqlDbType.Float); arPar[5].Value = obj.GrossWeight; arPar[6] = new SqlParameter("@Status", SqlDbType.Int); arPar[6].Value = (int)obj.Status; arPar[7] = new SqlParameter("@Remark", SqlDbType.Int); arPar[7].Value = obj.Remark; arPar[8] = new SqlParameter("@LastModifiedBy", SqlDbType.UniqueIdentifier); arPar[8].Value = UserBLL.GetCurrentUser(); arPar[9] = new SqlParameter("@WeigherId", SqlDbType.UniqueIdentifier); arPar[9].Value = obj.WeigherId; try { Affectedrow = SqlHelper.ExecuteNonQuery(tran, strSql, arPar); if (Affectedrow == 1) { return(true); } else { return(false); } } catch { throw new Exception("Unable to Update Unloading Information."); } }
protected void btnSearch_Click(object sender, EventArgs e) { this.lblMessage.Text = ""; string ScaleTicketNo; Nullable <DateTime> startDateWeighed = null; Nullable <DateTime> endDateWeighed = null; string TrackingNo; string GradingCode; ScaleTicketNo = this.txtScalingNo.Text; if (this.txtStratDate.Text != "") { try { startDateWeighed = DateTime.Parse(this.txtStratDate.Text); } catch { } } if (this.txtEndDate.Text != "") { try { endDateWeighed = DateTime.Parse(this.txtEndDate.Text); } catch { } } TrackingNo = this.txtTrackingNo.Text; GradingCode = this.txtGradingCode.Text; ScalingBLL obj = new ScalingBLL(); try { list = null; list = obj.Search(ScaleTicketNo, startDateWeighed, endDateWeighed, TrackingNo, GradingCode); } catch (Exception ex) { this.lblMessage.Text = ex.Message; } this.gvScaling.DataSource = list; this.gvScaling.DataBind(); if (list == null) { this.lblMessage.Text = "No records Found"; } if (list == null || list.Count == 0) { this.lblMessage.Text = "No records Found"; } }
private void BindData(Guid Id) { ScalingBLL obj = new ScalingBLL(); obj = obj.GetById(Id); if (obj != null) { if (obj.Id != null) { this.hfId.Value = obj.Id.ToString(); } if (obj.ScaleTicketNumber != "") { this.txtScaleTicket.Text = obj.ScaleTicketNumber.ToString(); } if (obj.DateWeighed != null) { this.txtDateWeighed.Text = obj.DateWeighed.ToString(); } this.cboWeigher.SelectedValue = obj.WeigherId.ToString(); this.txtGrossTruckWeight.Text = obj.GrossWeightWithTruck.ToString(); this.txtGrossWeoght.Text = obj.GrossWeight.ToString(); this.txtTruckWeight.Text = obj.TruckWeight.ToString(); this.txtRemark.Text = obj.Remark; this.cboStatus.SelectedValue = ((int)obj.Status).ToString(); DriverInformationBLL objDriver = new DriverInformationBLL(); if (obj.DriverInformationId != null) { objDriver = objDriver.GetById(obj.DriverInformationId); if (objDriver != null) { this.lblPlateNo.Text = objDriver.PlateNumber; this.lblTrailerNo.Text = objDriver.TrailerPlateNumber; } } bool hasGRN = false; GRNBLL objGRN = new GRNBLL(); hasGRN = objGRN.HasGRN("tblScaling", obj.Id); if (hasGRN == true) { this.btnAdd.Enabled = false; this.lblMessage.Text = "You can't update this Data because a GRN has already been Created for it."; } } }
public static ScalingBLL GetById(Guid Id) { string strSql = "spGetScalingInformationById"; SqlConnection conn = new SqlConnection(); try { SqlParameter[] arPar = new SqlParameter[1]; arPar[0] = new SqlParameter("@Id", SqlDbType.UniqueIdentifier); arPar[0].Value = Id; SqlDataReader reader; conn = Connection.getConnection(); reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar); if (reader != null) { if (reader.HasRows) { ScalingBLL obj = new ScalingBLL(); reader.Read(); if (reader["Id"] != null) { obj.Id = new Guid(reader["Id"].ToString()); } if (reader["ReceivigRequestId"] != null) { obj.ReceivigRequestId = new Guid(reader["ReceivigRequestId"].ToString()); } if (reader["ReceivigRequestId"] != DBNull.Value) { obj.ReceivigRequestId = new Guid(reader["ReceivigRequestId"].ToString()); } if (reader["DriverInformationId"] != DBNull.Value) { obj.DriverInformationId = new Guid(reader["DriverInformationId"].ToString()); } if (reader["DriverInformationId"] != DBNull.Value) { obj.DriverInformationId = new Guid(reader["DriverInformationId"].ToString()); } if (reader["DriverInformationId"] != DBNull.Value) { obj.DriverInformationId = new Guid(reader["DriverInformationId"].ToString()); } if (reader["GradingResultId"] != DBNull.Value) { obj.GradingResultId = new Guid(reader["GradingResultId"].ToString()); } if (reader["ScaleTicketNumber"] != DBNull.Value) { obj.ScaleTicketNumber = reader["ScaleTicketNumber"].ToString(); } if (reader["DateWeighed"] != DBNull.Value) { obj.DateWeighed = DateTime.Parse(reader["DateWeighed"].ToString()); } if (reader["GrossWeightWithTruck"] != DBNull.Value) { obj.GrossWeightWithTruck = float.Parse(reader["GrossWeightWithTruck"].ToString()); } if (reader["TruckWeight"] != DBNull.Value) { obj.TruckWeight = float.Parse(reader["TruckWeight"].ToString()); } if (reader["GrossWeight"] != DBNull.Value) { obj.GrossWeight = float.Parse(reader["GrossWeight"].ToString()); } if (reader["Status"] != DBNull.Value) { obj.Status = ((ScalingStatus)int.Parse(reader["Status"].ToString())); } if (reader["Remark"] != DBNull.Value) { obj.Remark = reader["Remark"].ToString(); } if (reader["PreWeightQueueNo"] != DBNull.Value) { obj.PreWeightQueueNo = int.Parse(reader["PreWeightQueueNo"].ToString()); } if (reader["QueueDate"] != DBNull.Value) { obj.QueueDate = DateTime.Parse(reader["QueueDate"].ToString()); } if (reader["WeigherId"] != DBNull.Value) { obj.WeigherId = new Guid(reader["WeigherId"].ToString()); } return(obj); } } else { return(null); } } catch (Exception ex) { throw ex; } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } return(null); }
private static List <ScalingBLL> Searchhelper(string strSql) { List <ScalingBLL> list = new List <ScalingBLL>(); SqlDataReader reader; SqlConnection conn = Connection.getConnection(); try { reader = SqlHelper.ExecuteReader(conn, CommandType.Text, strSql); if (reader.HasRows) { while (reader.Read()) { ScalingBLL obj = new ScalingBLL(); if (reader["Id"] != DBNull.Value) { obj.Id = new Guid(reader["Id"].ToString()); } if (reader["GradingCode"] != DBNull.Value) { obj.GradingCode = reader["GradingCode"].ToString(); } if (reader["GradingCode"] != DBNull.Value) { obj.GradingCode = reader["GradingCode"].ToString(); } if (reader["ScaleTicketNumber"] != DBNull.Value) { obj.ScaleTicketNumber = reader["ScaleTicketNumber"].ToString(); } if (reader["DateWeighed"] != DBNull.Value) { try { obj.DateWeighed = DateTime.Parse(reader["DateWeighed"].ToString()); } catch { } } if (reader["GrossWeight"] != DBNull.Value) { try { obj.GrossWeight = float.Parse(reader["GrossWeight"].ToString()); } catch { } } if (reader["TrackingNo"] != DBNull.Value) { obj.TrackingNo = reader["TrackingNo"].ToString(); } if (reader["WeigherId"] != null) { obj.WeigherId = new Guid(reader["WeigherId"].ToString()); } list.Add(obj); } reader.Dispose(); return(list); } } catch (Exception ex) { throw ex; } finally { if (conn != null) { if (conn.State == ConnectionState.Open) { conn.Close(); } } } return(list); }
public static bool InsertScalingInformation(ScalingBLL obj, SqlTransaction tran) { string strSql = "spInsertScaling"; SqlParameter[] arPar = new SqlParameter[18]; try { arPar[0] = new SqlParameter("@ReceivigRequestId", SqlDbType.UniqueIdentifier); arPar[0].Value = obj.ReceivigRequestId; arPar[1] = new SqlParameter("@DriverInformationId", SqlDbType.UniqueIdentifier); arPar[1].Value = obj.DriverInformationId; arPar[2] = new SqlParameter("@GradingResultId", SqlDbType.UniqueIdentifier); arPar[2].Value = obj.GradingResultId; arPar[3] = new SqlParameter("@ScaleTicketNumber", SqlDbType.NChar, 50); arPar[3].Value = obj.ScaleTicketNumber; arPar[4] = new SqlParameter("@DateWeighed", SqlDbType.DateTime); arPar[4].Value = obj.DateWeighed; arPar[5] = new SqlParameter("@GrossWeightWithTruck", SqlDbType.Float); arPar[5].Value = obj.GrossWeightWithTruck; arPar[6] = new SqlParameter("@TruckWeight", SqlDbType.Float); arPar[6].Value = obj.TruckWeight; arPar[7] = new SqlParameter("@GrossWeight", SqlDbType.Float); arPar[7].Value = obj.GrossWeight; arPar[8] = new SqlParameter("@Status", SqlDbType.Int); arPar[8].Value = (int)obj.Status; arPar[9] = new SqlParameter("@Remark", SqlDbType.Text); arPar[9].Value = obj.Remark; arPar[10] = new SqlParameter("@CreatedBy", SqlDbType.UniqueIdentifier); arPar[10].Value = UserBLL.GetCurrentUser(); arPar[11] = new SqlParameter("@WarehouseId", SqlDbType.UniqueIdentifier); arPar[11].Value = obj.WarehouseId; arPar[12] = new SqlParameter("@PreWeightQueueNo", SqlDbType.Int); arPar[12].Value = obj.PreWeightQueueNo; arPar[13] = new SqlParameter("@QueueNo", SqlDbType.Int); arPar[13].Value = obj.QueueNo; arPar[14] = new SqlParameter("@QueueDate", SqlDbType.DateTime); arPar[14].Value = obj.QueueDate; arPar[15] = new SqlParameter("@QueueDate", SqlDbType.DateTime); arPar[15].Value = obj.WeigherId; arPar[16] = new SqlParameter("@Id", SqlDbType.UniqueIdentifier); arPar[16].Value = obj.Id; arPar[17] = new SqlParameter("@TruckWeightId", SqlDbType.UniqueIdentifier); arPar[17].Value = obj.TruckWeightId; SqlConnection conn = new SqlConnection(); conn = Connection.getConnection(); int AffectedRow = 0; AffectedRow = SqlHelper.ExecuteNonQuery(tran, strSql, arPar); if (AffectedRow == 1) { return(true); } else { return(false); } } catch (Exception ex) { throw ex; throw new Exception("Unable to insert Scaling Information."); } }
private void rptGRN_ReportStart(object sender, EventArgs e) { if (HttpContext.Current.Session["GRNIDPrint"] == null) { throw new Exception("Session expired"); } Guid GRNId = Guid.Empty; GRNId = new Guid(HttpContext.Current.Session["GRNIDPrint"].ToString()); Guid GradingId = Guid.Empty; GRNBLL objGRN = new GRNBLL(); objGRN = objGRN.GetbyGRN_Number(GRNId); GradingId = objGRN.GradingId; this.lblGRN_No.Text = objGRN.GRN_Number; this.lblClient.Text = ClientBLL.GetClinetNameById(objGRN.ClientId); this.lblCommodityGrade.Text = CommodityGradeBLL.GetCommodityGradeNameById(objGRN.CommodityGradeId); this.lblWarehouse.Text = WarehouseBLL.GetWarehouseNameById(objGRN.WarehouseId); this.lblOriginalQuantity.Text = objGRN.OriginalQuantity.ToString(); this.lblNetWeight.Text = objGRN.NetWeight.ToString(); this.lblDateDeposited.Text = objGRN.DateDeposited.ToShortDateString(); this.lblTimeDeposited.Text = objGRN.DateDeposited.ToShortTimeString(); this.lblNoBags.Text = objGRN.TotalNumberOfBags.ToString(); //Bag Type BagTypeBLL objBt = new BagTypeBLL(); objBt.GetBagTypeById(objGRN.BagTypeId); lblBagType.Text = objBt.BagTypeName; //Driver Information List <DriverInformationBLL> list = null; DriverInformationBLL objDI = new DriverInformationBLL(); list = objDI.GetActiveDriverInformationByReceivigRequestId(objGRN.CommodityRecivingId); if (list != null) { string driverName = ""; string plateNo = ""; string driverLicense = ""; string licensceIssuedPlace = ""; foreach (DriverInformationBLL o in list) { if (driverName == "") { driverName = o.DriverName; } else { driverName += "," + o.DriverName; } if (plateNo == "") { if (String.IsNullOrEmpty(o.TrailerPlateNumber) != true) { plateNo = o.PlateNumber + "-" + o.TrailerPlateNumber; } else { plateNo = o.PlateNumber; } } else { if (String.IsNullOrEmpty(o.TrailerPlateNumber) != true) { plateNo += " , " + o.PlateNumber + "-" + o.TrailerPlateNumber; } else { plateNo += " , " + o.PlateNumber; } } if (driverLicense == "") { driverLicense = o.LicenseNumber; } else { driverLicense += " , " + o.LicenseNumber; } if (licensceIssuedPlace == "") { licensceIssuedPlace = o.LicenseIssuedPlace; } else { licensceIssuedPlace += " , " + o.LicenseIssuedPlace; } } this.lblDriverName.Text = driverName; this.lblPlateNo.Text = plateNo; this.lblDriverLicense.Text = driverLicense; this.lblPlaceIssued.Text = licensceIssuedPlace; } // Scaling ScalingBLL objScaling = new ScalingBLL(); objScaling = objScaling.GetById(objGRN.ScalingId); if (objScaling != null) { if (objScaling.WeigherId != null) { try { this.lblWeigherName.Text = UserRightBLL.GetUserNameByUserId(objScaling.WeigherId); } catch { } } } // Sampler SamplerBLL objSampler = new SamplerBLL(); objSampler = objSampler.GetActiveSamplingSupBySamplingId(objGRN.SamplingTicketId); if (objSampler != null) { this.lblSampler.Text = UserRightBLL.GetUserNameByUserId(objSampler.SamplerId); } //Graders GradingByBLL objGrader = new GradingByBLL(); this.lblGrader.Text = objGrader.GetSupGraderNameByGradingId(objGRN.GradingId); if (objGRN.ApprovedBy != null) { try { this.lblApprovedBy.Text = UserRightBLL.GetUserNameByUserId(objGRN.ApprovedBy); } catch { } } if (objGRN.ApprovedTimeStamp != null) { this.lblDateAproved.Text = objGRN.ApprovedTimeStamp.ToShortDateString(); } rpt = new rptGrading(GradingId); rptGS = new rptGRNService(GRNId); this.txtDateGenerated.Text = DateTime.Now.ToString(); ScalingBLL objSacling = new ScalingBLL(); objSacling = objSacling.GetById(objGRN.ScalingId); if (objSacling != null) { this.lblScaleTicketNo.Text = objSacling.ScaleTicketNumber; } this.subReport1.Report = rpt; this.subReport2.Report = this.rptGS; }
protected void btnAdd_Click(object sender, EventArgs e) { ScalingBLL obj = new ScalingBLL(); try { obj.Id = new Guid(this.hfId.Value.ToString()); } catch { this.lblMessage.Text = "An Error has ccured please try again. If the error persists Contact the Administrator"; return; } obj.ScaleTicketNumber = this.txtScaleTicket.Text; try { obj.DateWeighed = DateTime.Parse(this.txtDateWeighed.Text.ToString()); } catch { this.lblMessage.Text = "Incorrect Date weighed"; return; } try { obj.GrossWeightWithTruck = float.Parse(this.txtGrossTruckWeight.Text); } catch { this.lblMessage.Text = "Incorrect Gross Truck Weight"; return; } try { obj.TruckWeight = float.Parse(this.txtTruckWeight.Text); } catch { this.lblMessage.Text = "Incorrect Gross Truck Weight"; return; } obj.GrossWeight = obj.GrossWeightWithTruck - obj.TruckWeight; try { obj.Status = (ScalingStatus)int.Parse(this.cboStatus.SelectedValue.ToString()); } catch { this.lblMessage.Text = "Please Select Status"; return; } obj.Remark = this.txtRemark.Text; obj.WeigherId = new Guid(this.cboWeigher.SelectedValue.ToString()); bool isSaved = false; isSaved = obj.Update(); if (isSaved == true) { this.lblMessage.Text = "Update Sucessfull"; } else { this.lblMessage.Text = "Unable to update.Please try agin"; } }