Ejemplo n.º 1
0
        public static bool ClientAcceptanceGradingResult(GradingResultBLL obj, SqlTransaction tran)
        {
            int    AffectedRows = 0;
            string strSql       = "spGradingResultClientAccptance";

            SqlParameter[] arPar = new SqlParameter[7];
            try
            {
                arPar[0]       = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);
                arPar[0].Value = obj.ID;
                arPar[1]       = new SqlParameter("@Status", SqlDbType.Int);
                arPar[1].Value = obj.Status;
                arPar[2]       = new SqlParameter("@ClientAcceptanceTimeStamp", SqlDbType.DateTime);
                arPar[2].Value = obj.ClientAcceptanceTimeStamp;
                arPar[3]       = new SqlParameter("@LastModifiedBy", SqlDbType.UniqueIdentifier);
                arPar[3].Value = UserBLL.GetCurrentUser();
                arPar[4]       = new SqlParameter("@PreWeightQueueNo", SqlDbType.Int);
                arPar[4].Value = obj.PreWeightQueueNo;
                arPar[5]       = new SqlParameter("@QueueNo", SqlDbType.Int);
                arPar[5].Value = obj.QueueNo;
                arPar[6]       = new SqlParameter("@QueueDate", SqlDbType.DateTime);
                arPar[6].Value = obj.QueueDate;


                AffectedRows = SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, strSql, arPar);
                return(AffectedRows == 1);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            bool             isSaved = false;
            DateTime         dt      = Convert.ToDateTime(this.txtDateOfAcceptance.Text + " " + this.txtTimeodAcceptance.Text);
            GradingResultBLL objR    = new GradingResultBLL();
            Guid             Id      = new Guid(this.hfId.Value);
            int Status = -1;
            //Grading recived Status.
            GradingResultStatus GradingRecivedStatus;

            try
            {
                GradingRecivedStatus = (GradingResultStatus)int.Parse(this.cboGradingRecivedStatus.SelectedValue.ToString());
            }
            catch
            {
                this.lblMsg.Text = "Grading Recived status is empty.";
                return;
            }
            try
            {
                Status = int.Parse(this.cboAcceptanceStatus.SelectedValue);
            }
            catch
            {
                this.lblMsg.Text = "Please Select Status.";
                return;
            }
            if (Status == -1)
            {
                this.lblMsg.Text = "Please Select Status.";
                return;
            }
            string preQueNo = "";

            isSaved = objR.ClientAcceptance(Id, Status, GradingRecivedStatus, dt, out preQueNo);
            if (isSaved == true)
            {
                //if (objR.Status == GradingResultStatus.ClientAccepted)
                //{
                if (preQueNo != "")
                {
                    this.lblMsg.Text = "Data Updated Successfully - Pre Weight Queue No. is:" + preQueNo;
                    return;
                }
                //}
                this.btnSave.Enabled = false;
                if (Session["CATranNo"] != null)
                {
                    // Response.Redirect("ListInbox.aspx");
                }
                //LoadData();
            }
            else
            {
                this.lblMsg.Text = "Unable to Updat Data.";
            }
        }
Ejemplo n.º 3
0
        public static GradingResultBLL GetApprovedGradingResultByCommdityDepositerequest(Guid Id)
        {
            string           strSql = "GetApprovedGradingResultByCommdityDepositerequest";
            GradingResultBLL obj;
            SqlDataReader    reader;
            SqlConnection    conn = new SqlConnection();

            SqlParameter[] arPar = new SqlParameter[1];
            arPar[0]       = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);
            arPar[0].Value = Id;
            try
            {
                conn   = Connection.getConnection();
                reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar);
                if (reader.HasRows)
                {
                    obj = new GradingResultBLL();
                    if (reader.Read())
                    {
                        obj.ID                    = new Guid(reader["Id"].ToString());
                        obj.GradingCode           = reader["GradingCode"].ToString();
                        obj.GradingId             = new Guid(reader["GradingId"].ToString());
                        obj.CommodityGradeId      = new Guid(reader["CommodityGradeId"].ToString());
                        obj.Status                = (GradingResultStatus)Convert.ToInt32(reader["status"]);
                        obj.Remark                = reader["status"].ToString();
                        obj.GradeRecivedTimeStamp = Convert.ToDateTime(reader["GradeRecivedTimestamp"].ToString());
                        obj.IsSupervisor          = Convert.ToBoolean(reader["isSupervisor"]);
                        obj.TrackingNo            = reader["TransactionId"].ToString();
                        try
                        {
                            obj.ClientAcceptanceTimeStamp = Convert.ToDateTime(reader["ClientAcceptanceTimeStamp"].ToString());
                        }
                        catch
                        {
                        }
                        obj.GradingResult             = (GradingResultStatus)Convert.ToInt32(reader["GradingResult"]);
                        obj.CommodityDepositRequestId = new Guid(reader["CommodityDepositRequest"].ToString());
                    }
                    conn.Close();
                    return(obj);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (conn != null && conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
        }
Ejemplo n.º 4
0
        public static Nullable <Guid> InsertGradingResult(GradingResultBLL obj, SqlTransaction tran)
        {
            string strSql = "spInsertGradingResult";

            SqlParameter[] arPar = new SqlParameter[10];
            try
            {
                arPar[0]       = new SqlParameter("@GradingId", SqlDbType.UniqueIdentifier);
                arPar[0].Value = obj.GradingId;

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

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

                arPar[3]       = new SqlParameter("@Remark", SqlDbType.Text);
                arPar[3].Value = obj.Remark;

                arPar[4]       = new SqlParameter("@GradeRecivedTimestamp", SqlDbType.DateTime);
                arPar[4].Value = obj.GradeRecivedTimeStamp;

                arPar[5]       = new SqlParameter("@isSupervisor", SqlDbType.Bit);
                arPar[5].Value = obj.IsSupervisor;

                arPar[6]       = new SqlParameter("@CreatedBy", SqlDbType.UniqueIdentifier);
                arPar[6].Value = obj.CreatedBy;

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

                arPar[8]       = new SqlParameter("@id", SqlDbType.UniqueIdentifier);
                arPar[8].Value = obj.ID;

                arPar[9]       = new SqlParameter("@ProductionYear", SqlDbType.Int);
                arPar[9].Value = obj.ProductionYear;



                Nullable <Guid> id = null;
                id = new Guid(SqlHelper.ExecuteScalar(tran, strSql, arPar).ToString());
                if (id != null)
                {
                    return(id);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Can not insert Grading Result", ex);
            }
        }
Ejemplo n.º 5
0
        public static List <GradingResultBLL> GetGradingResultSearch(String TrackingNo, string GradingCode)
        {
            string                  strSql = "spSearchGradingResult";
            SqlConnection           conn   = new SqlConnection();
            List <GradingResultBLL> list;
            SqlDataReader           reader;

            SqlParameter[] arPar = new SqlParameter[3];
            arPar[0]       = new SqlParameter("@TransactionId", SqlDbType.NVarChar, 50);
            arPar[0].Value = TrackingNo;

            arPar[1]       = new SqlParameter("@GradingCode", SqlDbType.NVarChar, 50);
            arPar[1].Value = GradingCode;

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

            try
            {
                conn   = Connection.getConnection();
                reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar);
                if (reader.HasRows)
                {
                    list = new List <GradingResultBLL>();
                    while (reader.Read())
                    {
                        GradingResultBLL obj = new GradingResultBLL();
                        obj.ID = new Guid(reader["Id"].ToString());
                        obj.CommodityGradeId      = new Guid(reader["CommodityGradeId"].ToString());
                        obj.GradeRecivedTimeStamp = Convert.ToDateTime(reader["GradeRecivedTimestamp"].ToString());
                        obj.TrackingNo            = reader["TransactionId"].ToString();
                        obj.IsSupervisor          = Convert.ToBoolean(reader["isSupervisor"]);
                        obj.Status        = (GradingResultStatus)Convert.ToInt32(reader["status"]);
                        obj.GradingResult = (GradingResultStatus)Convert.ToInt32(reader["GradingResult"]);
                        list.Add(obj);
                    }
                    return(list);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
        }
Ejemplo n.º 6
0
        private void LoadGrading(Guid GradingId)
        {
            GradingResultBLL objGrade = new GradingResultBLL();

            objGrade = objGrade.GetApprovedGradingResultByGradingId(GradingId);
            if (objGrade != null)
            {
                this.hfCommodityGradeId.Value = objGrade.ID.ToString();
                this.hfGradingId.Value        = objGrade.GradingId.ToString();
                this.lblCode.Text             = objGrade.GradingCode.ToString();
                this.lblCommodityGrade.Text   = CommodityGradeBLL.GetCommodityGradeNameById(objGrade.CommodityGradeId);
                this.lblProductionYear.Text   = objGrade.ProductionYear.ToString();
            }
        }
Ejemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Nullable <Guid> GradingResultId = null;

            try
            {
                GradingResultId = new Guid(Request.QueryString.Get("id").ToString());
                this.hfGradingResultId.Value = GradingResultId.ToString();
            }
            catch
            {
                this.lblMsg.Text = "Invalid Id!";
            }



            GradingResultBLL objGradingResult = new GradingResultBLL();

            if (GradingResultId != null)
            {
                objGradingResult = objGradingResult.GetGradingResultById((Guid)GradingResultId);
            }
            if (objGradingResult == null)
            {
                this.lblMsg.Text = "Record can not be found!";
            }
            // Get grading Code
            //this.txtGradingCode.Text =
            this.txtDateRecived.Text     = objGradingResult.GradeRecivedTimeStamp.ToShortDateString();
            this.txtTimeRecived.Text     = objGradingResult.GradeRecivedTimeStamp.ToShortTimeString();
            this.chkIsSupervisor.Checked = objGradingResult.IsSupervisor;
            this.txtRemark.Text          = objGradingResult.Remark;
            this.cboStatus.SelectedIndex = (int)objGradingResult.Status;


            // //Load Control values.
            ////Loading Commodity.
            //ECXLookUp.ECXLookup objEcxLookUp = new WarehouseApplication.ECXLookUp.ECXLookup();
            //ECXLookUp.CCommodityGrade[] objCC = objEcxLookUp.GetActiveCommodityGrades(new Guid("33673ac2-7888-42d5-9712-522941b3208c"), new Guid(ID.ToString()));
            //foreach (ECXLookUp.CCommodityGrade cc in objCC)
            //{
            //    this.cboCommodityGrade.Items.Add(new ListItem(cc.Name.ToString(),cc.UniqueIdentifier.ToString()));
            //    if (cc.UniqueIdentifier == objGradingResult.ID)
            //    {
            //        CommodityClassId = new Guid(cc.CommodityClassUniqueIdentifier);
            //        this.cboCommodityGrade.SelectedValue = objGradingResult.CommodityGradeId.ToString();
            //    }
            //}
        }
Ejemplo n.º 8
0
        public static List <GradingResultBLL> GetAccpetedResultsPendingUnloadingByTrackingNo(Guid WarehouseId, string TrackingNo)
        {
            string strSql = "spGetClientAcceptedResultsPendingUnloadingByTrackingNo";
            List <GradingResultBLL> list;
            SqlDataReader           reader;

            SqlParameter[] arPar = new SqlParameter[2];
            arPar[0]       = new SqlParameter("@WarehouseId", SqlDbType.UniqueIdentifier);
            arPar[0].Value = WarehouseId;
            arPar[1]       = new SqlParameter("@TrackingNo", SqlDbType.NVarChar, 50);
            arPar[1].Value = TrackingNo;
            SqlConnection conn = Connection.getConnection();

            try
            {
                reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar);
                if (reader.HasRows)
                {
                    list = new List <GradingResultBLL>();
                    while (reader.Read())
                    {
                        GradingResultBLL obj = new GradingResultBLL();
                        obj.ID          = new Guid(reader["Id"].ToString());
                        obj.GradingCode = reader["GradingCode"].ToString();

                        list.Add(obj);
                    }
                    reader.Close();
                    reader.Dispose();
                    return(list);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
        }
Ejemplo n.º 9
0
        public static bool UpdateGradingResult(GradingResultBLL obj, SqlTransaction tran)
        {
            int    AffectedRows = 0;
            string strSql       = "spUpdateGradingResult";

            SqlParameter[] arPar = new SqlParameter[8];
            try
            {
                arPar[0]       = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);
                arPar[0].Value = obj.ID;

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

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

                arPar[3]       = new SqlParameter("@Remark", SqlDbType.Text);
                arPar[3].Value = obj.Remark;

                arPar[4]       = new SqlParameter("@GradeRecivedTimestamp", SqlDbType.DateTime);
                arPar[4].Value = obj.GradeRecivedTimeStamp;

                arPar[5]       = new SqlParameter("@isSupervisor", SqlDbType.Bit);
                arPar[5].Value = obj.IsSupervisor;

                arPar[6]       = new SqlParameter("@LastModifiedBy", SqlDbType.UniqueIdentifier);
                arPar[6].Value = obj.LastModifiedBy;

                arPar[7]       = new SqlParameter("@ProductionYear", SqlDbType.Int);
                arPar[7].Value = obj.ProductionYear;


                AffectedRows = SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, strSql, arPar);

                return(AffectedRows == 1);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 10
0
        private void LoadPage()
        {
            //TODO Warehouse from security manager.
            Guid warehouseId = UserBLL.GetCurrentWarehouse();

            List <GradingResultBLL> list = null;
            GradingResultBLL        obj  = new GradingResultBLL();

            try
            {
                list = obj.GetAcceptedresultsPendingScaling(warehouseId);

                if (list != null || list.Count > 0)
                {
                    int flag = -1;
                    this.cboGradingCode.Items.Add(new ListItem("Please Select Code", ""));
                    this.cboGradingCode.AppendDataBoundItems = true;
                    foreach (GradingResultBLL o in list)
                    {
                        this.cboGradingCode.Items.Add(new ListItem(o.GradingCode.ToString(), o.CommodityDepositRequestId.ToString() + "/" + o.ID.ToString()));
                        if (o.GradingCode == Session["AddScalingGradingCode"].ToString().Trim())
                        {
                            flag = 0;
                            this.cboGradingCode.SelectedValue = o.CommodityDepositRequestId.ToString() + "/" + o.ID.ToString();
                        }
                    }
                    if (flag == -1)
                    {
                        this.btnAdd.Enabled = false;
                    }
                    this.cboGradingCode.AppendDataBoundItems = false;
                }
                else
                {
                    this.lblmsg.Text = "There are No records pending Scaling.";
                }
            }
            catch
            {
                this.lblmsg.Text = "An error occured,please check the data entered  and try agian.If the error persists, contact IT Support.";
            }
        }
Ejemplo n.º 11
0
        private void BindData()
        {
            GradingResultBLL objSearch = new GradingResultBLL();

            this.list = objSearch.Search(this.txtTrackingNo.Text, this.txtGradingCode.Text);
            if (list != null)
            {
                if (list.Count <= 0)
                {
                    this.lblMsg.Text = "No records Found.";
                    return;
                }
                this.gvGradingResult.DataSource = this.list;
                this.gvGradingResult.DataBind();
            }
            else
            {
                this.lblMsg.Text = "No records Found.";
                return;
            }
        }
Ejemplo n.º 12
0
        private void loadGradingInfo()
        {
            //Displaay the commodity Grade.
            GradingResultBLL objGR = new GradingResultBLL();

            objGR = objGR.GetGradingResultById(new Guid(this.hfGradingResultId.Value.ToString()));
            if (objGR != null)
            {
                CommodityGradeBLL oCG = CommodityGradeBLL.GetCommodityGrade(objGR.CommodityGradeId);
                ViewState["CommId"] = oCG.CommodityId.ToString();
                this.lblCG.Text     = oCG.GradeName;
                if (oCG.CommodityId == (Guid)Utility.GetCommodityId("Coffee"))
                {
                    this.lblUnit.Text  = "(KG)";
                    this.lblUnit1.Text = "(KG)";
                }
                else
                {
                    this.lblUnit.Text  = "(Qtls)";
                    this.lblUnit1.Text = "(Qtls)";
                }
            }
        }
Ejemplo n.º 13
0
 private void GradingResultReport_ReportStart(object sender, EventArgs e)
 {
     if (HttpContext.Current.Session["rptGradingResultId"] == null)
     {
         throw new Exception("Session expired");
     }
     else
     {
         Guid Id = Guid.Empty;
         Id = new Guid(HttpContext.Current.Session["rptGradingResultId"].ToString());
         GradingResultBLL obj = new GradingResultBLL();
         obj = obj.GetGradingResultById(Id);
         if (obj == null)
         {
             throw new Exception("Object Null");
         }
         else
         {
             txtTrackingNo.Text = obj.TrackingNo;
             txtResultDate.Text = obj.GradeRecivedTimeStamp.ToString("dd MMM-yyyy");
             txtCode.Text       = obj.GradingCode.ToString();
             if (obj.Status != GradingResultStatus.GeneralRequiementfail && obj.Status != GradingResultStatus.MoistureFailed)
             {
                 txtGradeReceived.Text = CommodityGradeBLL.GetCommodityGradeNameById(obj.CommodityGradeId);
             }
             else if (obj.Status == GradingResultStatus.MoistureFailed)
             {
                 txtGradeReceived.Text = "Moisture Failed";
             }
             else if (obj.Status == GradingResultStatus.GeneralRequiementfail)
             {
                 txtGradeReceived.Text = "General Requiement Fail";
             }
         }
     }
 }
Ejemplo n.º 14
0
        private void LoadDataAfterChange()
        {
            Guid Id;

            try
            {
                Id = new Guid(this.cboGradingCode.SelectedValue.ToString());
            }
            catch
            {
                this.lblMsg.Text = "Please select Grading code";
                return;
            }
            // get previous Grading.
            GradingResultBLL obj = new GradingResultBLL();

            obj = obj.GetClientRejectedGradingResultByGradingId(Id);
            if (obj != null)
            {
                this.hfGradingResultId.Value       = obj.ID.ToString();
                this.hfPreviousGradingResult.Value = obj.CommodityGradeId.ToString();
                this.lblPreviousGrade.Text         = CommodityGradeBLL.GetCommodityGradeNameById(obj.CommodityGradeId);
            }
        }
Ejemplo n.º 15
0
        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;
            }
        }
Ejemplo n.º 16
0
        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()));
                    }
                }
            }
        }
Ejemplo n.º 17
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            this.lblMsg.Text = "";
            if (this.cboCommodityGrade.SelectedValue != "")
            {
                if (this.chkRecivedGrade.Checked == false)
                {
                    this.lblMsg.Text      = "Grade Received is Not Checked.";
                    this.lblMsg.ForeColor = System.Drawing.Color.Red;
                    this.cboCommodityGrade.SelectedIndex = -1;
                    this.cboCommodityClass.SelectedIndex = -1;
                    loadData();
                    this.cboCommodityGrade.SelectedIndex = -1;
                    this.cboCommodityGrade_CascadingDropDown.SelectedValue = "";
                    return;
                }
            }

            Nullable <float>    totalValue = null;
            GradingResultStatus GenralReqiurmentStatus;

            GenralReqiurmentStatus = GradingResultStatus.Undertermined;
            List <GradingResultDetailBLL> list = new List <GradingResultDetailBLL>();

            #region Checking GradingFactors
            foreach (GridViewRow row in this.gvGradingFactors.Rows)
            {
                GradingResultDetailBLL objResult = new GradingResultDetailBLL();
                Guid   GradingFactorId;
                string possibleValue;
                string dataType;
                string value;
                string FailPoint = string.Empty;
                int    isMax     = -1;
                // get the Id and the value.
                Label lblId = new Label();

                try
                {
                    lblId           = row.FindControl("lblId") as Label;
                    GradingFactorId = new Guid(lblId.Text);
                }
                catch (InvalidCastException)
                {
                    this.lblMsg.Text = "An error has occured please try again.If the error persits contact the administrator.";
                    return;
                }

                //Get Possible Values
                try
                {
                    Label lblPossibleTypes = new Label();
                    lblPossibleTypes = (Label)row.FindControl("lblPossibleTypes");
                    possibleValue    = lblPossibleTypes.Text;
                }
                catch
                {
                    this.lblMsg.Text = "An error has occured please try again.If the error persits contact the administrator.";
                    return;
                }
                // get DataType
                try
                {
                    Label lblDataType = new Label();
                    lblDataType = (Label)row.FindControl("lblDataType");
                    dataType    = lblDataType.Text;
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                // get Value.
                try
                {
                    TextBox txtGradingFactorValue = new TextBox();
                    txtGradingFactorValue = (TextBox)row.FindControl("txtGradingFactorValue");
                    value = txtGradingFactorValue.Text;
                    if (value == "" || value == String.Empty)
                    {
                        row.FindControl("lblEmpty").Visible = true;
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("An error has occured please try again.If the error persits contact the administrator.", ex);
                }
                // if it is a Genral req.

                try
                {
                    Label lblFailPoint = new Label();
                    lblFailPoint = (Label)row.FindControl("lblFailPoint");
                    FailPoint    = lblFailPoint.Text;
                }
                catch
                {
                }

                try
                {
                    Label lblisMax = new Label();
                    lblisMax = (Label)row.FindControl("lblisMax");
                    if (string.IsNullOrEmpty(lblisMax.Text) != true)
                    {
                        try
                        {
                            isMax = GradingFactorBLL.ParseTextGradingResultStatus(lblisMax.Text);
                        }
                        catch
                        {
                            this.lblMsg.Text = "Invalid Grading Result Comparision.Please try again.";
                            return;
                        }
                    }
                }
                catch
                {
                }
                //IsInTotalValue
                bool IsInTotalValue = false;
                try
                {
                    Label lblisTotalValue = new Label();
                    lblisTotalValue = (Label)row.FindControl("lblisTotalValue");
                    if (string.IsNullOrEmpty(lblisTotalValue.Text) != true)
                    {
                        try
                        {
                            if (lblisTotalValue.Text == "True")
                            {
                                IsInTotalValue = true;
                            }
                        }
                        catch
                        {
                            IsInTotalValue = false;
                        }
                    }
                }
                catch
                {
                }
                if (IsInTotalValue == true)
                {
                    if (totalValue == null)
                    {
                        totalValue = 0;
                    }
                    totalValue += float.Parse(value);
                }



                //Check Data Type.
                if (value == "")
                {
                    Label lblmessage;
                    lblmessage = row.FindControl("lblEmpty") as Label;
                    if (lblmessage != null)
                    {
                        lblmessage.Text      = "*";
                        lblmessage.Visible   = true;
                        lblmessage.ForeColor = System.Drawing.Color.Red;
                    }
                    return;
                }
                else
                {
                    if (DataValidationBLL.isDataValidForDataType(value, dataType) == false)
                    {
                        Label lblmessage;
                        lblmessage = row.FindControl("lblEmpty") as Label;
                        if (lblmessage != null)
                        {
                            lblmessage.Text      = "Error in Data Type";
                            lblmessage.Visible   = true;
                            lblmessage.ForeColor = System.Drawing.Color.Red;
                        }
                        return;
                    }
                }

                // check in possible Values
                if (DataValidationBLL.isExists(value, possibleValue) == false)
                {
                    Label lblmessage;
                    lblmessage = row.FindControl("lblEmpty") as Label;
                    if (lblmessage != null)
                    {
                        lblmessage.Text      = "Data Should Be one of the following: " + possibleValue;
                        lblmessage.Visible   = true;
                        lblmessage.ForeColor = System.Drawing.Color.Red;
                    }
                    return;
                }

                objResult.GradingFactorId = GradingFactorId;
                objResult.RecivedValue    = value;
                objResult.Status          = GradingResultDetailStatus.Active;

                list.Add(objResult);
                Label lblmessage1;
                lblmessage1 = row.FindControl("lblEmpty") as Label;
                if (lblmessage1 != null)
                {
                    lblmessage1.Text    = "";
                    lblmessage1.Visible = false;
                }

                // Check if is a General requirment.
                GradingFactorBLL objGenralReqiurment = new GradingFactorBLL();
                if (((GradingResultStatus)int.Parse(this.cboStatus.SelectedValue)) == GradingResultStatus.New || ((GradingResultStatus)int.Parse(this.cboStatus.SelectedValue)) == GradingResultStatus.Approved)
                {
                    GenralReqiurmentStatus = objGenralReqiurment.GetGradingResultStatus(value, (FailPointComparsion)(isMax), FailPoint, dataType);
                }
                else
                {
                    GenralReqiurmentStatus = (GradingResultStatus)int.Parse(this.cboStatus.SelectedValue);
                }
            }

            #endregion

            // Check if is a General requirment.

            if (((GradingResultStatus)int.Parse(this.cboStatus.SelectedValue)) == GradingResultStatus.New || ((GradingResultStatus)int.Parse(this.cboStatus.SelectedValue)) == GradingResultStatus.Approved)
            {
                GenralReqiurmentStatus = GradingResultStatus.Approved;
            }
            else
            {
                GenralReqiurmentStatus = (GradingResultStatus)int.Parse(this.cboStatus.SelectedValue);
            }



            //Get Commodity Grade

            Guid CommodityGradeId = Guid.Empty;
            if (this.chkRecivedGrade.Checked == true)
            {
                try
                {
                    CommodityGradeId = new Guid(this.cboCommodityGrade.SelectedValue.ToString());
                }
                catch
                {
                    this.lblMsg.Text = "Please Select Commodity Grade.";
                    return;
                }
            }

            //#region Checking Total Value
            ////Check Grading is OK
            //if (this.chkRecivedGrade.Checked == true)
            //{
            //    bool ValidGrade = false;
            //    CommodityGradeFactorValueBLL objGradeFactorValueBLL = new CommodityGradeFactorValueBLL();
            //    objGradeFactorValueBLL = objGradeFactorValueBLL.GetActiveValueByCommodoityGradeId(CommodityGradeId);
            //    GradingResultDetailBLL objGradingResultDetail = new GradingResultDetailBLL();
            //    if (totalValue != null)
            //    {
            //        string err = "";
            //        ValidGrade = objGradingResultDetail.PreInsertHasValidGradingResult((float)totalValue, CommodityGradeId, out err);
            //        if (ValidGrade == false)
            //        {
            //            this.lblMsg.Text = err + " Total Value : " + totalValue.ToString();
            //            this.lblMsg.ForeColor = System.Drawing.Color.Red;
            //            return;
            //        }
            //    }
            //}
            //#endregion

            Nullable <Guid> Id = null;

            GradingResultBLL obj = new GradingResultBLL();
            try
            {
                obj.GradingId = new Guid(this.cboGradingCode.SelectedValue.ToString());
            }
            catch
            {
                this.lblMsg.Text = "Please select Grading Code";
                return;
            }
            obj.CommodityGradeId = CommodityGradeId;
            obj.IsSupervisor     = this.isSupervisor.Checked;
            //obj.Status = (GradingResultStatus)Convert.ToInt32(this.cboStatus.SelectedValue);
            obj.Status = GenralReqiurmentStatus;
            obj.Remark = this.txtRemark.Text;
            if (this.cboProductionYear.SelectedValue.ToString() != "")
            {
                obj.ProductionYear = int.Parse(this.cboProductionYear.SelectedValue.ToString());
            }
            try
            {
                obj.GradeRecivedTimeStamp = Convert.ToDateTime(this.txtDateRecived.Text + " " + this.txtTimeRecived.Text);
            }
            catch
            {
                this.lblMsg.Text = "Please check grade recieved date and try again";
                return;
            }


            obj.CreatedBy = UserBLL.GetCurrentUser();
            try
            {
                Id = obj.Add(list, obj.TrackingNo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            if (Id != null)
            {
                this.lblMsg.Text = "Result Added Successfully.";
                Session["GRID"]  = Id.ToString();
                string strTranNo = Session["AddGradingRecivedTranNo"].ToString();
                Session["AddGradingRecivedTranNo"] = null;
                Response.Redirect("ListInbox.aspx");
            }
            else
            {
                this.lblMsg.Text = "Data can not be added please check the form and try again.If the error persists contact the administrator.";
            }
        }
Ejemplo n.º 18
0
        private void LoadData()
        {
            string str = "";
            Guid   Id;

            if (Session["GRID"] != null)
            {
                str = Session["GRID"].ToString();
            }
            if (str == "")
            {
                this.lblMsg.Text = "Unable to load data please try again.";
                return;
            }
            try
            {
                Id = new Guid(str);
                this.hfId.Value = Id.ToString();
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to Update Data.", ex);
            }
            GradingResultBLL obj = new GradingResultBLL();

            obj = obj.GetGradingResultById(Id);

            if (obj != null)
            {
                this.cboGradingRecivedStatus.SelectedValue = ((int)obj.Status).ToString();
            }
            lblGradingReceivedDate.Text = obj.GradeRecivedTimeStamp.ToShortDateString();
            cmpSampGen.ValueToCompare   = obj.GradeRecivedTimeStamp.ToShortDateString();
            if (obj.GradingCode != null)
            {
                this.lblGradeCode.Text = obj.GradingCode;
            }
            this.lblClient.Text = "";
            string cg = "";
            CommodityDepositeRequestBLL obCD = new CommodityDepositeRequestBLL();

            obCD = obCD.GetCommodityDepositeDetailById(obj.CommodityDepositRequestId);
            ClientBLL objClient = new ClientBLL();

            objClient = ClientBLL.GetClinet(obCD.ClientId);
            if (objClient != null)
            {
                this.lblClient.Text = objClient.ClientName;
            }
            else
            {
                this.lblMsg.Text = "Unable to load client Data.";
            }

            cg = CommodityGradeBLL.GetCommodityGradeNameById(obj.CommodityGradeId);
            this.lblCommodityGrade.Text = cg;
            if (((int)obj.Status == 3 || (int)obj.Status == 4) && obj.ClientAcceptanceTimeStamp != null)
            {
                this.cboAcceptanceStatus.SelectedValue = ((int)obj.Status).ToString();

                DateTime dtCA = DateTime.Now;
                if (obj.ClientAcceptanceTimeStamp == null)
                {
                    this.cboAcceptanceStatus.SelectedIndex = -1;
                }

                dtCA = (DateTime)obj.ClientAcceptanceTimeStamp;
                this.txtDateOfAcceptance.Text = dtCA.Date.ToShortDateString();
                this.txtTimeodAcceptance.Text = dtCA.ToLongTimeString();
                this.cboGradingRecivedStatus.SelectedValue = ((int)obj.GradingResult).ToString();
            }
        }
Ejemplo n.º 19
0
        public void LoadData()
        {
            string str = "";

            try
            {
                ViewState["vsTrackingNo"] = Request.QueryString["TrackingNo"].ToString();
            }
            catch
            {
            }
            if (Session["GRID"] != null)
            {
                str             = Session["GRID"].ToString();
                Session["GRID"] = null;
            }
            if (str == "")
            {
                this.lblMsg.Text = "Unable to Load data try again.";
                return;
            }

            Guid Id;

            try
            {
                Id = new Guid(str);
                ViewState["vsGradingResultId"] = Id;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            if (Id != null)
            {
                GradingResultBLL obj = new GradingResultBLL();
                obj = obj.GetGradingResultById(Id);
                try
                {
                    this.hfId.Value = obj.ID.ToString();
                }
                catch (InvalidCastException)
                {
                    this.hfId.Value        = "";
                    this.btnUpdate.Enabled = false;
                    this.lblMsg.Text       = "An error occured ";
                }
                catch (NullReferenceException)
                {
                    this.hfId.Value        = "";
                    this.btnUpdate.Enabled = false;
                    this.lblMsg.Text       = "An error occured ";
                }

                if (obj.GradingCode != null)
                {
                    this.txtGradingCode.Text = obj.GradingCode.ToString();
                }
                //Commodity Grade Populating
                LoadCommodityControls(obj.CommodityGradeId);


                //this.cboCommodityGrade.SelectedValue = obj.CommodityGradeId.ToString();
                try
                {
                    this.txtDateRecived.Text = obj.GradeRecivedTimeStamp.ToShortDateString();
                }
                catch (NullReferenceException)
                {
                    this.txtDateRecived.Text = "";
                }
                catch (InvalidCastException)
                {
                    this.txtDateRecived.Text = "";
                }
                this.txtTimeRecived.Text = obj.GradeRecivedTimeStamp.ToLongTimeString();
                try
                {
                    this.isSupervisor.Checked = obj.IsSupervisor;
                }
                catch (NullReferenceException)
                {
                    this.isSupervisor.Checked = false;
                }
                try
                {
                    this.cboStatus.SelectedValue = obj.Status.ToString();
                    if (this.cboStatus.SelectedValue == GradingResultStatus.ClientAccepted.ToString())
                    {
                        this.btnUpdate.Enabled        = false;
                        this.gvGradingFactors.Enabled = false;
                    }
                }
                catch (NullReferenceException)
                {
                    this.cboStatus.SelectedValue = "";
                }

                this.txtRemark.Text = obj.Remark.ToString();
                int currYear;
                currYear = int.Parse(ConfigurationSettings.AppSettings["CurrentEthiopianYear"]);
                this.cboProductionYear.Items.Add(new ListItem("Please Select Production Year.", ""));
                this.cboProductionYear.AppendDataBoundItems = true;
                bool isEthYearFound = false;
                int  procYear       = obj.ProductionYear;

                for (int i = currYear - 2; i <= currYear; i++)
                {
                    this.cboProductionYear.Items.Add(new ListItem(i.ToString(), i.ToString()));
                    if (isEthYearFound == false)
                    {
                        if (i == procYear)
                        {
                            this.cboProductionYear.SelectedValue = i.ToString();
                            isEthYearFound = true;
                        }
                    }
                }
                ViewState["vsProdYear"] = null;
                if (procYear != -1)
                {
                    this.cboProductionYear.Items.Add(new ListItem(procYear.ToString(), procYear.ToString()));
                    this.cboProductionYear.SelectedValue = procYear.ToString();
                }
                ViewState["vsProdYear"] = procYear;
                //Load dataGrid
                GridDataBind();
            }
        }
Ejemplo n.º 20
0
        private void LoadTruckInformation()
        {
            if (this.cboGradingCode.SelectedValue.ToString() == "")
            {
                this.lblmsg.Text = "Please select Tracking No.";
                this.cboGradingCode.SelectedIndex = -1;
                return;
            }
            string str = this.cboGradingCode.SelectedValue.ToString();

            string[] temp = new string[2];
            temp = str.Split('/');
            if (temp[0] == "" || temp[0] == null)
            {
                this.lblmsg.Text = "Please try agian.";
                this.cboGradingCode.SelectedIndex = -1;
                return;
            }
            Guid ReceivigRequestId;

            try
            {
                ReceivigRequestId = new Guid(temp[0].ToString());
            }
            catch
            {
                this.lblmsg.Text = "Please try agian.";
                this.cboGradingCode.SelectedIndex = -1;
                return;
            }
            try
            {
                this.hfGradingResultId.Value = temp[1].ToString();
            }
            catch
            {
                this.lblmsg.Text = "An error occured, please try agian.";
                this.cboGradingCode.SelectedIndex = -1;
                return;
            }
            this.hfReceivigRequestId.Value = ReceivigRequestId.ToString();
            List <DriverInformationBLL> list     = new List <DriverInformationBLL>();
            DriverInformationBLL        objTruck = new DriverInformationBLL();

            list = objTruck.GetActiveDriverInformationByReceivigRequestId(ReceivigRequestId);
            this.gvDriverInformation.DataSource = list;
            this.gvDriverInformation.DataBind();
            //Get detail gradingResult
            GradingResultBLL objGradingResult = new GradingResultBLL();

            objGradingResult = objGradingResult.GetGradingResultById(new Guid(temp[1].ToString()));
            UnloadingBLL objUnloading = new UnloadingBLL();

            objUnloading = objUnloading.GetApprovedUnloadingByGradingResultId(objGradingResult.ID);
            if (objUnloading != null)
            {
                this.lblDateUnloaded.Text      = objUnloading.DateDeposited.ToShortDateString();
                this.cmpSampGen.ValueToCompare = objUnloading.DateDeposited.ToShortDateString();
            }
            this.hfTrackingNo.Value = objGradingResult.TrackingNo;
        }
Ejemplo n.º 21
0
        private void LoadPage()
        {
            List <StackUnloadedBLL> list = new List <StackUnloadedBLL>();

            ViewState["StackUnloaded"] = list;
            // load controls.'
            GradingResultBLL obj = new GradingResultBLL();

            //TODO : change by warhouse id.
            Guid warehouseId = UserBLL.GetCurrentWarehouse();

            //Loading Grading Results pending Unloading.
            this.cboGradingCode.Items.Clear();
            List <GradingResultBLL> grdinglist = new List <GradingResultBLL>();

            try
            {
                grdinglist = obj.GetAcceptedresultsPendingUnloading(warehouseId);
            }
            catch (Exception ex)
            {
                this.lblmsg.Text = ex.Message;
            }
            if (grdinglist != null)
            {
                if (grdinglist.Count > 0)
                {
                    this.cboGradingCode.Items.Add(new ListItem("Please Select Code", ""));
                    this.cboGradingCode.AppendDataBoundItems = true;
                    this.cboGradingCode.DataSource           = grdinglist;
                    this.cboGradingCode.DataTextField        = "GradingCode";
                    this.cboGradingCode.DataValueField       = "Id";
                    this.cboGradingCode.DataBind();
                    this.cboGradingCode.AppendDataBoundItems = false;
                }
                else
                {
                    this.lblmsg.Text = "There are no pending results awaiting Unloading.";
                }
            }
            else
            {
                this.lblmsg.Text = "There are no pending results awaiting Unloading.";
            }



            //TODO Remove Comment

            //  Loading shedby warehouse.
            cboShed.Items.Clear();
            ShedBLL        shed     = new ShedBLL();
            List <ShedBLL> shedlist = new List <ShedBLL>();

            shedlist = shed.GetActiveShedByWarehouseId(warehouseId);
            cboShed.Items.Add(new ListItem("Select Shed", ""));
            cboShed.AppendDataBoundItems = true;
            if (shedlist.Count > 0)
            {
                foreach (ShedBLL s in shedlist)
                {
                    cboShed.Items.Add(new ListItem(s.ShedNumber, s.Id.ToString()));
                }
                cboShed.AppendDataBoundItems = false;
                this.btnSave.Enabled         = true;
            }
            else
            {
                this.btnSave.Enabled = false;
            }
        }