protected void btnOverrideUpdate_Click(object sender, EventArgs e) { const string METHOD_NAME = "btnOverrideUpdate_Click"; try { // First walk thru all business rules. if (grdContract.SelectedRow == null) { Common.CWarning warn = new Common.CWarning("Please select a Contract to edit."); throw (warn); } string userName = Common.AppHelper.GetIdentityName(); int cropYear = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear)); int directDeliveryID = Convert.ToInt32(grdContract.SelectedRow.Cells[(int)GrdContractCols.colDirectDeliveryID].Text); int contractID = Convert.ToInt32(grdContract.SelectedRow.Cells[(int)GrdContractCols.colContractID].Text); string rowVersion = grdContract.SelectedRow.Cells[(int)GrdContractCols.colRowVersion].Text; // Get the rate per ton. Rate is not required, but if given it must be a decimal string ratePerTonText = txtEditContractRatePerTon.Text; decimal dRatePerTon = 0; if (ratePerTonText.Length > 0) { try { dRatePerTon = Convert.ToDecimal(ratePerTonText); } catch { Common.CWarning warn = new Common.CWarning("Please enter a valid dollar amount for the Contract Rate Per Ton."); throw (warn); } } // Save it ! BeetDirectDelivery.DirectDeliveryContractSave(directDeliveryID, cropYear, contractID, dRatePerTon, rowVersion, userName); ResetContractEdit(); FillContractList(); FillGridContract(); } catch (System.Exception ex) { Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex); ((PrimaryTemplate)Page.Master).ShowWarning(ex); } }
protected void btnOverrideAdd_Click(object sender, EventArgs e) { const string METHOD_NAME = "btnOverrideAdd_Click"; try { string userName = Common.AppHelper.GetIdentityName(); int cropYear = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear)); string rowVersion = ""; // First walk thru all business rules. if (grdDirectDelivery.SelectedRow == null) { Common.CWarning warn = new Common.CWarning("Please select a Direct Delivery Scenario before adding a contract to a scenario."); throw (warn); } // Get the contractID if (ddlEditContractNumber.SelectedItem == null) { Common.CWarning warn = new Common.CWarning("Please select a Contract from the drop down list before adding a contract to the scenario."); throw (warn); } int contractID = Convert.ToInt32(ddlEditContractNumber.SelectedItem.Value); // No duplicates allowed in Contract grid. string cntNo = ddlEditContractNumber.SelectedItem.Text; foreach (GridViewRow row in grdContract.Rows) { if (row.Cells[(int)GrdContractCols.colContractNumber].Text == cntNo) { Common.CWarning warn = new Common.CWarning("This contract is already a listed override, please select another contract to Add."); throw (warn); } } // Get the rate per ton. Rate is not required, but if given it must be a decimal string ratePerTonText = txtEditContractRatePerTon.Text; decimal dRatePerTon = 0; if (ratePerTonText.Length > 0) { try { dRatePerTon = Convert.ToDecimal(ratePerTonText); } catch { Common.CWarning warn = new Common.CWarning("Please enter a valid dollar amount for the Rate Per Ton."); throw (warn); } } int directDeliveryID = Convert.ToInt32(grdDirectDelivery.SelectedRow.Cells[(int)GrdDirectDeliveryCols.colDirectDeliveryID].Text); // Save it ! BeetDirectDelivery.DirectDeliveryContractSave(directDeliveryID, cropYear, contractID, dRatePerTon, rowVersion, userName); ResetContractEdit(); FillContractList(); FillGridContract(); } catch (System.Exception ex) { Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex); ((PrimaryTemplate)Page.Master).ShowWarning(ex); } }