public static Nullable <Guid> GetRandomSamplingId(Guid WarehouseId) { Nullable <Guid> Id = null; string strSql = "spGetDepositeRequestWaitingSampling"; SqlConnection conn = Connection.getConnection(); SqlParameter[] arPar = new SqlParameter[1]; List <SamplingBLL> list = null; SqlDataReader reader; try { arPar[0] = new SqlParameter("@WarehouseId", SqlDbType.UniqueIdentifier); arPar[0].Value = WarehouseId; String strId = ""; reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar); if (reader.HasRows) { list = new List <SamplingBLL>(); while (reader.Read()) { SamplingBLL objSampling = new SamplingBLL(); if (reader["ReceivigRequestId"] != DBNull.Value) { objSampling.Id = new Guid(reader["ReceivigRequestId"].ToString()); } if (reader["TrackingNo"] != DBNull.Value) { objSampling.TrackingNo = reader["TrackingNo"].ToString(); } list.Add(objSampling); } if (list.Count < 1) { return(null); } else { foreach (SamplingBLL o in list) { try { string strm = WFTransaction.GetMessage(o.TrackingNo); if (strm.ToUpper() == "GetSampleTicket".ToUpper()) { WFTransaction.UnlockTask(o.TrackingNo); return(o.Id); } else { WFTransaction.UnlockTask(o.TrackingNo); } } catch { } } } } else { return(null); } } catch (NullReferenceException ex) { return(null); } catch (Exception ex) { throw ex; } finally { if (conn != null || conn.State == ConnectionState.Open) { conn.Close(); } } return(Id); }
protected void btnSearch_Click(object sender, EventArgs e) { #region co //string taskNo = txtTaskNo.Text.Trim(); //if (taskNo != string.Empty) //{ // XMLHelper objHelper = new XMLHelper(Session["Inboxpath"].ToString()); // InboxItems item = objHelper.SearchByInboxItemName(Session["WarehouseInboxItemName"].ToString()); // List<TransactionDetail> listDisplay = item.GetTransactions().Where(t => t.TrackNo == taskNo).ToList(); // if ("Select Trucks For Sampling" == Session["WarehouseInboxItemName"].ToString()) // { // TransactionDetail obj = new TransactionDetail("", ""); // obj.DisplayName = "Select Trucks for Sampling"; // obj.TrackNo = "GetTrucksReadyForSam"; // listDisplay.RemoveAll(RemovePredicate); // listDisplay.Add(obj); // } // else if ("Confirm Trucks For Sampling" == Session["WarehouseInboxItemName"].ToString()) // { // TransactionDetail obj = new TransactionDetail("", ""); // obj.DisplayName = "Confirm Truks For Sampling"; // obj.TrackNo = "ConfirmTrucksForSamp"; // listDisplay.RemoveAll(RemovePredicate); // listDisplay.Add(obj); // } // else if ("Assign Sampler".Trim() == Session["WarehouseInboxItemName"].ToString().Trim()) // { // TransactionDetail obj = new TransactionDetail("", ""); // obj.DisplayName = "Assign Sampler"; // obj.TrackNo = "GetSampleTicket"; // listDisplay.RemoveAll(RemovePredicate); // listDisplay.Add(obj); // } // this.gvDetail.DataSource = listDisplay; // this.gvDetail.DataBind(); //} #endregion if (string.IsNullOrEmpty(txtTaskNo.Text)) { msg.Text = "Please Provide Tracking No."; return; } string strTR = txtTaskNo.Text.Trim(); ECXWF.ECXEngine eng = new WarehouseApplication.ECXWF.ECXEngine(); ECXWF.CMessage[] mess = null; try { //eng.UnlockMessageByUser(Request.QueryString["TranNo"], "AddVoucherInformation", UserBLL.GetCurrentUser()); //eng.RemoveTransactionFromStack(Request.QueryString["TranNo"]); mess = eng.Request(strTR, UserBLL.GetCurrentUser(), new string[] { WarehouseBLL.CurrentWarehouse.Location }); if (mess != null) { WFTransaction.UnlockTask(strTR); List <TransactionDetail> lst = new List <TransactionDetail>(new TransactionDetail[] { new TransactionDetail(strTR, strTR) }); this.gvDetail.DataSource = lst; this.gvDetail.DataBind(); } else { msg.Text = "No Tracking number matchs the supplied criteria"; } } catch (Exception ex) { txtTaskNo.Text = ""; msg.Text = "Re-enter the Tracking No and Try Again"; //throw ex; } }
/// <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); }