Exemple #1
0
        protected void btnNew_Click(object sender, EventArgs e)
        {
            try {
                if (UsrCntSelector.IsChangedSHID)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "You changed the SHID without pressing the Find button.  Please press Find.");
                    return;
                }

                WSCSecurity auth = Globals.SecurityState;
                if (!UsrCntSelector.IsOwner)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Sorry, you are not authorized to update this information");
                    return;
                }

                NewContractAlertOn();

                // This process creates a temporary new field, but Does Not clear or reset
                // the sequence list for any current contract.

                int seqMax = UsrCntSelector.SequenceNumberMax;
                UsrCntSelector.ResetField();
                UsrCntSelector.SetSequenceNumber(seqMax, 0);
                ClearFieldDetail();

                //txtOtherLldContracts.Text = "";
            }
            catch (Exception ex) {
                ShowError(ex, "Unable to generate a New Field at this time.");
            }
        }
Exemple #2
0
        protected void btnAddField_Click(object sender, EventArgs e)
        {
            try {
                if (UsrCntSelector.IsChangedSHID)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "You changed the SHID without pressing the Find button.  Please press Find.");
                    return;
                }

                WSCSecurity auth = Globals.SecurityState;
                if (!UsrCntSelector.IsOwner)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Sorry, you are not authorized to update this information");
                    return;
                }

                // Add the field if it has a valid lld_id
                if (UsrCntSelector.LldID == 0)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "You must first Save this field before adding it to the Contract.");
                    return;
                }
                if (UsrCntSelector.CntLLDID > 0)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "This field is already contracted for this season.");
                    return;
                }
                if (!(UsrCntSelector.ContractID > 0))
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "You must first select a contract before adding a field to the contract.");
                    return;
                }

                // okay, add the field to the contract.
                int cntlld_cntlld_id_out = 0;

                WSCField.CntLldAddField(UsrCntSelector.ContractID, UsrCntSelector.LldID, UsrCntSelector.CropYear,
                                        auth.UserName, ref cntlld_cntlld_id_out);

                // Bounce sequence number to max value
                if (cntlld_cntlld_id_out > 0)
                {
                    int newMaxSeq = UsrCntSelector.SequenceNumberMax + 1;
                    UsrCntSelector.SetSequenceNumber(newMaxSeq, newMaxSeq);
                }

                ShowContractFieldDetail();
            }
            catch (Exception ex) {
                ShowError(ex, "Unable to Add this Field to this Contract at this time.");
            }
        }
Exemple #3
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try {
                if (UsrCntSelector.IsChangedSHID)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "You changed the SHID without pressing the Find button.  Please press Find.");
                    return;
                }

                WSCSecurity auth = Globals.SecurityState;
                if (!UsrCntSelector.IsOwner)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Sorry, you are not authorized to update this information");
                    return;
                }

                // Delete this Field \ Land Description when it has a valid LLD_ID.
                // Otherwise just blow it off and do a little reset.

                int lld_id = UsrCntSelector.LldID;
                if (lld_id > 0)
                {
                    WSCField.LegalLandDescDelete(lld_id);
                }
                else
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "You must be viewing a field already in the system in order to delete it.");
                    return;
                }

                int seq    = 0;
                int seqMax = 0;
                if (UsrCntSelector.SequenceNumber > 0)
                {
                    seq    = 1;
                    seqMax = UsrCntSelector.SequenceNumberMax - 1;
                }

                ClearFieldDetail();
                UsrCntSelector.InitControl(UsrCntSelector.SHID, UsrCntSelector.CropYear, UsrCntSelector.ContractNumber, seq);
            }
            catch (Exception ex) {
                ShowError(ex, @"Unable to Delete this Land Description \ Field at this time.");
            }
        }
Exemple #4
0
        protected void btnReset_Click(object sender, EventArgs e)
        {
            try {
                if (UsrCntSelector.IsChangedSHID)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "You changed the SHID without pressing the Find button.  Please press Find.");
                    return;
                }

                int seqMax = UsrCntSelector.SequenceNumberMax;
                UsrCntSelector.ResetField();
                UsrCntSelector.SetSequenceNumber(seqMax, 0);

                ClearFieldDetail();
                NewContractAlertOff();
            }
            catch (Exception ex) {
                ShowError(ex, "Unable to Resest the Field at this time.");
            }
        }
Exemple #5
0
        protected void btnRemoveField_Click(object sender, EventArgs e)
        {
            try {
                if (UsrCntSelector.IsChangedSHID)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "You changed the SHID without pressing the Find button.  Please press Find.");
                    return;
                }

                WSCSecurity auth = Globals.SecurityState;
                if (!UsrCntSelector.IsOwner)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Sorry, you are not authorized to update this information");
                    return;
                }

                // Remove the field from the contract if it has a valid cntlld entry.
                if (UsrCntSelector.SequenceNumber > 0)
                {
                    int cntlld_id = UsrCntSelector.CntLLDID;
                    if (cntlld_id > 0)
                    {
                        WSCField.CntLldDelete(cntlld_id);
                    }

                    UsrCntSelector.SequenceNumberMax = UsrCntSelector.SequenceNumberMax - 1;
                    UsrCntSelector.SetSequenceNumber(UsrCntSelector.SequenceNumberMax, 1);
                    ShowContractFieldDetail();
                }
                else
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "You must be viewing a field on this contract before removing a field from the contract.");
                    return;
                }
            }
            catch (Exception ex) {
                ShowError(ex, "Unable to Remove this Field to this Contract at this time.");
            }
        }
Exemple #6
0
        protected void btnSvrFindField_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnSvrFindField_Click";

            try {
                if (txtLldID.Text.Length > 0)
                {
                    int lldID = Convert.ToInt32(txtLldID.Text);
                    txtLldID.Text = "";
                    int maxFields = UsrCntSelector.SequenceNumberMax;

                    UsrCntSelector.ResetField();

                    UsrCntSelector.SetSequenceNumber(maxFields, 0);
                    ShowFieldDetail(lldID);
                }
            }
            catch (Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }
Exemple #7
0
        protected void btnSvrSave_Click(object sender, EventArgs e)
        {
            try {
                if (UsrCntSelector.IsChangedSHID)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "You changed the SHID without pressing the Find button.  Please press Find.");
                    return;
                }

                WSCSecurity auth = Globals.SecurityState;
                if (!UsrCntSelector.IsOwner)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Sorry, you are not authorized to update this information");
                    return;
                }

                if (!UsrCntSelector.IsOwner)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Sorry, you are not authorized to update this information");
                    return;
                }

                // Can only Save crop years >= 2006
                if (UsrCntSelector.CropYear < 2006)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "You cannot Save information for Crop Years before 2006.");
                    return;
                }

                // This performs an Insert or Update as needed for the current
                // Field \ Land Description.
                int    lldIDOUT = 0;
                Domain domain   = WSCField.GetDomainData();

                // STATE
                string state = Common.UILib.GetDropDownText(ddlState);
                if (state.Length == 0)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "You must select a State from the list.");
                    return;
                }

                if (!domain.StateList.Contains(state))
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "The State you selected, " + state + ", is no longer supported.  Please select a new value.");
                    return;
                }

                // County
                string county = Common.UILib.GetDropDownText(ddlCounty);
                if (county.Length == 0)
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "You must select a County from the list.");
                    return;
                }
                if (!domain.CountyList.Contains(state, county))
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "The County you selected, " + county + ", is no longer supported.  Please select a new value.");
                    return;
                }

                // FSA STATE
                string fsaState = Common.UILib.GetDropDownText(ddlFSAState);
                //if (state.Length == 0) {
                //Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "You must select a State from the list.");
                //return;
                //}

                // FSA County
                string fsaCounty = Common.UILib.GetDropDownText(ddlFSACounty);
                if (!domain.CountyList.Contains(fsaState, fsaCounty))
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "The FSA County you selected, " + fsaCounty + ", is no longer supported.  Please select a new value.");
                    return;
                }

                // TOWNSHIP
                string township = Common.UILib.GetDropDownText(ddlTownship);
                if (!domain.TownshipList.Contains(state, township))
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "The Township you selected, " + township + ", is no longer supported.  Please select a new value.");
                    return;
                }

                // RANGE
                string range = Common.UILib.GetDropDownText(ddlRange);
                if (!domain.RangeList.Contains(state, range))
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "The Range you selected, " + range + ", is no longer supported.  Please select a new value.");
                    return;
                }

                // SECTION
                string section = Common.UILib.GetDropDownText(ddlSection);
                if (!domain.SectionList.Contains(section))
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "The Section you selected, " + section + ", is no longer supported.  Please select a new value.");
                    return;
                }

                // QUADRANT
                string quadrant = Common.UILib.GetDropDownText(ddlQuadrant);
                if (!domain.QuadrantList.Contains(quadrant))
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "The Quadrant you selected, " + quadrant + ", is no longer supported.  Please select a new value.");
                    return;
                }

                // QUARTER QUADRANT
                string quarterQuadrant = Common.UILib.GetDropDownText(ddlQuarterQuadrant);
                if (!domain.QuarterQuadrantList.Contains(quarterQuadrant))
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "The Quarter Quadrant you selected, " + quarterQuadrant + ", is no longer supported.  Please select a new value.");
                    return;
                }

                // QUARTER FIELD
                string quarterField = Common.UILib.GetDropDownText(ddlQuarterField);
                if (!domain.QuarterQuadrantList.Contains(quarterField))
                {
                    Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "The Quarter Field you selected, " + quarterField + ", is no longer supported.  Please select a new value.");
                    return;
                }

                string  latitude  = txtLatitude.Text;
                decimal dLatitude = 0;
                if (latitude.Length == 0)
                {
                    latitude = "0";
                }
                else
                {
                    if (!Decimal.TryParse(latitude, out dLatitude))
                    {
                        Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Please enter just a number for GPS Latitude, no degree character.");
                        return;
                    }
                    latitude = dLatitude.ToString("0.00000");
                }

                string  longitude  = txtLongitude.Text;
                decimal dLongitude = 0;
                if (longitude.Length == 0)
                {
                    longitude = "0";
                }
                else
                {
                    if (!Decimal.TryParse(longitude, out dLongitude))
                    {
                        Common.AppHelper.ShowWarning((HtmlGenericControl)Master.FindControl("divWarning"), "Please enter just a number for GPS Longitude, no degree character.");
                        return;
                    }
                    longitude = dLongitude.ToString("0.00000");
                }

                string description = txtDescription.Text;
                if (description != Server.HtmlEncode(description))
                {
                    Common.CWarning wex = new Common.CWarning("Your Description cannot contain '<', '>', or '&' characters.");
                    throw (wex);
                }

                if (description.Length > 100)
                {
                    description = description.Substring(0, 100);
                }

                string farmNumber = txtFarmNo.Text;
                if (farmNumber != Server.HtmlEncode(farmNumber))
                {
                    Common.CWarning wex = new Common.CWarning("Your Farm Number cannot contain '<', '>', or '&' characters.");
                    throw (wex);
                }
                string tractNumber = txtTractNo.Text;
                if (tractNumber != Server.HtmlEncode(tractNumber))
                {
                    Common.CWarning wex = new Common.CWarning("Your Tract Number cannot contain '<', '>', or '&' characters.");
                    throw (wex);
                }
                string fieldNumber = txtFieldNo.Text;
                if (fieldNumber != Server.HtmlEncode(fieldNumber))
                {
                    Common.CWarning wex = new Common.CWarning("Your Field Number cannot contain '<', '>', or '&' characters.");
                    throw (wex);
                }

                string acres = txtAcres.Text;
                if (acres.Length > 0)
                {
                    if (acres.Contains("."))
                    {
                        Common.CWarning wex = new Common.CWarning("Your must enter a whole number of acres.");
                        throw (wex);
                    }
                }

                string fsaNumber = txtFSANumber.Text;
                if (fsaNumber != Server.HtmlEncode(fsaNumber))
                {
                    Common.CWarning wex = new Common.CWarning("Your FSA Number cannot contain '<', '>', or '&' characters.");
                    throw (wex);
                }

                bool editForceNewRecord = false;

                if (txtSaveToPriorYears.Text.Length > 0 && txtSaveToPriorYears.Text != "1")
                {
                    editForceNewRecord = true;
                }

                int lldID = 0;
                if (editForceNewRecord)
                {
                    lldID = -1;
                }
                else
                {
                    lldID = UsrCntSelector.LldID;
                }

                int cntlldOUT = UsrCntSelector.CntLLDID;
                WSCField.LegalLandDescSave(lldID,
                                           state, county, township,
                                           range, section,
                                           quadrant, quarterQuadrant,
                                           (latitude == "" ? 0 : Convert.ToDecimal(latitude)),
                                           (longitude == "" ? 0 : Convert.ToDecimal(longitude)),
                                           description, UsrCntSelector.FieldName,
                                           (acres == "" ? 0 : Convert.ToInt32(acres)),
                                           chkFSAOfficial.Checked, UsrCntSelector.FsaNumber, fsaState, fsaCounty,
                                           farmNumber, tractNumber, fieldNumber, quarterField,
                                           auth.UserName, ref lldIDOUT,
                                           editForceNewRecord, UsrCntSelector.CntLLDID, UsrCntSelector.ContractID, UsrCntSelector.CropYear, ref cntlldOUT);

                if (UsrCntSelector.CntLLDID > 0)
                {
                    if (editForceNewRecord)
                    {
                        UsrCntSelector.InitControl(UsrCntSelector.SHID, UsrCntSelector.CropYear, UsrCntSelector.ContractNumber, UsrCntSelector.SequenceNumber + 1);
                    }
                    else
                    {
                        UsrCntSelector.InitControl(UsrCntSelector.SHID, UsrCntSelector.CropYear, UsrCntSelector.ContractNumber, UsrCntSelector.SequenceNumber);
                    }
                }

                UsrCntSelector.LldID    = lldIDOUT;
                UsrCntSelector.CntLLDID = cntlldOUT;

                ShowFieldDetail(UsrCntSelector.LldID);
                NewContractAlertOff();
            }
            catch (Exception ex) {
                ShowError(ex, "Unable to Save this Field Information at this time.");
            }
        }