Ejemplo n.º 1
0
        private void FillFactoryGrid()
        {
            const string METHOD_NAME = "FillFactoryGrid";

            try {
                int cropYear = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear));
                grdFactory.SelectedIndex = -1;

                // Use currently selected crop year to fill the over plant factory grid
                List <ListOverPlantFactoryItem> overPlantList = BeetDataOverPlant.OverPlantFactoryByYear(cropYear);

                grdFactory.DataSource = overPlantList;
                grdFactory.DataBind();
            }
            catch (Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                throw (wex);
            }
        }
Ejemplo n.º 2
0
        protected void btnPost_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnPost_Click";

            try {
                int cropYear = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear));

                GridViewRow grdRow        = grdFactory.SelectedRow;
                int         factoryNumber = Convert.ToInt32(grdRow.Cells[ftyColFactoryNumber].Text);
                string      userName      = Common.AppHelper.GetIdentityName();

                BeetDataOverPlant.OverPlantPost(cropYear, factoryNumber, userName);

                ClearFactoryEdit();
                FillFactoryGrid();
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
Ejemplo n.º 3
0
        protected void ddlFactoryOverPlant_SelectedIndexChanged(object sender, EventArgs e)
        {
            const string METHOD_NAME = "ddlFactoryOverPlant_SelectedIndexChanged";

            try {
                //-----------------------------------------------------------------------------------------
                // Changing the Over Plant factory can change the Over Plant percentage, which cna impact
                // the Possible Over Plant Shares, and if Acceptance is 'Yes' then the Over Plant Shares are
                // also changed.
                //-----------------------------------------------------------------------------------------

                if (ddlFactoryOverPlant.SelectedIndex != 0)
                {
                    int cropYear      = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear));
                    int factoryNumber = Convert.ToInt32(Common.UILib.GetDropDownValue(ddlFactoryOverPlant));

                    List <ListOverPlantFactoryItem> opfItem = BeetDataOverPlant.OverPlantFactoryByNumber(cropYear, factoryNumber);

                    if (opfItem.Count > 0)
                    {
                        txtOverPlantPercentage.Text = opfItem[0].Percentage;
                        if (opfItem[0].IsOverPlantAllowed == "Yes")
                        {
                            OverPlantAllowed();
                        }
                        else
                        {
                            OverPlantNotAllowed();
                            Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Either over plant is not allowed or not set up for this member's factory.");
                        }
                        CalculateOverPlant();
                        CheckOverPlantShares();
                    }
                }
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
Ejemplo n.º 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnSave_Click";

            try {
                string shid     = txtSHID.Text;
                int    cropYear = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear));

                string tmp = "";
                tmp = txtOverPlantShares.Text;
                if (tmp.Length == 0)
                {
                    tmp = "0";
                }
                if (!Common.CodeLib.IsNumeric(tmp))
                {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a number for 'Over Plant Shares'.");
                    throw (warn);
                }
                int overPlantUsed = Convert.ToInt32(tmp.Replace(",", ""));
                tmp = txtOverPlantPercentage.Text;
                if (tmp.Length == 0)
                {
                    tmp = "0";
                }
                if (!Common.CodeLib.IsNumeric(tmp))
                {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a number for 'Over Plant Percentage'.");
                    throw (warn);
                }
                decimal opMemberPct = Convert.ToDecimal(tmp.Replace(",", ""));

                int    overPlantPossible = Convert.ToInt32(txtPossibleOverPlantShares.Text.Replace(",", ""));
                string overPlantAccept   = ddlOverPlantAcceptance.SelectedItem.ToString().Substring(0, 1);
                bool   isFormReceived    = chkOverPlantFormReceived.Checked;

                CalculateOverPlant();
                CheckOverPlantShares();

                bool isPossibleDifferent = (overPlantPossible.ToString() != txtPossibleOverPlantShares.Text);
                bool isSharesDifferent   = (overPlantUsed.ToString() != txtOverPlantShares.Text);

                // We should not have a difference in possible or shares used after calling
                // CalculateOverPlant, but if we do, throw a warning to the user.
                if (isPossibleDifferent && isSharesDifferent)
                {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("The number of Possible Over Plant Shares and the number of Over Plant Shares were recalculated.  If you approve, press Save again.");
                    throw (warn);
                }
                if (isPossibleDifferent)
                {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("The number of Possible Over Plant Shares were recalculated.  If you approve, press Save again.");
                    throw (warn);
                }
                if (isSharesDifferent)
                {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("The number of Over Plant Shares were recalculated.  If you approve, press Save again.");
                    throw (warn);
                }

                if (overPlantUsed > overPlantPossible)
                {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please make sure that the number of Over Plant Shares is not greater than the number of Possible Over Plant Shares.");
                    throw (warn);
                }

                switch (overPlantAccept)
                {
                case "U":
                    if (overPlantUsed != 0)
                    {
                        Common.CWarning warn = new WSCIEMP.Common.CWarning("When Over Plant Acceptance is 'Undecided', the Over Plant Shares must equal 0.");
                        throw (warn);
                    }
                    break;

                case "N":
                    if (overPlantUsed != 0)
                    {
                        Common.CWarning warn = new WSCIEMP.Common.CWarning("When Over Plant Acceptance is 'No', the Over Plant Shares must equal 0.");
                        throw (warn);
                    }
                    break;

                case "Y":
                    if (overPlantUsed != overPlantPossible)
                    {
                        Common.CWarning warn = new WSCIEMP.Common.CWarning("When Over Plant Acceptance is 'Yes', the Over Plant Shares must equal the 'Possible Over Plant Shares'.");
                        throw (warn);
                    }
                    break;

                case "P":
                    break;
                }

                int opFactoryNumber = Convert.ToInt32(Common.UILib.GetDropDownValue(ddlFactoryOverPlant));
                if (opFactoryNumber == 0)
                {
                    Common.CWarning warn = new WSCIEMP.Common.CWarning("Please select an Over Plant Factory.");
                    throw (warn);
                }

                string userName      = Common.AppHelper.GetIdentityName();
                bool   isOverridePct = (btnCustomPct.Text == OVERRIDE_ON);

                BeetDataOverPlant.OverPlantSave(Convert.ToInt32(MyOverPlantID), Convert.ToInt32(MyMemberID), cropYear, overPlantUsed, overPlantAccept,
                                                isFormReceived, isOverridePct, opMemberPct, opFactoryNumber, userName);
                FindAddress(shid);
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
Ejemplo n.º 5
0
        private void FindMemberOverPlant(int memberID)
        {
            const string METHOD_NAME = "FindMemberOverPlant";

            try {
                int    cropYear    = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear));
                string userName    = Common.AppHelper.GetIdentityName();
                bool   isPriorYear = false;

                if (ddlCropYear.SelectedIndex > 1)
                {
                    isPriorYear = true;
                }

                List <ListOverPlantMemberItem> oplList = BeetDataOverPlant.OverPlantMemberGetInfo(memberID, cropYear, userName);

                if (oplList.Count > 0)
                {
                    ListOverPlantMemberItem oplMember = oplList[0];

                    MyOverPlantID       = oplMember.OverPlantID;
                    txtFactoryHome.Text = oplMember.HomeFactoryName;
                    Common.UILib.SelectDropDownValue(ddlFactoryOverPlant, oplMember.OverPlantFactoryNumber);
                    Common.UILib.SelectDropDown(ddlOverPlantAcceptance, oplMember.OverPlantAccept);
                    txtPatronSharesOwned.Text        = oplMember.PatronSharesOwned;
                    txtOverPlantShares.Text          = oplMember.OverPlantUsed;
                    txtOverPlantPercentage.Text      = oplMember.OverPlantPct;
                    chkOverPlantFormReceived.Checked = oplMember.IsFormReceived;
                    txtPossibleOverPlantShares.Text  = oplMember.OverPlantPossible;

                    if (oplMember.IsOverridePct)
                    {
                        btnCustomPct.Text = OVERRIDE_ON;
                        txtOverPlantPercentage.ReadOnly = false;
                        txtOverPlantPercentage.CssClass = "ButtonText";
                    }
                    else
                    {
                        btnCustomPct.Text = OVERRIDE_OFF;
                        txtOverPlantPercentage.ReadOnly = true;
                        txtOverPlantPercentage.CssClass = "highlightRO";
                    }

                    //--------------------------------------------
                    // Is Over Plant allowed?
                    //--------------------------------------------
                    if (!oplMember.IsOverPlantAllowed)
                    {
                        OverPlantNotAllowed();
                        Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Either over plant is not allowed or not set up for this member's factory.");
                    }
                    else
                    {
                        if (!isPriorYear)
                        {
                            OverPlantAllowed();
                        }
                        else
                        {
                            OverPlantNotAllowed();
                            Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Save is not allowed in a prior year.");
                        }
                    }
                }
                else
                {
                    OverPlantNotAllowed();
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Either over plant is not allowed or not set up for this member's factory.");
                }
            }
            catch (Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                throw (wex);
            }
        }
Ejemplo n.º 6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnSave_Click";

            try {
                int         cropYear = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear));
                GridViewRow grdRow   = grdFactory.SelectedRow;

                if (grdRow == null)
                {
                    WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please select a Over Plant Factory Detail record before pressing Save.");
                    throw warn;
                }

                int    factoryNumber = Convert.ToInt32(grdRow.Cells[ftyColFactoryNumber].Text);
                string userName      = Common.AppHelper.GetIdentityName();

                bool    isOverPlantAllowed = chkIsOverPlantAllowed.Checked;
                decimal overPlantPct       = Convert.ToDecimal((txtPercentage.Text.Length > 0? txtPercentage.Text: "0"));
                bool    isPoolingAllowed   = chkIsPoolingAllowed.Checked;
                int     poolMemberSHID     = Convert.ToInt32(txtPoolSHID.Text);
                string  poolCutoffDate     = txtCutoffDate.Text;

                // Business Rules, oh boy!
                if (isOverPlantAllowed)
                {
                    // If over plant is allowed, you need to have a percentage.
                    if (overPlantPct == 0)
                    {
                        WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("You need to enter a Percentage when you check 'Over Plant Allowed'.");
                        throw warn;
                    }
                }
                else
                {
                    // if over plant not allowed, you cannot have a percentage or cutoff date or allow pooling.
                    if (overPlantPct != 0)
                    {
                        WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("You cannot enter a Percentage unless you check 'Over Plant Allowed'.");
                        throw warn;
                    }
                    if (poolCutoffDate.Length > 0)
                    {
                        WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("You cannot enter a Cutoff Date unless you check 'Over Plant Allowed'.");
                        throw warn;
                    }
                    if (isPoolingAllowed)
                    {
                        WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("You cannot check 'Allow Pooling' unless you check 'Over Plant Allowed'.");
                        throw warn;
                    }
                }

                if (poolCutoffDate.Length > 0)
                {
                    if (!Common.CodeLib.IsDate(poolCutoffDate))
                    {
                        WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a valid Cutoff Date (mm/dd/yyyy).");
                        throw warn;
                    }
                }

                BeetDataOverPlant.OverPlantFactorySave(cropYear, factoryNumber, isOverPlantAllowed, overPlantPct, isPoolingAllowed, poolMemberSHID, poolCutoffDate, userName);

                ClearFactoryEdit();
                FillFactoryGrid();
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }