Пример #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Page.IsPostBack == false)
     {
         this.Page.DataBind();
         if (Session["SamplingId"] != null)
         {
             Guid Id = Guid.Empty;
             Id = new Guid(Session["SamplingId"].ToString());
             Session["SamplingId"] = null;
             if (Id != Guid.Empty)
             {
                 SamplingBLL obj = new SamplingBLL();
                 obj    = obj.GetSampleDetail(Id);
                 obj.Id = Id;
                 if (obj != null)
                 {
                     this.lblSampleCode.Text       = obj.SampleCode;
                     this.txtDateCodeGenrated.Text = obj.GeneratedTimeStamp.ToShortDateString();
                     this.txtTimeArrival.Text      = obj.GeneratedTimeStamp.ToShortTimeString();
                     ViewState["SamplingId"]       = Id;
                     CommodityDepositeRequestBLL objCDR = new CommodityDepositeRequestBLL();
                     objCDR = objCDR.GetCommodityDepositeDetailById(obj.ReceivigRequestId);
                     if (objCDR != null)
                     {
                         lblArrivalDate.Text = objCDR.DateTimeRecived.ToShortDateString();
                     }
                 }
             }
         }
     }
 }
Пример #2
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            List <SamplingBLL>  list         = null;
            string              TrackingNo   = "";
            string              SamplingCode = "";
            Nullable <DateTime> from         = null;
            Nullable <DateTime> to           = null;

            TrackingNo   = this.txtTrackingNo.Text;
            SamplingCode = this.txtSampleCode.Text;
            try
            {
                from = DateTime.Parse(this.txtStratDate.Text);
                to   = DateTime.Parse(this.txtEndDate.Text);
            }
            catch
            {
            }

            list = SamplingBLL.SearchSampling(TrackingNo, SamplingCode, from, to);
            if (list != null)
            {
                if (list.Count > 0)
                {
                    this.gvScaling.DataSource = list;
                    this.gvScaling.DataBind();
                }
            }
            else
            {
                this.lblMessage.Text = "No Records find.";
                return;
            }
        }
Пример #3
0
        protected void btnNext_Click(object sender, EventArgs e)
        {
            //update sampling Date
            Guid SamplingId = Guid.Empty;

            SamplingId = new Guid(ViewState["SamplingId"].ToString());
            DateTime DateCoded;

            try
            {
                DateCoded = DateTime.Parse(this.txtDateCodeGenrated.Text + " " + this.txtTimeArrival.Text);
            }
            catch (ArgumentNullException)
            {
                this.lblMessage.Text = "please Check that Date sampled is in correct format";
                return;
            }
            catch (FormatException)
            {
                this.lblMessage.Text = "please Check that Date sampled is in correct format";
                return;
            }
            SamplingBLL obj = new SamplingBLL();

            obj.Id = SamplingId;
            obj.GeneratedTimeStamp = DateCoded;
            if (obj.UpdateDateCoded() == true)
            {
                this.lblMessage.Text = "Data Updated Successuly";
            }
            else
            {
                this.lblMessage.Text = "Unable to Update data please try again";
            }
        }
Пример #4
0
        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");
        }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SamplingBLL Sampling;
            Guid        id  = new Guid(Request.QueryString["Id"].ToString());
            SamplingBLL obj = new SamplingBLL();

            Sampling = obj.GetSampleDetail(id);

            this.lblSamplingCode.Text = Sampling.SampleCode.ToString();
        }
Пример #6
0
        private void LoadSampling(Guid GradingId)
        {
            SamplingBLL objSampling = new SamplingBLL();

            objSampling = objSampling.GetApprovedSamplesByGradingId(GradingId);
            if (objSampling != null)
            {
                this.lblSampledDate.Text  = objSampling.GeneratedTimeStamp.ToShortDateString();
                this.lblSampleTicket.Text = objSampling.SampleCode;
                this.hfSamplingId.Value   = objSampling.Id.ToString();
            }
        }
Пример #7
0
        public static SamplingBLL GetSampleById(Guid Id)
        {
            SamplingBLL   objSample = new SamplingBLL();
            SqlDataReader reader;
            string        strSql = "spGetSampleById";

            SqlParameter[] arPar = new SqlParameter[1];

            arPar[0]       = new SqlParameter("@samplingId", SqlDbType.UniqueIdentifier);
            arPar[0].Value = Id;
            SqlConnection conn = null;

            try
            {
                conn   = Connection.getConnection();
                reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar);
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        SamplerBLL Sampler = new SamplerBLL();
                        objSample.SerialNo           = Convert.ToInt32(reader["SerialNo"]);
                        objSample.GeneratedTimeStamp = Convert.ToDateTime(reader["GeneratedDate"]);
                        objSample.SampleCode         = reader["SampleCode"].ToString();
                        objSample.ReceivigRequestId  = new Guid(reader["ReceivigRequestId"].ToString());
                        objSample.TrackingNo         = reader["TrackingNo"].ToString();
                        if (reader["GeneratedDate"] != DBNull.Value)
                        {
                            objSample.GeneratedTimeStamp = (DateTime)reader["GeneratedDate"];
                        }
                        Sampler.SamplerId = new Guid(reader["UserId"].ToString());

                        objSample._sampler = Sampler;
                    }
                    return(objSample);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (conn != null)
                {
                    if (conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                    }
                }
            }
            return(null);
        }
Пример #8
0
        protected void gvScaling_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int         index = Convert.ToInt32(e.CommandArgument);
            GridViewRow rw    = this.gvScaling.Rows[index];

            if (e.CommandName == "edit")
            {
                Label lblId = (Label)rw.FindControl("lblId");
                if (lblId.Text != "")
                {
                    Session["SamplingId"] = lblId.Text;
                    Response.Redirect("EditSampling.aspx");
                }
            }
            else if (e.CommandName == "Print")
            {
                Label lblId = (Label)rw.FindControl("lblId");
                if (lblId.Text != "")
                {
                    Guid SId = Guid.Empty;
                    SId = new Guid(lblId.Text);
                    SamplingBLL objSample = new SamplingBLL();
                    objSample = objSample.GetSampleDetail(SId);
                    if (objSample == null)
                    {
                        this.lblMessage.Text = "Unable to print sample Ticket";
                        return;
                    }
                    objSample.Id      = SId;
                    Session["Sample"] = objSample;
                    SamplerBLL objSampler = new SamplerBLL();
                    objSampler = objSampler.GetSamplerBySamplingId(SId)[0];

                    Session["Sampler"] = objSampler;

                    ScriptManager.RegisterStartupScript(this,
                                                        this.GetType(),
                                                        "ShowReport",
                                                        "<script type=\"text/javascript\">" +
                                                        string.Format("javascript:window.open(\"ReportSampleTicket.aspx?id={0}\", \"_blank\",\"height=400px,width=600px,top=0,left=0,resizable=yes,scrollbars=yes\");", lblId.Text.ToString()) +
                                                        "</script>",
                                                        false);
                }
            }
        }
Пример #9
0
        public void BindData(string TranNo)
        {
            this.cboSampler.Items.Clear();

            Guid WarehouseId        = UserBLL.GetCurrentWarehouse();
            List <SamplingBLL> list = new List <SamplingBLL>();
            SamplingBLL        obj  = new SamplingBLL();

            //18-01-2012
            list = obj.GetSamplesPenndingResult(WarehouseId, TranNo);
            this.cboSampleCode.Items.Add(new ListItem("Please Select Sample Code.", ""));
            this.cboSampler.Items.Clear();
            this.cboSampleCode.AppendDataBoundItems = true;
            this.cboSampleCode.DataSource           = list;
            this.cboSampleCode.DataTextField        = "SampleCode";
            this.cboSampleCode.DataValueField       = "Id";
            this.cboSampleCode.DataBind();
        }
Пример #10
0
        public void SamplingCodechanged()
        {
            Guid id = Guid.Empty;

            this.cboSampler.Items.Clear();
            try
            {
                id = new Guid(this.cboSampleCode.SelectedValue.ToString());
            }
            catch
            {
                this.lblMsg.Text = "An error has occured please try again.If the error persists contact the administrator";
                return;
            }
            SamplerBLL        obj         = new SamplerBLL();
            List <SamplerBLL> list        = new List <SamplerBLL>();
            SamplingBLL       objSampling = new SamplingBLL();

            objSampling = objSampling.GetSampleDetail(id);
            if (objSampling != null)
            {
                lblSampleGenratedDateTime.Text = objSampling.GeneratedTimeStamp.ToShortDateString();
                //this.cmpSampGen.ValueToCompare = objSampling.GeneratedTimeStamp.ToShortDateString();
            }
            else
            {
                this.lblMsg.Text = "An error has occured please try again.If the error persists contact the administrator";
                return;
            }


            list = obj.GetSamplerBySamplingId(id);
            if (list != null)
            {
                this.cboSampler.Items.Add(new ListItem("Please Select Sampler.", ""));
                this.cboSampler.AppendDataBoundItems = true;
                foreach (SamplerBLL o in list)
                {
                    this.cboSampler.Items.Add(new ListItem(o.SamplerName, o.SamplerId.ToString()));
                    this.cboSampler.SelectedValue = o.SamplerId.ToString();
                }
            }
            this.cboSampler.Enabled = false;
        }
Пример #11
0
        private void rptSampleTicketCoffee_DataInitialize(object sender, EventArgs e)
        {
            this.txtDateGenerated.Text = DateTime.Today.ToString("dd MMM-yyyy");

            //Load Sample ticket with data.
            if (HttpContext.Current.Session["Sample"] != null)
            {
                SamplingBLL objSampling = new SamplingBLL();
                objSampling = (SamplingBLL)HttpContext.Current.Session["Sample"];
                objSampling = objSampling.GetSampleDetail(objSampling.Id);
                this.txtDateSampled.Text = objSampling.GeneratedTimeStamp.ToString("dd MMM-yyyy");
                this.txtCode.Text        = objSampling.SampleCode.ToString();
                EmployeeAttendanceBLL objEmployee = new EmployeeAttendanceBLL();


                this.txtSamplerName.Text = UserRightBLL.GetUserNameByUserId(objSampling._sampler.SamplerId);
                VoucherInformationBLL objVoucher = new VoucherInformationBLL();
                objVoucher = objVoucher.GetVoucherInformationByCommodityDepositRequestId(objSampling.ReceivigRequestId);
                if (objVoucher != null)
                {
                    this.txtNoBags.Text       = objVoucher.NumberofBags.ToString();
                    this.txtPlompTruck.Text   = objVoucher.NumberOfPlomps.ToString();
                    this.txtPlompTrailer.Text = objVoucher.NumberOfPlompsTrailer.ToString();
                }
                //Get Driver information.
                List <DriverInformationBLL> list = new List <DriverInformationBLL>();
                DriverInformationBLL        obj  = new DriverInformationBLL();
                list = obj.GetActiveDriverInformationByReceivigRequestId(objSampling.ReceivigRequestId);
                if (list != null)
                {
                    if (list.Count == 1)
                    {
                        obj = list[0];
                        this.txtPlateNo.Text        = obj.PlateNumber.ToString();
                        this.txtTrailerPlateNo.Text = obj.TrailerPlateNumber.ToString();
                    }
                }
            }
            HttpContext.Current.Session["Sample"]  = null;
            HttpContext.Current.Session["Sampler"] = null;
        }
Пример #12
0
        public static List <SamplingBLL> GetSamplesPendingCoding(Guid WarehouseId)
        {
            string             strSql = "spGetSamplesPendingCoding";
            SqlDataReader      reader;
            List <SamplingBLL> list;

            SqlParameter[] arPar = new SqlParameter[1];
            SqlConnection  conn  = Connection.getConnection();

            arPar[0]       = new SqlParameter("@WarehouseId", SqlDbType.UniqueIdentifier);
            arPar[0].Value = WarehouseId;
            reader         = SqlHelper.ExecuteReader(Connection.getConnection(), CommandType.StoredProcedure, strSql, arPar);
            if (reader.HasRows)
            {
                list = new List <SamplingBLL>();
                while (reader.Read())
                {
                    SamplingBLL objSampling = new SamplingBLL();
                    objSampling.Id = new Guid(reader["Id"].ToString());
                    objSampling.ReceivigRequestId = new Guid(reader["ReceivigRequestId"].ToString());
                    objSampling.SampleCode        = reader["SampleCode"].ToString();
                    list.Add(objSampling);
                }
                if (conn != null)
                {
                    if (conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                    }
                }
                return(list);
            }
            if (conn != null)
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(null);
        }
Пример #13
0
        public static Nullable <Guid> InsertSample(SamplingBLL objSample, SqlTransaction tran)
        {
            try
            {
                Nullable <Guid> Id = null;

                string         strSql = "spInsertSampling";
                SqlParameter[] arPar  = new SqlParameter[7];

                arPar[0]       = new SqlParameter("@ReceivigRequestId", SqlDbType.UniqueIdentifier);
                arPar[0].Value = objSample.ReceivigRequestId;

                arPar[1]       = new SqlParameter("@SamplingStatusId", SqlDbType.Int);
                arPar[1].Value = 1;

                arPar[2]       = new SqlParameter("@SerialNo", SqlDbType.Int);
                arPar[2].Value = objSample.SerialNo;

                arPar[3]       = new SqlParameter("@GeneratedDate", SqlDbType.DateTime);
                arPar[3].Value = DateTime.Today;

                arPar[4]       = new SqlParameter("@WarehouseId", SqlDbType.UniqueIdentifier);
                arPar[4].Value = objSample.WarehouseId;

                arPar[5]       = new SqlParameter("@CreatedBy", SqlDbType.UniqueIdentifier);
                arPar[5].Value = UserBLL.GetCurrentUser();


                arPar[6]       = new SqlParameter("@TrackingNo", SqlDbType.NVarChar, 50);
                arPar[6].Value = objSample.TrackingNo;

                //   AffectedRows = SqlHelper.ExecuteNonQuery(tran, strSql, arPar);
                Id = new Guid(SqlHelper.ExecuteScalar(Connection.getConnection(), CommandType.StoredProcedure, strSql, arPar).ToString());

                return(Id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #14
0
        protected void btnGenerateSampleTicket_Click(object sender, EventArgs e)
        {
            //

            Nullable <Guid> Id;
            Guid            WarehouseId        = UserBLL.GetCurrentWarehouse();
            Guid            Moistureid         = Guid.Empty;
            bool            isMoisture         = false;
            string          TransactionId      = String.Empty;
            Nullable <Guid> RecievingRequestId = null;

            try
            {
                if (this.chkReSampling.Checked == false)
                {
                    RecievingRequestId = SamplingBLL.GetRandomSample(WarehouseId);
                    isMoisture         = false;
                }
                else
                {
                    try
                    {
                        RecievingRequestId = SamplingBLL.GetRandomReSampling(WarehouseId, out Moistureid, out TransactionId);
                    }
                    catch (Exception ex)
                    {
                        this.lblMsg.Text = ex.Message;
                    }
                    isMoisture = true;
                }
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = ex.Message;
                return;
            }
            if (RecievingRequestId == null)
            {
                this.lblMsg.Text = "There are no records Pending Sampling";
                return;
            }

            Nullable <int> SerialNo  = null;
            SamplingBLL    objSample = new SamplingBLL();

            SerialNo = objSample.GetSerialNo(WarehouseId);
            if (SerialNo == null)
            {
                throw new Exception("Inavlid Serial No. exception");
            }
            // Create sampling obect

            SamplingBLL objSampling = new SamplingBLL();

            objSampling.ReceivigRequestId = (Guid)RecievingRequestId;
            objSampling.SamplingStatusId  = SamplingStatus.Active;
            objSampling.SerialNo          = SamplingBLL.GetSerial(WarehouseId);
            objSampling.WarehouseId       = WarehouseId;

            CommodityDepositeRequestBLL objCommDep = new CommodityDepositeRequestBLL();

            objCommDep = objCommDep.GetCommodityDepositeDetailById((Guid)RecievingRequestId);
            if (objCommDep != null)
            {
                if (string.IsNullOrEmpty(objCommDep.TrackingNo) == true)
                {
                    this.lblMsg.Text = "Can not get Tracking Number.Please try again.";
                    return;
                }
                else
                {
                    if (isMoisture == false)
                    {
                        objSampling.TrackingNo = objCommDep.TrackingNo;
                    }
                    else
                    {
                        objSampling.TrackingNo = TransactionId;
                    }
                }
            }
            else
            {
                throw new Exception("Unable to get Arrival Information CommDepId=" + RecievingRequestId.ToString());
            }

            //Create Sampler
            SamplerBLL objSampler = new SamplerBLL();

            try
            {
                objSampler.SamplerId = new Guid(this.cboSampler.SelectedValue.ToString());
            }
            catch
            {
                this.lblMsg.Text = "Please select Sampler";
                return;
            }

            objSampler.Status = SamplerStatus.Active;



            Id = objSampling.InsertSample(objSampling, objSampler, isMoisture);

            if (Id != null)
            {
                objSampling.Id = (Guid)Id;
                string tran = "";
                tran = SamplingBLL.GetTransactionNumber((Guid)RecievingRequestId);
                Session["Sampler"] = objSampler;
                Session["Sample"]  = objSampling;



                ScriptManager.RegisterStartupScript(this,
                                                    this.GetType(),
                                                    "ShowReport",
                                                    "<script type=\"text/javascript\">" +
                                                    string.Format("javascript:window.open(\"ReportSampleTicket.aspx?id={0}\", \"_blank\",\"height=400px,width=600px,top=0,left=0,resizable=yes,scrollbars=yes\");", Id.ToString()) +
                                                    "</script>",
                                                    false);
            }
            else
            {
                this.lblMsg.Text = "Data can not be saved.Please try again if the error persists contact the administrator.";
            }
        }
Пример #15
0
        public static List <SamplingBLL> GetSamplesPendingResultByTrackingNo(Guid WarehouseId, string TrackingNo)
        {
            string strSql;
            int    path = 2;

            strSql = "spGetSamplesWaitingforResultByTransactionNo";

            SqlDataReader      reader;
            List <SamplingBLL> list;

            SqlParameter[] arPar = null;
            if (path == 1)
            {
                arPar = new SqlParameter[1];

                arPar[0]       = new SqlParameter("@WarehouseId", SqlDbType.UniqueIdentifier);
                arPar[0].Value = WarehouseId;
            }
            else if (path == 2)
            {
                arPar = new SqlParameter[2];

                arPar[0]       = new SqlParameter("@WarehouseId", SqlDbType.UniqueIdentifier);
                arPar[0].Value = WarehouseId;

                arPar[1]       = new SqlParameter("@TransNo", SqlDbType.NVarChar, 50);
                arPar[1].Value = TrackingNo;
            }
            SqlConnection conn = null;

            try
            {
                conn   = Connection.getConnection();
                reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar);
                if (reader.HasRows)
                {
                    list = new List <SamplingBLL>();
                    while (reader.Read())
                    {
                        SamplingBLL objSampling = new SamplingBLL();
                        objSampling.Id         = new Guid(reader["Id"].ToString());
                        objSampling.SampleCode = reader["SampleCode"].ToString();
                        list.Add(objSampling);
                    }
                    return(list);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (conn != null)
                {
                    if (conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                    }
                }
            }
            return(null);
        }
Пример #16
0
 public SamplingDAL(SamplingBLL source)
 {
     this._samplingBLL = source;
 }
Пример #17
0
        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);
        }
Пример #18
0
        public static List <SamplingBLL> Search(string TrackingNo, string SampleCode, Nullable <DateTime> from, Nullable <DateTime> to)
        {
            string strSql   = "Select Id,SampleCode,TrackingNo,GeneratedDate from tblSampling  ";
            string strWhere = " Where ";

            if (TrackingNo != "")
            {
                strWhere += "TrackingNo='" + TrackingNo + "' ";
            }
            if (SampleCode != "")
            {
                if (strWhere != " Where ")
                {
                    strWhere += " or SampleCode='" + SampleCode + "' ";
                }
                else
                {
                    strWhere += " SampleCode='" + SampleCode + "' ";
                }
            }
            if (from != null && to != null)
            {
                if (strWhere != " Where ")
                {
                    strWhere += " and ( GeneratedDate >='" + from.ToString() + "' and GeneratedDate<='" + to.ToString() + "')";
                }
                else
                {
                    strWhere += " ( GeneratedDate >='" + from.ToString() + "' and GeneratedDate<='" + to.ToString() + "')";;
                }
            }
            else if (from != null && to == null)
            {
                if (strWhere != " Where ")
                {
                    strWhere += " and ( GeneratedDate >='" + from.ToString() + "' and GeneratedDate<=" + to.ToString() + "')";
                }
                else
                {
                    strWhere += " GeneratedDate >='" + from.ToString() + "' and GeneratedDate<='" + to.ToString() + "'";
                }
            }
            strSql = strSql + " " + strWhere;
            SqlDataReader reader;

            SqlParameter[] arPar = new SqlParameter[1];
            SqlConnection  conn  = Connection.getConnection();

            reader = SqlHelper.ExecuteReader(Connection.getConnection(), CommandType.Text, strSql);
            List <SamplingBLL> list = null;

            if (reader.HasRows)
            {
                list = new List <SamplingBLL>();
                while (reader.Read())
                {
                    SamplingBLL obj = new SamplingBLL();
                    if (reader["Id"] != DBNull.Value)
                    {
                        obj.Id = new Guid(reader["Id"].ToString());
                    }
                    if (reader["SampleCode"] != DBNull.Value)
                    {
                        obj.SampleCode = reader["SampleCode"].ToString();
                    }
                    if (reader["TrackingNo"] != DBNull.Value)
                    {
                        obj.TrackingNo = reader["TrackingNo"].ToString();
                    }
                    if (reader["GeneratedDate"] != DBNull.Value)
                    {
                        obj.GeneratedTimeStamp = DateTime.Parse(reader["GeneratedDate"].ToString());
                    }

                    list.Add(obj);
                }
                if (conn != null)
                {
                    if (conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                    }
                }
                return(list);
            }
            if (conn != null)
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(null);
        }