// Private Sub AssignUnitsToBookingsExcel() // Dim miniUnits As List(Of VW_MinibookingMiniUnitAssignment), miniUnitIds As New List(Of Integer), // miniBookingIds As New Dictionary(Of Integer, String), muRow As VW_UnitSourceMiniUnit, mbRow As VW_BookingMinibooking // Dim muIDmbID As String, railListID As Integer = 0, bus As New MinibookingMiniUnitAssignmentService // For i = 0 To dgvMiniUnit.Rows.Count - 1 // muRow = dgvMiniUnit.Rows(i).DataBoundItem // railListID = muRow.RecordKey // For s = 0 To dgvAllBookings.Rows.Count - 1 // If dgvAllBookings.Rows(s).Cells(0).Value = True Then // mbRow = dgvAllBookings.Rows(s).DataBoundItem // muIDmbID = muRow.MiniUnitId.ToString + "|" + mbRow.MiniBookingId.ToString // If Not shouldNotAssignList.Contains(muIDmbID) Then // If Not miniBookingIds.ContainsKey(mbRow.MiniBookingId) Then // miniBookingIds.Add(mbRow.MiniBookingId, mbRow.BookingNumber) // End If // End If // End If // Next // Next // 'For Each mb In miniBookingIds // ' miniUnits = MinibookingMiniUnitAssignmentService.GetByMiniBookingId(mb.Key) // ' updateUnitsInExcelFile(mb.Value, miniUnits) // 'Next // 'getAsnUnits() // End Sub private void getAsnBookings() { if (dgvMiniUnit.Rows.Count > 0) { int index = dgvMiniUnit.CurrentRow.Index; var newRowBalToStorage = new VW_MinibookingMiniUnitAssignment(); VW_UnitSourceMiniUnit mu = (VW_UnitSourceMiniUnit)dgvMiniUnit.CurrentRow.DataBoundItem; var mbmuasnList = MinibookingMiniUnitAssignmentService.GetByMiniUnitId(mu.MiniUnitId); if (mu.BalanceToStorageAllowed == true == true) { newRowBalToStorage.BookingNumber = "BAL. TO STORAGE"; mbmuasnList.Add(newRowBalToStorage); btnBalToStorage.Text = "RM. BAL. TO STORAGE"; } else { btnBalToStorage.Text = "BAL. TO STORAGE"; } VWMinibookingMiniUnitAssignmentBindingSource.DataSource = mbmuasnList; } else { VWMinibookingMiniUnitAssignmentBindingSource.DataSource = MinibookingMiniUnitAssignmentService.GetByMiniUnitId(0); dgvAsnBookings.DataSource = VWMinibookingMiniUnitAssignmentBindingSource; } }
private void populateBagLabels() { UnitObj = (VW_UnitSourceMiniUnit)cboUnitSources.SelectedItem; lblCustomer.Text = UnitObj.CustomerName; lblCargoType.Text = UnitObj.CargoType; lblCommodityGrade.Text = UnitObj.GradeName + " " + UnitObj.CommodityName; }
public DialogResult ShowDialog(VW_BookingMinibooking mbRow, object muRow, Form assgnForm) { bkgNumbLabel.Text = mbRow.BookingNumber; bkgCustomerLabel.Text = mbRow.CustomerName; VW_UnitSourceMiniUnit mu = (VW_UnitSourceMiniUnit)muRow; unitSourvceNumbLabel.Text = Conversions.ToString(mu.MiniunitNumber); try { unitSourceCustomLabel.Text = Conversions.ToString(mu.CustomerName); } catch { unitSourceCustomLabel.Text = Conversions.ToString(mu.CustomerName); } _muID = Conversions.ToInteger(mu.MiniUnitId); PictureBox1.Hide(); changeUnitCustRadioButton.Checked = false; dontAsnRadioButton.Checked = true; checkUnit(); MdlLoadingSetting.showDialogForm(this, assgnForm); return(DialogResult); }
private void FrmGrainInvList_Load(object sender, EventArgs e) { firstLoad = true; var giService = new GrainInventoryService(); dgvInventory.DataSource = GrainInventoryService.GetAllGrainInventory(); using (var db = new WTCCeresEntities()) { { var withBlock = cboCustomer; var categories = new List <int>(); categories.Add((int)MdlEnum.CompanyCategory.CUSTOMER); categories.Add((int)MdlEnum.CompanyCategory.CUSTOMER_VENDOR); withBlock.DataSource = CompanyService.GetByCompanyCategoryId(categories, db); withBlock.DisplayMember = "CompanyName"; withBlock.ValueMember = "CompanyId"; } var exclusionList = new List <string>(); exclusionList.Add("RELEASED"); { var withBlock1 = cboUnitNumber; var newUs = new VW_UnitSourceMiniUnit(); newUs.MiniunitNumber = ""; newUs.MiniUnitId = 0; var uslist = MiniUnitService.GetAll(exclusionList, db); uslist.Insert(0, newUs); withBlock1.DataSource = uslist; withBlock1.DisplayMember = "MiniUnitNumber"; withBlock1.ValueMember = "MiniUnitId"; withBlock1.SelectedIndex = -1; } { var withBlock2 = cboCommodity; withBlock2.DataSource = CommodityService.GetAll(db); withBlock2.DisplayMember = "CommodityCode"; withBlock2.ValueMember = "CommodityId"; } { var withBlock3 = cboGrade; withBlock3.DataSource = GradeService.GetAll(db); withBlock3.DisplayMember = "GradeCode"; withBlock3.ValueMember = "GradeId"; } } firstLoad = false; }
private bool GoodToGo() { bool isGood = true; int railListId = 0; lblWarning.Text = ""; int previousMiniUnitId = 0; if (UnitObj.CustomerId == 0) { isGood = false; previousMiniUnitId = UnitObj.MiniUnitId; var result = My.MyProject.Forms.MessageBoxCeresYesNo.ShowDialog("Field Required:", "It seems like the unit " + UnitObj.MiniunitNumber + " has no customer yet, and creation on grain inventory can not proceed without this information." + Constants.vbNewLine + "Would you like to edit this unit now?", My.Resources.Resources.warning, this); if (result == DialogResult.Yes) { if (!Information.IsNothing(UnitObj.RecordKey)) { railListId = (int)UnitObj.RecordKey; } var unit = UnitSourceService.GetVWById(UnitObj.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); MdlLoadingSetting.showDialogForm(My.MyProject.Forms.FrmEditAddRailList, this); firstLoad = true; cboUnitSources.DataSource = MiniUnitService.GetAll(exclusionList); cboUnitSources.SelectedValue = previousMiniUnitId; UnitObj = (VW_UnitSourceMiniUnit)cboUnitSources.SelectedItem; populateBagLabels(); firstLoad = false; GoodToGo(); } } else if (dgvGrainLocations.Rows.Count == 0) { isGood = false; lblWarning.Text = "Inventory quantity can not be 0"; } else if (UnitObj.CargoType == "BAGGER" & Information.IsNothing(SelectedBag)) { lblWarning.Text = "Must select a bag for cargo type 'BAGGER'"; isGood = false; } return(isGood); }
/* TODO ERROR: Skipped EndRegionDirectiveTrivia */ /* TODO ERROR: Skipped RegionDirectiveTrivia */ private void LoadGridMiniBooking(string BookingNumber) { VW_UnitSourceMiniUnit muRow = (VW_UnitSourceMiniUnit)dgvMiniUnit.Rows[0].DataBoundItem; SelectedCargosList.Clear(); if (muRow.CargoTypeCode.Equals("BAG")) { SelectedCargosList.Add("BAG"); } else { SelectedCargosList.Add("BLK"); SelectedCargosList.Add("BGR"); } VWBookingMinibooking.DataSource = MinibookingService.GetJointBookingToAsnByFilter(muRow.CustomerName, SelectedCargosList, txtBookingNumber.Text); shouldNotAssignList.Clear(); checkAsnButton(); }
private void btnAssignBooking_Click(object sender, EventArgs e) { var muToBeAssign = new List <VW_UnitSourceMiniUnit>(); muToBeAssign = (List <VW_UnitSourceMiniUnit>)My.MyProject.Forms.frmAssignUnitToBooking.VWUnitSourceMiniUnitBindingSource.DataSource; for (int i = 0, loopTo = dgvMiniUnit.Rows.Count - 1; i <= loopTo; i++) { if (Conversions.ToBoolean(Operators.ConditionalCompareObjectEqual(dgvMiniUnit.Rows[i].Cells[1].Value, true, false))) { var muRow = new VW_UnitSourceMiniUnit(); muRow = (VW_UnitSourceMiniUnit)dgvMiniUnit.Rows[i].DataBoundItem; muToBeAssign.Add(muRow); } } My.MyProject.Forms.frmAssignUnitToBooking.VWUnitSourceMiniUnitBindingSource.DataSource = muToBeAssign; Close(); My.MyProject.Forms.FrmRailList.LoadForm(false); }
private void btnBalToStorage_Click(object sender, EventArgs e) { VW_UnitSourceMiniUnit miniUnitRow = (VW_UnitSourceMiniUnit)dgvMiniUnit.CurrentRow.DataBoundItem; string message; string titleMessage; if (miniUnitRow.BalanceToStorageAllowed == false == true) { titleMessage = "Balance to storage:"; message = "The remaining balance of unit " + miniUnitRow.MiniunitNumber + " WILL be send to storage at the end of transload." + Constants.vbNewLine + "Confirm balance to storage?"; } else { titleMessage = "Remove balance to storage:"; message = "The remaining balance of unit " + miniUnitRow.MiniunitNumber + " WILL NOT be send to storage at the end of transload." + Constants.vbNewLine + "Confirm remove balance to storage?"; } var result = My.MyProject.Forms.MessageBoxCeresYesNo.ShowDialog(titleMessage, message, My.Resources.Resources.warning, this); if (result == DialogResult.Yes) { if (miniUnitRow.BalanceToStorageAllowed == false == true) { muService.UpdateBalanceAllowedStorage(miniUnitRow.MiniUnitId, true); miniUnitRow.BalanceInstruxCode = "BLTS"; miniUnitRow.BalanceToStorageAllowed = true; } else { muService.UpdateBalanceAllowedStorage(miniUnitRow.MiniUnitId, false); miniUnitRow.BalanceInstruxCode = ""; miniUnitRow.BalanceToStorageAllowed = false; } getAsnBookings(); } }
private void miniUnitsDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { object selectedRow; bool value; DataGridView focusedDgv; int mbId; VW_BookingMinibooking selectedMBRow; if (e.ColumnIndex == 0) { if (tabUnits.SelectedIndex == 0) { value = Conversions.ToBoolean(dgvMiniUnits.Rows[e.RowIndex].Cells[0].Value); selectedRow = new VW_UnitSourceMiniUnit(); selectedRow = (VW_UnitSourceMiniUnit)dgvMiniUnits.Rows[e.RowIndex].DataBoundItem; focusedDgv = dgvMiniUnits; } else { value = Conversions.ToBoolean(dgvStorageUnits.Rows[e.RowIndex].Cells[0].Value); selectedRow = new VW_GrainUnitStorage(); selectedRow = (VW_GrainUnitStorage)dgvStorageUnits.Rows[e.RowIndex].DataBoundItem; focusedDgv = dgvStorageUnits; } if (value == false) { focusedDgv.Rows[e.RowIndex].Cells[0].Value = true; numbSelectMU += 1; checkCmdtyAndCustomer(selectedRow); } else { focusedDgv.Rows[e.RowIndex].Cells[0].Value = false; numbSelectMU -= 1; for (int i = 0, loopTo = dgvSelectedBkg.Rows.Count - 1; i <= loopTo; i++) { selectedMBRow = new VW_BookingMinibooking(); selectedMBRow = (VW_BookingMinibooking)dgvSelectedBkg.Rows[i].DataBoundItem; if (tabUnits.SelectedIndex == 0) { VW_UnitSourceMiniUnit r = new VW_UnitSourceMiniUnit(); r = (VW_UnitSourceMiniUnit)dgvMiniUnits.Rows[e.RowIndex].DataBoundItem; shouldNotAssignList.Remove(r.MiniUnitId.ToString() + "|" + selectedMBRow.MiniBookingId.ToString()); } else { VW_GrainUnitStorage r = new VW_GrainUnitStorage(); r = (VW_GrainUnitStorage)dgvStorageUnits.Rows[e.RowIndex].DataBoundItem; shouldNotAssignStorageList.Remove(r.GrainInventoryId.ToString() + "|" + selectedMBRow.MiniBookingId.ToString()); } } } checkAsnButton(); // VWUnitSourceMiniUnitBindingSource.DataSource = VW_UnitSOurceMiniUnitService.GetByFilter(selectedMBRow.CustomerName, BkServicesList, "") } }
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()); } } } }
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); } } }