protected void btnOverrideDelete_Click(object sender, EventArgs e) { const string METHOD_NAME = "btnOverrideDelete_Click"; try { // First walk thru all business rules. if (grdContract.SelectedRow == null) { Common.CWarning warn = new Common.CWarning("Please select a Contract to Delete from the grid."); throw (warn); } 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; // Delete it ! BeetDirectDelivery.DirectDeliveryContractDelete(directDeliveryID, cropYear, contractID, rowVersion); ResetContractEdit(); FillContractList(); FillGridContract(); } catch (System.Exception ex) { Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex); ((PrimaryTemplate)Page.Master).ShowWarning(ex); } }
private void FillGridContract() { const string METHOD_NAME = "FillGridContract"; try { if (grdDirectDelivery.SelectedRow != null) { int cropYear = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear)); int directDeliveryID = Convert.ToInt32(grdDirectDelivery.SelectedRow.Cells[(int)GrdDirectDeliveryCols.colDirectDeliveryID].Text); int contractID = 0, contractNumber = 0; List <ListDirectDeliveryContractItem> stateList = BeetDirectDelivery.DirectDeliveryContractGet(cropYear, directDeliveryID, contractID, contractNumber); grdContract.SelectedIndex = -1; grdContract.DataSource = stateList; grdContract.DataBind(); } else { List <ListDirectDeliveryContractItem> stateList = new List <ListDirectDeliveryContractItem>(); stateList.Add(new ListDirectDeliveryContractItem(0, 0, "", 0, 0)); grdContract.SelectedIndex = -1; grdContract.DataSource = stateList; grdContract.DataBind(); } } catch (Exception ex) { Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex); throw (wex); } }
protected void btnDirectDeliveryAdd_Click(object sender, EventArgs e) { const string METHOD_NAME = "btnDirectDeliveryAdd_Click"; try { string userName = Common.AppHelper.GetIdentityName(); int cropYear = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear)); int directDeliveryID = 0; string rowVersion = ""; // Get the delivery station if (ddlEditDeliveryStation.SelectedItem == null) { Common.CWarning warn = new Common.CWarning("Please select a Delivery Station in the Direct Delivery Edit area."); throw (warn); } int deliveryStationNumber = Convert.ToInt32(ddlEditDeliveryStation.SelectedItem.Value); // Get the cotnract station if (ddlEditContractStation.SelectedItem == null) { Common.CWarning warn = new Common.CWarning("Please select a Contract Station in the Direct Delivery Edit area."); throw (warn); } int contractStationNumber = Convert.ToInt32(ddlEditContractStation.SelectedItem.Value); // Get the rate per ton. Rate is not required, but if given it must be a decimal string ratePerTonText = txtEditRatePerTon.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); } } // Save it ! BeetDirectDelivery.DirectDeliverySave(directDeliveryID, cropYear, contractStationNumber, deliveryStationNumber, dRatePerTon, rowVersion, userName); ResetDirectDeliveryEdit(); ResetContractEdit(); FillGridDirectDelivery(); FillContractList(); } catch (System.Exception ex) { Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex); ((PrimaryTemplate)Page.Master).ShowWarning(ex); } }
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); } }
private void FillGridDirectDelivery() { const string METHOD_NAME = "FillGridDirectDelivery"; try { int cropYear = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear)); int contractStationNumber = Convert.ToInt32(Common.UILib.GetDropDownValue(ddlCriteriaContractStation)); int deliveryStationNumber = Convert.ToInt32(Common.UILib.GetDropDownValue(ddlCriteriaDeliveryStation)); List <ListDirectDeliveryItem> stateList = BeetDirectDelivery.DirectDeliveryGet(cropYear, contractStationNumber, deliveryStationNumber); grdDirectDelivery.SelectedIndex = -1; grdDirectDelivery.DataSource = stateList; grdDirectDelivery.DataBind(); } catch (Exception ex) { Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex); throw (wex); } }
private void DoContractSearch() { const string METHOD_NAME = "DoContractSearch"; try { //--------------------------------------------------------------------------------------------- // Work from bottom up. Arrange Contract override then arrange the direct delivery definition. // * Fill Contract Grid * //--------------------------------------------------------------------------------------------- int cropYear = Convert.ToInt32(Common.UILib.GetDropDownText(ddlCropYear)); int directDeliveryID = 0, contractID = 0; int contractNumber = 0; try { contractNumber = Convert.ToInt32(_contractSearch); } catch { Common.CWarning wex = new Common.CWarning("Please enter a contract number."); throw (wex); } List <ListDirectDeliveryContractItem> cntList = BeetDirectDelivery.DirectDeliveryContractGet(cropYear, directDeliveryID, contractID, contractNumber); directDeliveryID = Convert.ToInt32(cntList[0].DirectDeliveryID); contractID = Convert.ToInt32(cntList[0].ContractID); List <ListDirectDeliveryItem> deliveryList = BeetDirectDelivery.DirectDeliveryGetByID(cropYear, directDeliveryID); string deliveryStation = deliveryList[0].DeliveryStation; string contractStation = deliveryList[0].ContractStation; if (deliveryStation.Length == 0 || deliveryStation == "*" || cntList.Count > 1) { deliveryStation = "Any"; } if (contractStation.Length == 0) { contractStation = "Any"; } Common.UILib.SelectDropDown(ddlCriteriaDeliveryStation, deliveryStation); Common.UILib.SelectDropDown(ddlCriteriaContractStation, contractStation); ResetDirectDeliveryEdit(); ResetContractEdit(); FillGridDirectDelivery(); if (directDeliveryID > 0) { // Find the matching row in the Direct Delivery grid. foreach (GridViewRow row in grdDirectDelivery.Rows) { if (row.Cells[(int)GrdDirectDeliveryCols.colDirectDeliveryID].Text == directDeliveryID.ToString()) { grdDirectDelivery.SelectedIndex = row.DataItemIndex; } } } if (grdDirectDelivery.SelectedRow != null) { PopDirectDeliveryEdit(); } FillContractList(); FillGridContract(); if (contractID > 0) { // Find the matching row in the Direct Delivery grid. foreach (GridViewRow row in grdContract.Rows) { if (row.Cells[(int)GrdContractCols.colContractID].Text == contractID.ToString()) { grdContract.SelectedIndex = row.DataItemIndex; } } } if (grdContract.SelectedRow != null) { PopContractEdit(); } } catch (System.Exception ex) { Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex); throw (wex); } }
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); } }