Example #1
0
        private void LoadSampler(Guid Id)
        {
            List <SamplerBLL> list = new List <SamplerBLL>();
            SamplerBLL        obj  = new SamplerBLL();

            list = obj.GetSamplerBySamplingId(Id);
            if (list != null)
            {
                this.cboSampler.Items.Clear();


                List <UserBLL> listE = UserRightBLL.GetUsersWithRight("Sampler");
                if (listE != null)
                {
                    foreach (UserBLL b in listE)
                    {
                        this.cboSampler.Items.Add(new ListItem(b.UserName, b.UserId.ToString()));
                    }
                    if (list != null)
                    {
                        this.cboSampler.SelectedValue = list[0].SamplerId.ToString();
                    }
                }
                else
                {
                    if (list != null)
                    {
                        foreach (SamplerBLL i in list)
                        {
                            this.cboSampler.Items.Add(new ListItem(UserBLL.GetName(i.SamplerId), i.SamplerId.ToString()));
                        }
                    }
                }
            }
        }
Example #2
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);
        }
Example #3
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);
                }
            }
        }
Example #4
0
        public static List <SamplerBLL> GetSamplerBySamplingId(Guid SamplingId)
        {
            List <SamplerBLL> list;
            string            strSql = "spGetSamplersBySamplingTicketId";

            SqlParameter[] arPar = new SqlParameter[4];
            arPar[0]       = new SqlParameter("@SamplingTicketId", SqlDbType.UniqueIdentifier);
            arPar[0].Value = SamplingId;
            SqlDataReader reader;
            SqlConnection conn = null;

            try
            {
                conn   = Connection.getConnection();
                reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar);
                if (reader.HasRows)
                {
                    list = new List <SamplerBLL>();
                    while (reader.Read())
                    {
                        SamplerBLL objsampler = new SamplerBLL();
                        objsampler.SamplerId = new Guid(reader["UserId"].ToString());

                        list.Add(objsampler);
                    }
                    return(list);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (conn != null)
                {
                    if (conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                    }
                }
            }
            return(null);
        }
Example #5
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;
        }
Example #6
0
        public static bool InsertSampler(SamplerBLL obj, SqlTransaction tran)
        {
            try
            {
                string         strSql       = "spInsertSampler";
                int            AffectedRows = 0;
                SqlParameter[] arPar        = new SqlParameter[5];

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

                arPar[1]       = new SqlParameter("@UserId", SqlDbType.UniqueIdentifier);
                arPar[1].Value = obj.SamplerId;

                arPar[2]       = new SqlParameter("@Status", SqlDbType.UniqueIdentifier);
                arPar[2].Value = (int)obj.Status;

                arPar[3]       = new SqlParameter("@CreatedBy", SqlDbType.UniqueIdentifier);
                arPar[3].Value = UserBLL.GetCurrentUser();
                arPar[4]       = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);
                arPar[4].Value = obj.Id;
                AffectedRows   = SqlHelper.ExecuteNonQuery(tran, strSql, arPar);
                if (AffectedRows == -1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw ex;
            }
        }
Example #7
0
        public static SamplerBLL GetActiveSamplerSupBySamplingId(Guid SamplingId)
        {
            string strSql = "spGetActiveSamplerBySamplingTicketId";

            SqlParameter[] arPar = new SqlParameter[4];
            arPar[0]       = new SqlParameter("@SamplingTicketId", SqlDbType.UniqueIdentifier);
            arPar[0].Value = SamplingId;
            SqlDataReader reader;
            SqlConnection conn       = null;
            SamplerBLL    objsampler = null;

            conn   = Connection.getConnection();
            reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar);
            if (reader.HasRows)
            {
                if (reader.Read())
                {
                    objsampler = new SamplerBLL();
                    if (reader["UserId"] != DBNull.Value)
                    {
                        objsampler.SamplerId = new Guid(reader["UserId"].ToString());
                    }
                    else
                    {
                        objsampler.SamplerId = Guid.Empty;
                    }
                }
            }
            if (conn != null)
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(objsampler);
        }
Example #8
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.";
            }
        }
Example #9
0
        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;
        }