Exemple #1
0
        private void GridDataBind()
        {
            Guid Id = new Guid(this.hfId.Value.ToString());
            GradingResultDetailBLL        objGRD = new GradingResultDetailBLL();
            List <GradingResultDetailBLL> list   = new List <GradingResultDetailBLL>();

            list = objGRD.GetGradingResultDetailByGradingResultId(Id);

            this.gvGradingFactors.DataSource = list;
            this.gvGradingFactors.DataBind();
        }
Exemple #2
0
        public static List <GradingResultDetailBLL> GetGradingResultWithTotalValue(Guid Id)
        {
            string        strSql = "spGetTotalValue";
            SqlConnection conn   = new SqlConnection();
            List <GradingResultDetailBLL> list;

            try
            {
                SqlParameter[] arPar = new SqlParameter[1];
                arPar[0]       = new SqlParameter("@GradingResultId", SqlDbType.UniqueIdentifier);
                arPar[0].Value = Id;
                SqlDataReader reader;
                conn   = Connection.getConnection();
                reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar);
                if (reader != null)
                {
                    if (reader.HasRows)
                    {
                        list = new List <GradingResultDetailBLL>();
                        while (reader.Read())
                        {
                            GradingResultDetailBLL obj = new GradingResultDetailBLL();
                            obj.Id = new Guid(reader["Id"].ToString());
                            obj.GradingFactorId   = new Guid(reader["GradingFactorId"].ToString());
                            obj.RecivedValue      = reader["ReceivedValue"].ToString();
                            obj.Status            = (GradingResultDetailStatus)reader["Status"];
                            obj.GradingFactorName = reader["GradingFactorName"].ToString();
                            obj.DataType          = reader["ValueType"].ToString();
                            obj.PossibleValues    = reader["PossibleValues"].ToString();

                            list.Add(obj);
                        }
                        return(list);
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(null);
        }
Exemple #3
0
 private void rptGrading_ReportStart(object sender, EventArgs e)
 {
     try
     {
         GradingResultDetailBLL objGradingResultDetail = new GradingResultDetailBLL();
         reader = objGradingResultDetail.GetGradingResultDetailByGradingIdDataReader(this.GradingIdSubReport, conn);
     }
     catch (Exception ex)
     {
         if (this.conn.State == ConnectionState.Open)
         {
             conn.Close();
         }
         throw ex;
     }
 }
Exemple #4
0
        public static bool InsertGradingResultDetail(GradingResultDetailBLL obj, SqlTransaction trans)
        {
            if (obj != null)
            {
                int            AffectedRows = 0;
                string         strSql       = "spInsertGradingResultDetail";
                SqlConnection  conn         = Connection.getConnection();
                SqlParameter[] arPar        = new SqlParameter[6];

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

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

                arPar[2]       = new SqlParameter("@ReceivedValue", SqlDbType.NVarChar, 50);
                arPar[2].Value = obj.RecivedValue;

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

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

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

                AffectedRows = SqlHelper.ExecuteNonQuery(trans, strSql, arPar);
                if (AffectedRows == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Exemple #5
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.";
            }
        }
Exemple #6
0
        protected void gvGradingFactors_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                Guid Id = new Guid(this.hfId.Value.ToString());
            }
            catch
            {
                this.lblmsg2.Text = "Unable to Update data,please check the data enterd and try again.If the error persists, contact IT Support";
            }
            //check if the GR is accpted by the Client if true then - Ignore changes.

            GridViewRow row = gvGradingFactors.Rows[e.RowIndex];

            if (row != null)
            {
                Label lblmessage;
                lblmessage = row.FindControl("lblEmpty") as Label;
                if (lblmessage != null)
                {
                    lblmessage.Text      = "";
                    lblmessage.Visible   = true;
                    lblmessage.ForeColor = System.Drawing.Color.Red;
                }
                Nullable <Guid> Id    = null;
                Label           lblId = row.FindControl("lblId") as Label;
                if (lblId != null)
                {
                    try
                    {
                        Id = new Guid(lblId.Text);
                    }
                    catch
                    {
                        this.lblmsg2.Text = "An Error please try again.If the error persists conatact the administrator.";
                        return;
                    }
                }
                //get value Type
                string DataType    = String.Empty;
                Label  lblDataType = row.FindControl("lblDataType") as Label;
                if (lblDataType != null)
                {
                    DataType = lblDataType.Text;
                }

                // get Possible Values.
                string PossibleValues    = String.Empty;
                Label  lblPossibleValues = row.FindControl("lblPossibleTypes") as Label;
                if (lblPossibleValues != null)
                {
                    PossibleValues = lblPossibleValues.Text;
                }

                string  value    = String.Empty;
                TextBox txtValue = row.FindControl("txtGradingFactorValue") as TextBox;
                if (txtValue != null)
                {
                    value = txtValue.Text;
                }


                // check validations.
                //if (DataValidationBLL.isDataValidForDataType(value, DataType) == false)
                //{
                //    Label lblmessage2;
                //    lblmessage2 = row.FindControl("lblEmpty") as Label;
                //    if (lblmessage != null)
                //    {
                //        lblmessage2.Text = "ERROR in Data Type";
                //        lblmessage2.Visible = true;
                //        lblmessage2.ForeColor = System.Drawing.Color.Red;
                //    }
                //    return;
                //}
                if (DataValidationBLL.isExists(value, PossibleValues) == false)
                {
                    Label lblmessage3;
                    lblmessage3 = row.FindControl("lblEmpty") as Label;
                    if (lblmessage3 != null)
                    {
                        lblmessage3.Text      = "Data Should Be one of the following: " + PossibleValues;
                        lblmessage3.Visible   = true;
                        lblmessage3.ForeColor = System.Drawing.Color.Red;
                    }
                    return;
                }
                bool isSaved = false;
                GradingResultDetailBLL objGRD = new GradingResultDetailBLL();
                isSaved = objGRD.UpdateEach((Guid)Id, value);
                if (isSaved == true)
                {
                    this.lblmsg2.Text = "Data updated Successfully.";
                    this.gvGradingFactors.EditIndex = -1;
                    GridDataBind();
                }
                else
                {
                    this.lblmsg2.Text = "Data can not be updated.";
                    this.gvGradingFactors.EditIndex = -1;
                    GridDataBind();
                }
            }
            else
            {
                this.lblmsg2.Text = "You can not update this record.";
            }
        }
Exemple #7
0
        private bool isTotalValueCorrect()
        {
            bool  isCorrect           = false;
            bool  CalculateTotalValue = false;
            float totalValue          = 0;

            foreach (GridViewRow row in this.gvGradingFactors.Rows)
            {
                GradingResultDetailBLL objResult = new GradingResultDetailBLL();
                float value;



                try
                {
                    Label lblisTotalValue = new Label();
                    lblisTotalValue = (Label)row.FindControl("lblisTotalValue");
                    if (string.IsNullOrEmpty(lblisTotalValue.Text) != true)
                    {
                        try
                        {
                            if (lblisTotalValue.Text == "True")
                            {
                                CalculateTotalValue = true;
                                // get Value.
                                try
                                {
                                    TextBox txtGradingFactorValue = new TextBox();
                                    txtGradingFactorValue = (TextBox)row.FindControl("txtGradingFactorValue");
                                    if (txtGradingFactorValue.Text == "" || txtGradingFactorValue.Text == null)
                                    {
                                        this.lblMsg.Text = "Please eneter Value";
                                        return(false);
                                    }
                                    else
                                    {
                                        value       = float.Parse(txtGradingFactorValue.Text);
                                        totalValue += value;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    throw ex;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            if (CalculateTotalValue == true)
            {
                if (this.cboCommodityGrade.SelectedValue != "" || this.cboCommodityGrade.SelectedValue != null)
                {
                    string err = "";
                    GradingResultDetailBLL obj = new GradingResultDetailBLL();
                    return(obj.PreInsertHasValidGradingResult(totalValue, new Guid(this.cboCommodityGrade.SelectedValue.ToString()), out err));
                }
                else
                {
                    return(false);
                }
            }

            return(isCorrect);
        }
Exemple #8
0
        public static GradingResultDetailBLL GetGradingResultDetailById(Guid Id)
        {
            string        strSql = "spGetGradingResultDetailById";
            SqlDataReader reader;
            SqlConnection conn = Connection.getConnection();

            SqlParameter[] arPar = new SqlParameter[1];
            arPar[0]       = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);
            arPar[0].Value = Id;
            try
            {
                reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar);
                if (reader.HasRows)
                {
                    GradingResultDetailBLL obj = new GradingResultDetailBLL();
                    if (reader.Read())
                    {
                        obj.Id = new Guid(reader["Id"].ToString());
                        obj.GradingFactorId   = new Guid(reader["GradingFactorId"].ToString());
                        obj.RecivedValue      = reader["ReceivedValue"].ToString();
                        obj.Status            = (GradingResultDetailStatus)reader["Status"];
                        obj.GradingFactorName = reader["GradingFactorName"].ToString();
                        obj.DataType          = reader["ValueType"].ToString();
                        obj.PossibleValues    = reader["PossibleValues"].ToString();
                        if (reader["isInTotalValue"] != DBNull.Value)
                        {
                            obj.isInTotalValue = bool.Parse(reader["isInTotalValue"].ToString());
                        }
                        else
                        {
                            obj.isInTotalValue = false;
                        }

                        try
                        {
                            obj.LastModifiedBy        = new Guid(reader["LastModifiedBy"].ToString());
                            obj.LastModifiedTimestamp = Convert.ToDateTime(reader["LastModifiedTimestamp"].ToString());
                        }
                        catch
                        {
                        }
                    }
                    conn.Close();
                    return(obj);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (conn != null && conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
        }