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."); } }
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."); } }