public static SamplingResultBLL GetSamplesResultsPendingCodingByTrackingNo(Guid WarehouseId, string TrackingNo) { string strSql = "spGetSamplesResultsPendingCodingByTrackingNo"; SqlDataReader reader; SqlParameter[] arPar = new SqlParameter[2]; SqlConnection conn = Connection.getConnection(); arPar[0] = new SqlParameter("@WarehouseId", SqlDbType.UniqueIdentifier); arPar[0].Value = WarehouseId; arPar[1] = new SqlParameter("@TrackingNo", SqlDbType.NVarChar, 50); arPar[1].Value = TrackingNo; SamplingResultBLL objSamplingResult = null; reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar); if (reader.HasRows) { reader.Read(); objSamplingResult = new SamplingResultBLL(); objSamplingResult.Id = new Guid(reader["Id"].ToString()); objSamplingResult.ReceivigRequestId = new Guid(reader["ReceivigRequestId"].ToString()); objSamplingResult.SamplingResultCode = reader["SampleCode"].ToString(); objSamplingResult.TrackingNo = TrackingNo; } if (conn != null) { if (conn.State == ConnectionState.Open) { conn.Close(); } } return(objSamplingResult); }
private void rptSamplingResult_DataInitialize(object sender, EventArgs e) { SamplingResultBLL objSamplingResult = null; if (HttpContext.Current.Session["SamplingResultCode"] != null) { string Code = HttpContext.Current.Session["SamplingResultCode"].ToString(); objSamplingResult = new SamplingResultBLL(); objSamplingResult = objSamplingResult.GetSamplingResultBySamplingResultCode(Code); } else { throw new Exception("Session expired"); } if (objSamplingResult != null) { this.txtCode.Text = objSamplingResult.SamplingResultCode; this.txtNoBags.Text = objSamplingResult.NumberOfBags.ToString(); SamplingBLL objSampling = new SamplingBLL(); objSampling = objSampling.GetSampleDetail(objSamplingResult.SamplingId); this.txtDateSampled.Text = objSampling.GeneratedTimeStamp.ToString("dd MMM-yyyy"); this.txtDateGenerated.Text = DateTime.Now.ToString("dd MMM-yyyy"); DriverInformationBLL objDriver = new DriverInformationBLL(); List <DriverInformationBLL> listDriver = objDriver.GetActiveDriverInformationByReceivigRequestId(objSampling.ReceivigRequestId); if (listDriver != null) { this.txtPlateNo.Text = listDriver[0].TrailerPlateNumber.ToString(); this.txtTrailerPlateNo.Text = listDriver[0].TrailerPlateNumber.ToString(); } } this.txtDateGenerated.Text = DateTime.Now.ToString("dd MMM-yyyy"); }
public static bool UpdateManagerApproval(SamplingResultBLL obj, SqlTransaction tran) { int AffectedRows = 0; string strSql = "spUpdateManagerApprovalSamplingResult"; SqlParameter[] arPar = new SqlParameter[4]; arPar[0] = new SqlParameter("@Id", SqlDbType.UniqueIdentifier); arPar[0].Value = obj.Id; arPar[1] = new SqlParameter("@ManagerApprovalRemark", SqlDbType.Text); arPar[1].Value = obj.ManagerApprovalRemark; arPar[2] = new SqlParameter("@Status", SqlDbType.Int); arPar[2].Value = (int)obj.Status; arPar[3] = new SqlParameter("@LastModifiedBy", SqlDbType.UniqueIdentifier); arPar[3].Value = UserBLL.GetCurrentUser(); AffectedRows = SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, strSql, arPar); if (AffectedRows == 1) { return(true); } else { return(false); } }
private bool LoadManagerApprovalData(string TrackingNo) { bool isFound = false; SamplingResultBLL obj = new SamplingResultBLL(); obj = obj.GetByTrackingNo(TrackingNo); if (obj != null) { isFound = true; this.cboSampleCode.Items.Clear(); this.cboSampleCode.Items.Add(new ListItem(obj.SamplingResultCode, obj.SamplingId.ToString())); this.cboSampleCode.SelectedValue = obj.SamplingId.ToString(); this.hfSamplingResultId.Value = obj.Id.ToString(); SamplingCodechanged(); this.lblSamplingResultCode.Text = obj.SamplingResultCode; this.lblResultTrackingNo.Text = obj.TrackingNo; this.cboResultStatus.SelectedValue = ((int)obj.Status).ToString(); ViewState["oldResultMA"] = obj; //string[] RightArr = new string[] { "WHSupervisor" }; //List<string> hasRight = UserBLL.HasRoles(UserBLL.GetCurrentUser(), RightArr); //if (hasRight.Count == 1) //{ // this.pnlManagerApproval.Visible = true; //} //else //{ // this.pnlManagerApproval.Visible = false; //} } return(isFound); }
private void LoadData() { // from Query String or smt if (Session["SamplingResultId"] != null) { this.txtId.Value = Session["SamplingResultId"].ToString(); } // get from the Database. SamplingResultBLL obj = new SamplingResultBLL(); obj = obj.GetSamplingResultById(new Guid(this.txtId.Value.ToString())); LoadSampler(obj.SamplingId); // Load Controls this.txtSampleCode.Text = obj.SamplingResultCode.ToString(); this.cboSampler.SelectedValue = obj.EmployeeId.ToString(); this.txtNumberofbags.Text = obj.NumberOfBags.ToString(); //this.txtNumberOfSeparations.Text = obj.NumberOfSeparations.ToString(); this.txtSamplerCommment.Text = obj.SamplerComments; this.txtRemark.Text = obj.Remark; this.chkisSupervisor.Checked = obj.IsSupervisor; this.cboStatus.SelectedValue = ((int)obj.Status).ToString(); List <SamplingResultBLL> listSR = new List <SamplingResultBLL>(); SamplingResultBLL oSr = new SamplingResultBLL(); }
protected void btnSave_Click(object sender, EventArgs e) { bool isSaved = false; // get from the Database. SamplingResultBLL obj = new SamplingResultBLL(); // Load Controls obj.Id = new Guid(this.txtId.Value.ToString()); obj.EmployeeId = new Guid(this.cboSampler.SelectedValue.ToString()); obj.NumberOfBags = Convert.ToInt32(this.txtNumberofbags.Text); //obj.NumberOfSeparations = Convert.ToInt32(this.txtNumberOfSeparations.Text); obj.SamplerComments = this.txtSamplerCommment.Text; obj.Remark = this.txtRemark.Text; obj.IsSupervisor = this.chkisSupervisor.Checked; obj.Status = (SamplingResultStatus)Convert.ToInt32(this.cboStatus.SelectedValue.ToString()); isSaved = obj.Update(); if (isSaved == true) { this.lblMsg.Text = "Data updated Successfully."; LoadData(); } else { this.lblMsg.Text = "Unable to update data."; } }
//GradingDate public static List <SamplingResultBLL> GetSamplesResultsPendingCoding(Guid WarehouseId, string SamplingCode) { string strSql = "spGetSamplesResultsPendingCoding"; SqlDataReader reader; List <SamplingResultBLL> list; SqlParameter[] arPar = new SqlParameter[2]; SqlConnection conn = Connection.getConnection(); arPar[0] = new SqlParameter("@WarehouseId", SqlDbType.UniqueIdentifier); arPar[0].Value = WarehouseId; arPar[1] = new SqlParameter("@SamplingCode", SqlDbType.NVarChar, 50); arPar[1].Value = SamplingCode; reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar); if (reader.HasRows) { list = new List <SamplingResultBLL>(); while (reader.Read()) { SamplingResultBLL objSamplingResult = new SamplingResultBLL(); objSamplingResult.Id = new Guid(reader["Id"].ToString()); objSamplingResult.ReceivigRequestId = new Guid(reader["ReceivigRequestId"].ToString()); objSamplingResult.SamplingResultCode = reader["SampleCode"].ToString(); objSamplingResult.TrackingNo = reader["TrackingNo"].ToString(); //GradingDate if (reader["SampleReturnedDateTime"] != DBNull.Value) { objSamplingResult.ResultReceivedDateTime = DateTime.Parse(reader["SampleReturnedDateTime"].ToString()); } else if (reader["SamplingResultCreatedDate"] != DBNull.Value) { objSamplingResult.ResultReceivedDateTime = DateTime.Parse(reader["SamplingResultCreatedDate"].ToString()); } else { objSamplingResult.ResultReceivedDateTime = DateTime.Now; } list.Add(objSamplingResult); } if (conn != null) { if (conn.State == ConnectionState.Open) { conn.Close(); } } return(list); } if (conn != null) { if (conn.State == ConnectionState.Open) { conn.Close(); } } return(null); }
public static SamplingResultBLL GetGradingDisputePendingCodingByTrackingNo(string TrackingNo) { string strSql = "spGetGradingDisputePendingCodingByTrackingNo"; SqlDataReader reader; SqlParameter[] arPar = new SqlParameter[2]; SqlConnection conn = Connection.getConnection(); arPar[0] = new SqlParameter("@Trackingno", SqlDbType.NVarChar, 50); arPar[0].Value = TrackingNo; arPar[1] = new SqlParameter("@warehouseId", SqlDbType.UniqueIdentifier); arPar[1].Value = UserBLL.GetCurrentWarehouse(); try { reader = SqlHelper.ExecuteReader(Connection.getConnection(), CommandType.StoredProcedure, strSql, arPar); if (reader.HasRows) { reader.Read(); SamplingResultBLL objSampling = new SamplingResultBLL(); if (reader["SamplingResultId"] != DBNull.Value) { objSampling.Id = new Guid(reader["SamplingResultId"].ToString()); } objSampling.ReceivigRequestId = new Guid(reader["ReceivigRequestId"].ToString()); objSampling.SamplingCode = long.Parse(reader["SampleCode"].ToString()); objSampling.TrackingNo = reader["TransactionId"].ToString(); objSampling.SamplingResultCode = reader["SamplingResultCode"].ToString(); return(objSampling); } } catch (Exception ex) { throw ex; } finally { if (conn != null) { if (conn.State == ConnectionState.Open) { conn.Close(); } } } return(null); }
protected void btnManagerApprove_Click(object sender, EventArgs e) { // Update the Record - status - Approved. // Make the WF Proceed. if (btnManagerApprove.Text == "Update") { if (string.IsNullOrEmpty(this.hfSamplingResultId.Value.ToString()) == true) { this.lblMsg.Text = "Unable to get Sampling Result Id.Please Try Again"; return; } if (ViewState["oldResultMA"] == null) { this.lblMsg.Text = "An error has occured please try again.If the error persists contact administrators."; return; } SamplingResultBLL oldObj = (SamplingResultBLL)ViewState["oldResultMA"]; if (oldObj == null) { this.lblMsg.Text = "An error has occured please try again.If the error persists contact administrators."; return; } SamplingResultBLL obj = new SamplingResultBLL(); obj.Id = new Guid(this.hfSamplingResultId.Value.ToString()); obj.Status = (SamplingResultStatus)int.Parse(this.cboResultStatus.SelectedValue.ToString()); obj.ManagerApprovalRemark = this.txtManagerApproval.Text; obj.TrackingNo = this.lblResultTrackingNo.Text; bool isSaved = false; isSaved = obj.UpdateManagerApproval(oldObj); if (isSaved == true) { this.lblMsg.Text = "Data Updated Successfully."; this.btnManagerApprove.Text = "Next"; this.btnManagerApprove.Enabled = true; } else { this.lblMsg.Text = "Unable to update data,please try again."; } } else { Response.Redirect("ListInbox.aspx"); } }
public static bool UpdateSamplingResult(SamplingResultBLL obj, SqlTransaction tran) { int AffectedRows = 0; string strSql = "spUpdateSamplingResult"; SqlParameter[] arPar = new SqlParameter[9]; arPar[0] = new SqlParameter("@Id", SqlDbType.UniqueIdentifier); arPar[0].Value = obj.Id; arPar[1] = new SqlParameter("@EmployeeId", SqlDbType.UniqueIdentifier); arPar[1].Value = obj.EmployeeId; arPar[2] = new SqlParameter("@NumberOfBags", SqlDbType.Int); arPar[2].Value = obj.NumberOfBags; arPar[3] = new SqlParameter("@NumberOfSeparations", SqlDbType.Int); arPar[3].Value = obj.NumberOfSeparations;; arPar[4] = new SqlParameter("@SamplerComments", SqlDbType.Text); arPar[4].Value = obj.SamplerComments; arPar[5] = new SqlParameter("@isSupervisor", SqlDbType.Bit); arPar[5].Value = obj.IsSupervisor; arPar[6] = new SqlParameter("@Status", SqlDbType.Int); arPar[6].Value = (int)obj.Status; arPar[7] = new SqlParameter("@Remark", SqlDbType.Text); arPar[7].Value = obj.Remark; arPar[8] = new SqlParameter("@LastModifiedBy", SqlDbType.UniqueIdentifier); arPar[8].Value = UserBLL.GetCurrentUser(); AffectedRows = SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, strSql, arPar); if (AffectedRows == 1) { return(true); } else { return(false); } }
private void BindData() { string trackingNo = this.txtTrackingNo.Text; string samplecode = ""; if (this.txtSamplingCode.Text == "") { samplecode = null; } else { samplecode = this.txtSamplingCode.Text; } List <SamplingResultBLL> list; SamplingResultBLL obj = new SamplingResultBLL(); list = obj.Search(trackingNo, samplecode); if (list != null) { if (list.Count < 1) { this.lblMsg.Text = "Your Search returns 0 results."; } else { this.gvGradingResult.DataSource = list; this.gvGradingResult.DataBind(); } } else { this.lblMsg.Text = "Your Search returns 0 results."; } }
protected void btnSave_Click(object sender, EventArgs e) { this.lblMsg.Text = ""; bool isSaved = false; Guid SamplingId = Guid.Empty; try { SamplingId = new Guid(this.cboSampleCode.SelectedValue.ToString()); } catch { this.lblMsg.Text = "an error has occured please try agian.if the error persists Contact the administrator."; BindGrid(); return; } SamplingResultBLL objSave = new SamplingResultBLL(); int noSep = -1; noSep = int.Parse(this.txtNumberOfSeparations.Text); //18-01-2012 //List<SamplingResultBLL> list = (List<SamplingResultBLL>)ViewState["SamplingResultList"]; List <SamplingResultBLL> list = (List <SamplingResultBLL>)Session["SamplingResultList"]; if (list != null) { if (noSep != list.Count) { this.lblMsg.Text = "Number of Sampling Result Details should exactly be equal to the number of separations."; BindGrid(); return; } } else { if (noSep > 0) { this.lblMsg.Text = "Number of Sampling Result Details should exactly be equal to the number of separations."; BindGrid(); return; } } DateTime ResultReceivedDateTime; if (DateTime.TryParse(this.txtArrivalDate.Text + " " + txtTimeArrival.Text, out ResultReceivedDateTime) == false) { this.lblMsg.Text = "Please enter a valid Date for Result Received date/time"; BindGrid(); return; } objSave.ResultReceivedDateTime = ResultReceivedDateTime; objSave.IsPlompOk = this.chkPlomps.Checked; isSaved = objSave.Add(list, SamplingId); if (isSaved == true) { this.lblMsg.Text = "Sampling Result Successfully Created."; btnNext.Enabled = true; Clear(); try { this.gvSamplingResultDetail.Columns[2].Visible = false; this.gvSamplingResultDetail.Columns[3].Visible = true; foreach (TableRow row in this.gvSamplingResultDetail.Rows) { LinkButton btn = (LinkButton)(row.FindControl("cmdPrint")); btn.Visible = true; } foreach (TableRow row in this.gvSamplingResultDetail.Rows) { LinkButton btn = (LinkButton)(row.FindControl("cmdRemove")); btn.Visible = false; } } catch (Exception ex) { throw ex; } BindGrid(); } else { this.lblMsg.Text = "An error has occured please try again"; string TranNo; try { TranNo = Request.QueryString["TranNo"]; } catch { TranNo = ""; } BindData(TranNo); } }
protected void btnAdd_Click(object sender, EventArgs e) { this.lblMsg.Text = ""; List <SamplingResultBLL> list = new List <SamplingResultBLL>(); string SampleCode = this.cboSampleCode.SelectedItem.Value.ToString(); //18-01-2012 //if (ViewState["SamplingResultList"] == null || ViewState["SamplingResultList"].ToString() == "") if (Session["SamplingResultList"] == null || Session["SamplingResultList"].ToString() == "") { SamplingResultBLL objSave = new SamplingResultBLL(); objSave.SamplingId = new Guid(this.cboSampleCode.SelectedValue.ToString()); objSave.EmployeeId = new Guid(this.cboSampler.SelectedValue.ToString()); objSave.NumberOfBags = Convert.ToInt32(this.txtNumberofbags.Text); objSave.NumberOfSeparations = Convert.ToInt32(this.txtNumberOfSeparations.Text); objSave.SamplerComments = this.txtSamplerCommment.Text; objSave.IsSupervisor = this.chkisSupervisor.Checked; objSave.Remark = this.txtRemark.Text; objSave.Status = SamplingResultStatus.New; objSave.CreatedBy = UserBLL.GetCurrentUser(); objSave.SamplingResultCode = this.cboSampleCode.SelectedItem.Text.ToString(); objSave.IsPlompOk = this.chkPlomps.Checked; list.Add(objSave); Session["SamplingResultList"] = list; ViewState["MaxCode"] = 0; BindGrid(); } else { //18-01-2012 //list = (List<SamplingResultBLL>)ViewState["SamplingResultList"]; list = (List <SamplingResultBLL>)Session["SamplingResultList"]; if (list.Count >= Convert.ToInt32(this.txtNumberOfSeparations.Text)) { this.lblMsg.Text = "You can not add sampling Results more than the Number of Separations"; BindGrid(); return; } if (ViewState["MaxCode"] == null || ViewState["MaxCode"].ToString() == "") { this.lblMsg.Text = "Please try again!"; BindGrid(); } else { //18-01-2012 //list = (List<SamplingResultBLL>)ViewState["SamplingResultList"]; list = (List <SamplingResultBLL>)Session["SamplingResultList"]; Nullable <int> temp = null; try { temp = int.Parse(ViewState["MaxCode"].ToString()); } catch { this.lblMsg.Text = "Please try again"; BindGrid(); return; } if (temp == null) { this.lblMsg.Text = "Please try again"; BindGrid(); return; } else { temp += 1; } SamplingResultBLL objSave = new SamplingResultBLL(); objSave.SamplingId = new Guid(this.cboSampleCode.SelectedValue.ToString()); objSave.EmployeeId = new Guid(this.cboSampler.SelectedValue.ToString()); try { objSave.NumberOfBags = Convert.ToInt32(this.txtNumberofbags.Text); } catch { this.lblMsg.Text = "Please check Number of Bags"; BindGrid(); return; } try { objSave.NumberOfSeparations = Convert.ToInt32(this.txtNumberOfSeparations.Text); } catch { this.lblMsg.Text = "Please check Numer of Separtions"; BindGrid(); return; } objSave.SamplerComments = this.txtSamplerCommment.Text; objSave.IsSupervisor = this.chkisSupervisor.Checked; objSave.Remark = this.txtRemark.Text; objSave.Status = SamplingResultStatus.New; objSave.CreatedBy = UserBLL.GetCurrentUser(); objSave.SamplingResultCode = this.cboSampleCode.SelectedItem.Text.ToString() + "-" + temp.ToString(); list.Add(objSave); //18-01-2012 //ViewState["SamplingResultList"] = list; Session["SamplingResultList"] = list; ViewState["MaxCode"] = temp; } BindGrid(); } this.txtNumberofbags.Text = ""; }
public static bool InsertSamplingResult(SamplingResultBLL obj, SqlTransaction tran) { int AffectedRows = 0; string strSql = "spInsertSamplingResult"; SqlParameter[] arPar = new SqlParameter[15]; arPar[0] = new SqlParameter("@SamplingId", SqlDbType.UniqueIdentifier); arPar[0].Value = obj.SamplingId; arPar[1] = new SqlParameter("@EmployeeId", SqlDbType.UniqueIdentifier); arPar[1].Value = obj.EmployeeId; arPar[2] = new SqlParameter("@NumberOfBags", SqlDbType.Int); arPar[2].Value = obj.NumberOfBags; arPar[3] = new SqlParameter("@NumberOfSeparations", SqlDbType.Int); arPar[3].Value = obj.NumberOfSeparations; arPar[4] = new SqlParameter("@SamplerComments", SqlDbType.Text); arPar[4].Value = obj.SamplerComments;; arPar[5] = new SqlParameter("@isSupervisor", SqlDbType.Bit); arPar[5].Value = obj.IsSupervisor; arPar[6] = new SqlParameter("@Status", SqlDbType.Int); arPar[6].Value = (int)obj.Status; arPar[7] = new SqlParameter("@Remark", SqlDbType.Text); arPar[7].Value = obj.Remark; arPar[8] = new SqlParameter("@CreatedBy", SqlDbType.UniqueIdentifier); arPar[8].Value = obj.CreatedBy; arPar[9] = new SqlParameter("@SamplingCode", SqlDbType.Int); arPar[9].Value = obj.SamplingCode; arPar[10] = new SqlParameter("@SamplingResultCode", SqlDbType.NVarChar, 50); arPar[10].Value = obj.SamplingResultCode; arPar[11] = new SqlParameter("@isPlompOk", SqlDbType.Bit); arPar[11].Value = obj.IsPlompOk; arPar[12] = new SqlParameter("@TrackingNo", SqlDbType.NChar, 50); arPar[12].Value = obj.TrackingNo; arPar[13] = new SqlParameter("@Id", SqlDbType.UniqueIdentifier); arPar[13].Value = obj.Id; arPar[14] = new SqlParameter("@ResultReceivedTimeStamp", SqlDbType.DateTime); arPar[14].Value = obj.ResultReceivedDateTime; try { AffectedRows = SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, strSql, arPar); } catch (Exception ex) { throw new Exception("Can not update the database.", ex); } if (AffectedRows == -1) { return(true); } else { return(false); } }
public static List <SamplingResultBLL> SearchSamplingResult(string TrackingNo, string SampleCode) { SqlDataReader reader; SqlConnection conn = null; List <SamplingResultBLL> list; string strWhere = ""; string strSql = "select SamplingResultId,SamplingId,TrackingNo, SamplingCode,EmployeeId,NumberOfBags,"; strSql = strSql + " NumberOfSeparations,SamplerComments,isSupervisor,Status,Remark, "; strSql = strSql + " CreatedBy,CreatedTimestamp,LastModifiedBy,LastModifiedTimestamp,SamplingResultCode,IsPlompOk , ResultReceivedTimeStamp"; strSql = strSql + " from vSamplingResult where "; try { if (TrackingNo != "" || SampleCode != null) { if (TrackingNo != "") { strWhere = " TrackingNo='" + TrackingNo + "' "; } if (SampleCode != null) { if (strWhere == "") { strWhere = strWhere + " SamplingCode like '" + @SampleCode + "'"; } else { strWhere = strWhere + " or SamplingCode like '" + SampleCode + "'"; } } strSql = strSql + strWhere + " order By isSupervisor desc "; conn = Connection.getConnection(); reader = SqlHelper.ExecuteReader(conn, CommandType.Text, strSql); if (reader.HasRows) { list = new List <SamplingResultBLL>(); while (reader.Read()) { SamplingResultBLL obj = new SamplingResultBLL(); obj.Id = new Guid(reader["SamplingResultId"].ToString()); obj.SamplingId = new Guid(reader["SamplingId"].ToString()); obj.EmployeeId = new Guid(reader["EmployeeId"].ToString()); obj.NumberOfBags = Convert.ToInt32(reader["NumberOfBags"]); obj.NumberOfSeparations = Convert.ToInt32(reader["NumberOfSeparations"]); obj.IsSupervisor = Convert.ToBoolean(reader["isSupervisor"]); obj.Status = (SamplingResultStatus)reader["Status"]; obj.SamplerComments = reader["SamplerComments"].ToString(); obj.Remark = reader["remark"].ToString(); obj.CreatedBy = new Guid(reader["CreatedBy"].ToString()); obj.CreatedTimeStamp = Convert.ToDateTime(reader["CreatedTimestamp"]); obj.TrackingNo = reader["TrackingNo"].ToString(); obj.SamplingResultCode = reader["SamplingResultCode"].ToString(); if (reader["IsPlompOk"] != null) { obj.IsPlompOk = bool.Parse(reader["IsPlompOk"].ToString()); } else { obj.IsPlompOk = false; } if (reader["LastModifiedBy"] != DBNull.Value) { obj.LastModifiedBy = new Guid(reader["LastModifiedBy"].ToString()); } if (reader["LastModifiedTimestamp"] != DBNull.Value) { obj.LastModifiedTimestamp = Convert.ToDateTime(reader["LastModifiedTimestamp"]); } if (reader["ResultReceivedTimeStamp"] != DBNull.Value) { obj.ResultReceivedDateTime = Convert.ToDateTime(reader["ResultReceivedTimeStamp"]); } list.Add(obj); } return(list); } } else { return(null); } } catch (Exception ex) { throw ex; } finally { if (conn != null) { if (conn.State == ConnectionState.Open) { conn.Close(); } } } return(null); }
private void BindData() { this.cboSampleCode.Items.Clear(); // Load Combo with samplesPendingCoding List <SamplingResultBLL> list = new List <SamplingResultBLL>(); SamplingResultBLL obj = new SamplingResultBLL(); Guid WarehouseId = UserBLL.GetCurrentWarehouse(); string strSC = Session["GradingCodeId"].ToString(); list = obj.GetSamplesResultsPendingCoding(WarehouseId, strSC); this.cboSampleCode.Items.Add(new ListItem("Please Select Sample Code", String.Empty)); this.cboSampleCode.AppendDataBoundItems = true; //GradingDate if (list != null) { int flag = 0; foreach (SamplingResultBLL i in list) { string TempId = i.Id.ToString() + "/" + i.ReceivigRequestId.ToString() + "/" + i.TrackingNo; this.cboSampleCode.Items.Add(new ListItem(i.SamplingResultCode.ToString(), TempId)); if (Session["GradingCodeId"] == null) { this.lblMsg.Text = "your Session has expired"; return; } if (Session["GradingCodeId"].ToString().ToUpper() == i.SamplingResultCode.ToString().ToUpper()) { this.cboSampleCode.SelectedValue = TempId; //GradingDate this.txtSamplingResultDate.Text = i.ResultReceivedDateTime.ToShortDateString(); flag = 1; } } if (flag == 0) { this.cboSampleCode.SelectedIndex = -1; } } else { this.lblMsg.Text = "There are no samples Pending coding."; return; } List <UserBLL> listEmp = new List <UserBLL>(); try { listEmp = UserRightBLL.GetUsersWithRight("Grader"); } catch { this.lblMsg.Text = "No Graders for the warehouse"; return; } if (listEmp != null && listEmp.Count > 0) { this.cboGrader.Items.Clear(); this.cboGrader.AppendDataBoundItems = true; this.cboGrader.Items.Add(new ListItem("Please Select Grader.", "")); listEmp.Sort((x, y) => string.Compare(x.UserName, y.UserName)); foreach (UserBLL o in listEmp) { this.cboGrader.Items.Add(new ListItem(o.FullName, o.UserId.ToString())); } this.cboGrader.AppendDataBoundItems = false; } else { throw new Exception("No Graders Avalaible for the warehouse"); } }
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 SamplingResultBLL GetSamplingResultByTrackingNo(string TrackingNo) { SqlConnection conn = new SqlConnection(); try { string strSql = "spGetSamplingResultListBySamplingTrackingNo"; SqlParameter[] arPar = new SqlParameter[1]; arPar[0] = new SqlParameter("@TrackingNo", SqlDbType.NVarChar, 50); arPar[0].Value = TrackingNo; SqlDataReader reader; conn = Connection.getConnection(); reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar); if (reader != null) { if (reader.HasRows) { SamplingResultBLL obj = new SamplingResultBLL(); reader.Read(); obj.Id = new Guid(reader["Id"].ToString()); obj.SamplingId = new Guid(reader["SamplingId"].ToString()); obj.EmployeeId = new Guid(reader["EmployeeId"].ToString()); obj.NumberOfBags = Convert.ToInt32(reader["NumberOfBags"].ToString()); obj.NumberOfSeparations = Convert.ToInt32(reader["NumberOfSeparations"].ToString()); obj.SamplerComments = reader["SamplerComments"].ToString(); obj.IsSupervisor = Convert.ToBoolean(reader["isSupervisor"]); obj.Status = (SamplingResultStatus)reader["Status"]; obj.Remark = reader["Remark"].ToString(); if (reader["SampleCode"] != DBNull.Value) { obj.SamplingCode = long.Parse(reader["SampleCode"].ToString()); } if (reader["SamplingResultCode"] != DBNull.Value) { obj.SamplingResultCode = reader["SamplingResultCode"].ToString(); } if (reader["TrackingNo"] != DBNull.Value) { obj.TrackingNo = reader["TrackingNo"].ToString(); } if (reader["IsPlompOk"] != DBNull.Value) { obj.IsPlompOk = bool.Parse(reader["IsPlompOk"].ToString()); } else { obj.IsPlompOk = false; } if (reader["ResultReceivedTimeStamp"] != DBNull.Value) { obj.ResultReceivedDateTime = DateTime.Parse(reader["ResultReceivedTimeStamp"].ToString()); } return(obj); } } else { return(null); } } catch (Exception ex) { throw ex; } finally { if (conn != null) { if (conn.State == ConnectionState.Open) { conn.Close(); } } } return(null); }
private void selectedGradechanged(Guid Id) { GradingResultBLL obj = new GradingResultBLL(); obj = obj.GetGradingResultById(Id); this.cboGradingCode.Items.Add(new ListItem(obj.GradingCode.ToString(), obj.GradingCode.ToString())); this.cboGradingCode.SelectedValue = obj.GradingCode.ToString(); this. hfTrackingNo.Value = obj.TrackingNo; if (obj != null) { this.hfRecivingRequestId.Value = obj.CommodityDepositRequestId.ToString(); CommodityGradeBLL objCG = new CommodityGradeBLL(); string CGName; CGName = CommodityGradeBLL.GetCommodityGradeNameById(obj.CommodityGradeId); ViewState["UnloadingCommGradeId"] = obj.CommodityGradeId; this.lblCommodityGrade.Text = CGName; lblCADateTime.Text = ((DateTime)obj.ClientAcceptanceTimeStamp).ToShortDateString(); //try //{ // cmpSampGen.ValueToCompare = ((DateTime)obj.ClientAcceptanceTimeStamp).ToShortDateString(); //} //catch //{ // cmpSampGen.ValueToCompare = ((DateTime.Now).AddDays(-100)).ToShortDateString(); //} // Get Grading Id GradingBLL objGrading = new GradingBLL(); objGrading = objGrading.GetById(obj.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 agin.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; } } else { this.lblmsg.Text = "please select grading code and try again."; return; } //Load Commodity Grade Bags List <BagTypeBLL> list = new List <BagTypeBLL>(); BagTypeBLL objBagType = new BagTypeBLL(); list = objBagType.GetCommodityGradeBag(obj.CommodityGradeId); this.cboBagType.Items.Clear(); if (list != null) { if (list.Count > 0) { this.cboBagType.Items.Add(new ListItem("Please Select Bag Type", "")); foreach (BagTypeBLL i in list) { this.cboBagType.Items.Add(new ListItem(i.BagTypeName, i.Id.ToString())); } } } }