Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
            }
        }