Esempio n. 1
0
        private void populateMiniUnits()
        {
            BkServicesList.Clear();
            if (OriginalMBSelectedList.Count > 0)
            {
                var selectedMBRow = OriginalMBSelectedList[0];
                if (selectedMBRow.ServiceCode.Equals("BAG"))
                {
                    BkServicesList.Add("BAG");
                }
                else
                {
                    BkServicesList.Add("BLK");
                    BkServicesList.Add("OTHER");
                }

                UnitMUList = VW_UnitSOurceMiniUnitService.GetByFilter(selectedMBRow.CustomerName, BkServicesList, "");
                VWUnitSourceMiniUnitBindingSource.DataSource = UnitMUList;
                VWGrainUnitStorageBindingSource.DataSource   = GrainInventoryService.GetAllGrainInventoryUnitsByFilter(selectedMBRow.CustomerName, BkServicesList, Strings.Trim(tbSearchStorageUnit.Text));
            }
        }
Esempio n. 2
0
        private void checkCmdtyAndCustomer(object unitRow)
        {
            int    muID;
            string MUSource;
            string cmdtyName;
            string gradeName;
            int    cmdtyId;
            int    gradeId;
            VW_BookingMinibooking selectedMBRow;
            VW_UnitSourceMiniUnit mu = (VW_UnitSourceMiniUnit)unitRow;

            VW_GrainUnitStorage g = new VW_GrainUnitStorage();

            try
            {
                g = (VW_GrainUnitStorage)unitRow;
            }
            catch { }


            muID = mu.MiniUnitId;


            MUSource = Conversions.ToString(mu.MiniunitNumber);

            // selectedUnits.Add(muID, MUSource)

            cmdtyName = Conversions.ToString(mu.CommodityName);
            gradeName = Conversions.ToString(mu.GradeName);
            cmdtyId   = Conversions.ToInteger(mu.CommodityId);
            gradeId   = Conversions.ToInteger(mu.GradeId);

            // Check if mini unit is already assigned to mini booking
            for (int i = 0, loopTo = dgvSelectedBkg.Rows.Count - 1; i <= loopTo; i++)
            {
                selectedMBRow = (VW_BookingMinibooking)dgvSelectedBkg.Rows[i].DataBoundItem;
                bool muAlreadyAsn;
                // check if mu was already assigned
                if (tabUnits.SelectedIndex == 0)
                {
                    muAlreadyAsn = MdlBookingManagement.miniUnitAlreadyAssigned(muID, selectedMBRow.MiniBookingId, false);
                }
                else
                {
                    g            = (VW_GrainUnitStorage)unitRow;
                    muAlreadyAsn = MdlBookingManagement.miniUnitAlreadyAssigned(g.GrainInvStorageLocationId, selectedMBRow.MiniBookingId, true);
                }

                if (muAlreadyAsn)
                {
                    shouldNotAssignList.Add(muID.ToString() + "|" + selectedMBRow.MiniBookingId.ToString());
                    My.MyProject.Forms.MessageBoxCeresOK.ShowDialog("Unit source already added to booking", "Selected Unit source is already added to the booking " + selectedMBRow.BookingNumber + ", so it will not be added again.", this);
                }

                // If cmdty doesn't exist, add to unit source.
                if (cmdtyId == 0)
                {
                    var result = My.MyProject.Forms.MessageBoxCeresYesNo.ShowDialog("Warning:", "There's no commodity added to the unit '" + MUSource + "' Yet. Would you like to add it now? " + "If No is selected, the unit will not be added to the booking", My.Resources.Resources.caution, this);
                    if (result == DialogResult.Yes)
                    {
                        var unit     = UnitSourceService.GetVWById(Conversions.ToInteger(mu.UnitSourceId));
                        var unitList = new List <VW_UnitSource>();
                        unitList.Add(unit);
                        My.MyProject.Forms.FrmEditAddRailList.isNewRecord = false;
                        My.MyProject.Forms.FrmEditAddRailList.isMultiEdit = false;
                        My.MyProject.Forms.FrmEditAddRailList.LoadForm(unitList);
                        Close();
                        MdlLoadingSetting.showDialogForm(My.MyProject.Forms.FrmEditAddRailList, My.MyProject.Forms.FrmParentScreen);
                    }
                    // If tabUnits.SelectedIndex = 0 Then
                    // VWUnitSourceMiniUnitBindingSource.DataSource.Item(unitRow) = MiniUnitService.GetVWByMUId(unitRow.MiniUnitId)
                    // 'VWUnitSourceMiniUnitBindingSource.DataSource

                    // End If
                    else if (tabUnits.SelectedIndex == 0)
                    {
                        shouldNotAssignList.Add(muID.ToString() + "|" + selectedMBRow.MiniBookingId.ToString());
                    }
                    else
                    {
                        g = (VW_GrainUnitStorage)unitRow;
                        shouldNotAssignStorageList.Add(g.GrainInvStorageLocationId.ToString() + "|" + selectedMBRow.MiniBookingId.ToString());
                    }
                }
                // If cmdty and grade doesnt exist in mb, ask if should add.
                else if (MdlBookingManagement.miniUnitMissingCommodity(selectedMBRow.MiniBookingId, cmdtyId, gradeId))
                {
                    var result = My.MyProject.Forms.MessageBoxCeresYesNo.ShowDialog("Commodity and Rate doesn't match", "The commodity and grade of the unit '" + MUSource + "' (" + gradeName + " " + cmdtyName + ") is not added to the booking '" + selectedMBRow.BookingNumber + "'. Would you like to add it now? " + "If No is selected, the unit will not be added to the booking", My.Resources.Resources.caution, this);
                    if (result == DialogResult.Yes)
                    {
                        MdlBookingManagement.saveBkgCommodity(selectedMBRow.MiniBookingId, cmdtyId, gradeId);
                    }
                    else if (tabUnits.SelectedIndex == 0)
                    {
                        shouldNotAssignList.Add(muID.ToString() + "|" + selectedMBRow.MiniBookingId.ToString());
                    }
                    else
                    {
                        shouldNotAssignStorageList.Add(g.GrainInvStorageLocationId.ToString() + "|" + selectedMBRow.MiniBookingId.ToString());
                    }
                }

                if (mu.CustomerId != selectedMBRow.CustomerId)
                {
                    var result = My.MyProject.Forms.MessageBoxCustomerMatchingWarning.ShowDialog(selectedMBRow, unitRow, this);
                    if (result == DialogResult.Yes & shouldChangeCustomer == true)
                    {
                        MdlBookingManagement.updateCustomer(MiniUnitService.GetById(muID));

                        // update muDataGridView
                        VWUnitSourceMiniUnitBindingSource.DataSource = VW_UnitSOurceMiniUnitService.GetByFilter(Conversions.ToString(mu.CustomerName), BkServicesList, Strings.Trim(tbSearchStorageUnit.Text));
                    }
                    else if (tabUnits.SelectedIndex == 0)
                    {
                        shouldNotAssignList.Add(muID.ToString() + "|" + selectedMBRow.MiniBookingId.ToString());
                    }
                    else
                    {
                        shouldNotAssignStorageList.Add(g.GrainInvStorageLocationId.ToString() + "|" + selectedMBRow.MiniBookingId.ToString());
                    }
                }
            }
        }