public static List <TrucksForSamplingBLL> GetTrucksPendingConfirmation(Guid WarehouseId) { List <TrucksForSamplingBLL> list = null; string strSql = "spGetTrucksPendingConfirmation"; SqlConnection conn = null; SqlParameter[] arPar = new SqlParameter[1]; SqlDataReader reader = null; arPar[0] = new SqlParameter("@WarehouseId", SqlDbType.UniqueIdentifier); arPar[0].Value = WarehouseId; try { conn = Connection.getConnection(); reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar); if (reader.HasRows) { list = new List <TrucksForSamplingBLL>(); while (reader.Read()) { TrucksForSamplingBLL obj = new TrucksForSamplingBLL(); obj.Id = new Guid(reader["Id"].ToString()); obj.WarehouseId = WarehouseId; obj.ReceivigRequestId = new Guid(reader["ReceivigRequestId"].ToString()); obj.DriverInformationId = new Guid(reader["DriverInformationId"].ToString()); obj.DateGenerated = DateTime.Parse(reader["DateGenerated"].ToString()); obj.SamplerInspectorId = new Guid(reader["SamplingInspector"].ToString()); obj.Status = (TrucksForSamplingStatus)int.Parse(reader["Status"].ToString()); obj.TrackingNo = reader["TrackingNo"].ToString(); obj.CreatedBy = UserBLL.GetCurrentUser(); obj.PlateNo = reader["PlateNumber"].ToString(); obj.TrailerPlateNo = reader["TrailerPlateNumber"].ToString(); obj.TrackingNo = reader["TrackingNo"].ToString(); list.Add(obj); } } } catch (Exception ex) { throw ex; } finally { reader.Close(); if (conn != null) { if (conn.State == ConnectionState.Open) { conn.Close(); } } } return(list); }
public static bool InsertTruksForSampling(TrucksForSamplingBLL obj, SqlTransaction tran) { string strSql = "spInsertTrucksForSampling"; try { SqlParameter[] arPar = new SqlParameter[9]; 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("@WarehouseId", SqlDbType.UniqueIdentifier); arPar[2].Value = obj.WarehouseId; arPar[3] = new SqlParameter("@TrackingNo", SqlDbType.NChar, 50); arPar[3].Value = obj.TrackingNo; arPar[4] = new SqlParameter("@DateGenerated", SqlDbType.DateTime); arPar[4].Value = obj.DateGenerated; arPar[5] = new SqlParameter("@Status", SqlDbType.Int); arPar[5].Value = (int)obj.Status; arPar[6] = new SqlParameter("@Remark", SqlDbType.Text); arPar[6].Value = obj.Remark; arPar[7] = new SqlParameter("@CreatedBy", SqlDbType.UniqueIdentifier); arPar[7].Value = UserBLL.GetCurrentUser(); arPar[8] = new SqlParameter("@Id", SqlDbType.UniqueIdentifier); arPar[8].Value = obj.Id; int AffectedRow = 0; AffectedRow = SqlHelper.ExecuteNonQuery(tran, strSql, arPar); if (AffectedRow == 1) { return(true); } else { throw new Exception("Unable to Insert all the Data."); } } catch (Exception ex) { throw ex; } }
protected void btnGenerate_Click(object sender, EventArgs e) { this.lblMessage.Text = ""; this.gvDetail.DataSource = null;; this.gvDetail.DataBind(); int NumberOfTrucks = 0; if (this.cboNoTrucks.SelectedValue != "") { NumberOfTrucks = int.Parse(this.cboNoTrucks.SelectedValue); } if (NumberOfTrucks == 0) { this.lblMessage.Text = "Please Select Number of Trucks"; return; } try { List <TrucksForSamplingBLL> list = TrucksForSamplingBLL.GetRandomSample(UserBLL.GetCurrentWarehouse(), NumberOfTrucks); if (list != null) { if (list.Count > 0) { this.gvDetail.DataSource = list; this.gvDetail.DataBind(); this.btnPrint.Visible = true; } else { this.lblMessage.Text = "There are no enteries Trucks Pending Sampling."; } } else { this.lblMessage.Text = "There are no enteries Trucks Pending Sampling."; } } catch (Exception ex) { this.lblMessage.Text = ex.Message; } }
private void BindTrucksPendingConfirmation() { List <TrucksForSamplingBLL> list = new List <TrucksForSamplingBLL>(); TrucksForSamplingBLL obj = new TrucksForSamplingBLL(); list = obj.GetTruckspendingConfirmation(); if (list != null) { if (list.Count > 0) { this.gvDetail.DataSource = list; this.gvDetail.DataBind(); CheckBox chk; foreach (GridViewRow rowItem in gvDetail.Rows) { chk = (CheckBox)(rowItem.FindControl("chkConfirmed")); chk.Checked = true; chk.Enabled = true; chk.Attributes.Add("OnCheckedChanged", "chkCount(this)"); } } else { this.btnConform.Enabled = false; this.lblMessage.Text = "There are no Trucks Pending Confirmation"; this.gvDetail.DataSource = null; this.gvDetail.DataBind(); } } else { this.btnConform.Enabled = false; this.lblMessage.Text = "There are no Trucks Pending Confirmation"; this.gvDetail.DataSource = null; this.gvDetail.DataBind(); } }
public static bool UpdateConfirmation(TrucksForSamplingBLL obj, SqlTransaction tran) { string strSql = "spUpdateTrucksForSamplingConfirmation"; try { SqlParameter[] arPar = new SqlParameter[4]; arPar[0] = new SqlParameter("@Id", SqlDbType.UniqueIdentifier); arPar[0].Value = obj.Id; arPar[1] = new SqlParameter("@Status", SqlDbType.Int); arPar[1].Value = (int)obj.Status; arPar[2] = new SqlParameter("@Remark", SqlDbType.Text); arPar[2].Value = obj.Remark; arPar[3] = new SqlParameter("@LastModifiedBy", SqlDbType.UniqueIdentifier); arPar[3].Value = UserBLL.GetCurrentUser(); int AffectedRow = 0; AffectedRow = SqlHelper.ExecuteNonQuery(tran, strSql, arPar); if (AffectedRow == 1) { return(true); } else { return(false); } } catch (Exception ex) { throw ex; } }
protected void btnConform_Click(object sender, EventArgs e) { //validation CheckBox chk; DropDownList cboRem; Label lblId, lblerr; TextBox lblReMark; List <TrucksForSamplingBLL> list = new List <TrucksForSamplingBLL>(); foreach (GridViewRow rowItem in gvDetail.Rows) { chk = (CheckBox)(rowItem.FindControl("chkConfirmed")); cboRem = (DropDownList)(rowItem.FindControl("cboRemark")); lblReMark = (TextBox)(rowItem.FindControl("txtRemark")); lblerr = (Label)(rowItem.FindControl("lblerr")); //if (chk.Checked != true) //{ // if (cboRem.SelectedValue == "Ready For Sampling") // { // rowItem.CssClass = "GridSelectedRow"; // this.lblMessage.Text = "Please select Reason not selecting the Truck"; // return; // } //} //else //{ // if (cboRem.SelectedValue != "Ready For Sampling") // { // rowItem.CssClass = "GridSelectedRow"; // this.lblMessage.Text = "Please select Reason not selecting the Truck"; // return; // } //} //everthig is fine so update all if (chk.Checked == true) { lblId = (Label)(rowItem.FindControl("lblId")); if (lblId != null) { TrucksForSamplingBLL obj = new TrucksForSamplingBLL(); obj.Id = new Guid(lblId.Text); if (cboRem.SelectedValue.ToString().Trim() == "1") { obj.Status = TrucksForSamplingStatus.Confirmed; } else if (cboRem.SelectedValue.ToString().Trim() == "2") { obj.Status = TrucksForSamplingStatus.TruckMissingOnSamplingQueue; } else { obj.Status = TrucksForSamplingStatus.Other; } if (obj.Status != TrucksForSamplingStatus.Confirmed && obj.Status != TrucksForSamplingStatus.TruckMissingOnSamplingQueue) { if (lblReMark == null) { lblerr.Visible = true; return; } else { if (lblReMark.Text == "") { lblerr.Visible = true; return; } } } else { lblerr.Visible = false; } Label lblTrackingNo = (Label)(rowItem.FindControl("lblTrackingNo")); obj.TrackingNo = lblTrackingNo.Text; if (lblReMark != null) { obj.Remark = lblReMark.Text; } list.Add(obj); } } }////////////////checked // Update the changes bool isSaved = false; TrucksForSamplingBLL objUpdate = new TrucksForSamplingBLL(); isSaved = objUpdate.Confirm(list); if (isSaved == true) { this.lblMessage.Text = "Data updated Successfully"; this.btnConform.Enabled = false; BindTrucksPendingConfirmation(); this.UIAbsentTrucks1.LoadData(); return; } else { this.lblMessage.Text = "Unable to Update Data please try again"; return; } }
/// <summary> /// /// </summary> /// <param name="WarehouseId"></param> /// <returns>Commodity Deposite Request</returns> /// public static List <TrucksForSamplingBLL> GetRandomTrucksForSamplingId(Guid WarehouseId, int NumberOfTrucks) { List <TrucksForSamplingBLL> list = null; string strSql = "spGetTrucksWaitingSampling"; SqlConnection conn = null; SqlParameter[] arPar = new SqlParameter[2]; SqlDataReader reader = null; arPar[0] = new SqlParameter("@WarehouseId", SqlDbType.UniqueIdentifier); arPar[0].Value = WarehouseId; arPar[1] = new SqlParameter("@top", SqlDbType.Int); arPar[1].Value = NumberOfTrucks; try { conn = Connection.getConnection(); reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar); if (reader.HasRows) { list = new List <TrucksForSamplingBLL>(); int counter = 1; while (reader.Read()) { TrucksForSamplingBLL obj = new TrucksForSamplingBLL(); obj.WarehouseId = WarehouseId; obj.ReceivigRequestId = new Guid(reader["Id"].ToString()); if (reader["DriverInformationId"] != DBNull.Value) { obj.DriverInformationId = new Guid(reader["DriverInformationId"].ToString()); } else { obj.DriverInformationId = Guid.Empty; } obj.DateGenerated = DateTime.Now; obj.SamplerInspectorId = UserBLL.GetCurrentUser(); obj.Status = TrucksForSamplingStatus.New; obj.TrackingNo = reader["TrackingNo"].ToString(); obj.CreatedBy = UserBLL.GetCurrentUser(); obj.PlateNo = reader["PlateNumber"].ToString(); obj.TrailerPlateNo = reader["TrailerPlateNumber"].ToString(); if (obj.TrackingNo != "") { try { string strM = ""; strM = WFTransaction.GetMessage(obj.TrackingNo); if (strM.ToUpper() == "GetTrucksReadyForSam".ToUpper()) { if (counter <= NumberOfTrucks) { list.Add(obj); counter++; } } WFTransaction.UnlockTask(obj.TrackingNo); } catch { } } } } } catch (Exception ex) { throw ex; } finally { reader.Close(); if (conn != null) { if (conn.State == ConnectionState.Open) { conn.Close(); } } } return(list); }