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());
                    }
                }
            }
        }
Esempio n. 3
0
        private void btnAssociateBooking_Click(object sender, EventArgs e)
        {
            RailList1.RequestSelectedUnitNumbers();
            var    muRow            = new VW_UnitSourceMiniUnit();
            var    mbMU             = new DataTable();
            var    muRowList        = new List <VW_UnitSourceMiniUnit>();
            var    multiMUList      = new List <VW_UnitSourceMiniUnit>();
            var    muListToAssign   = new List <VW_UnitSourceMiniUnit>();
            string diffCargosList   = "";
            string diffCustomerList = "";
            var    SelectedUs       = UnitSourceService.GetByUnitSourceListById(SelectedUniSourceId);

            if (hasSameCargoTypes(SelectedUs, ref diffCargosList) == false)
            {
                My.MyProject.Forms.MessageBoxCeresOK.ShowDialog("Can not proceed:", "It Seems like different cargo types has been selected. Please, select only one type of cargo type to continue." + Constants.vbNewLine + "Units:" + Constants.vbNewLine + diffCargosList, this);
                return;
            }
            else if (hasSameCustomers(SelectedUs, ref diffCustomerList) == false)
            {
                My.MyProject.Forms.MessageBoxCeresOK.ShowDialog("Can not proceed:", "It Seems like different Customers has been selected. Please, select the same customer name  to continue." + Constants.vbNewLine + "Units:" + Constants.vbNewLine + diffCustomerList, this);
                return;
            }

            {
                var withBlock = My.MyProject.Forms.frmMiniUnitToAssign;

                // Lopp through selected Unit sources
                for (int i = 0, loopTo = SelectedUniSourceId.Count - 1; i <= loopTo; i++)
                {
                    // Get All MiniUnits from unitID
                    muRowList = VW_UnitSOurceMiniUnitService.GetByUnitSourceById(SelectedUniSourceId[i]);

                    // If more than one mu, send them to Form where user will pick the mini unit
                    if (muRowList.Count > 1)
                    {
                        foreach (var mu in muRowList)
                        {
                            multiMUList.Add(mu);
                        }
                        withBlock.VWUnitSourceMiniUnitBindingSource.DataSource = multiMUList;
                    }

                    // If theres only one MU, send it straigt to Form where mini unit will be asn to minibooking
                    else if (muRowList.Count == 1)
                    {
                        muListToAssign.Add(muRowList[0]);
                        My.MyProject.Forms.frmAssignUnitToBooking.dgvMiniUnit.DataSource = muListToAssign;
                    }

                    // If there's no mini unit, give the option to edit unit source, and repeat process
                    else if (My.MyProject.Forms.MessageBoxCeresYesNo.ShowDialog("There is not Mini Unit for this Unit.", "Create Mini Unit ?", My.Resources.Resources.caution, this) == DialogResult.Yes)
                    {
                        // FrmEditAddRailList.

                        var unit     = UnitSourceService.GetVWById(SelectedUniSourceId[i]);
                        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);
                        RailList1.RequestSelectedUnitNumbers();
                        MdlLoadingSetting.showDialogForm(My.MyProject.Forms.FrmEditAddRailList, My.MyProject.Forms.FrmParentScreen);
                        muRowList = VW_UnitSOurceMiniUnitService.GetByUnitSourceById(SelectedUniSourceId[i]);
                        if (muRowList.Count > 1)
                        {
                            foreach (var mu in muRowList)
                            {
                                multiMUList.Add(mu);
                            }
                            withBlock.VWUnitSourceMiniUnitBindingSource.DataSource = multiMUList;
                        }
                        else if (muRowList.Count == 1)
                        {
                            muListToAssign.Add(muRowList[0]);
                            My.MyProject.Forms.frmAssignUnitToBooking.dgvMiniUnit.DataSource = muListToAssign;
                        }
                    }
                }

                if (My.MyProject.Forms.frmMiniUnitToAssign.VWUnitSourceMiniUnitBindingSource.Count > 1)
                {
                    MdlLoadingSetting.showDialogForm(My.MyProject.Forms.frmMiniUnitToAssign, this);
                }
                else if (Convert.ToInt32(((List <object>)My.MyProject.Forms.frmAssignUnitToBooking.dgvMiniUnit.DataSource).Count) > 0)
                {
                    MdlLoadingSetting.showDialogForm(My.MyProject.Forms.frmAssignUnitToBooking, this);
                }
                else
                {
                    RailList1.TakeRailList(FetchRailList(true), true);
                }
            }
        }