private void btnUpdateMu_Click(object sender, EventArgs e) { MiniUnit muRow; var muService = new MiniUnitService(); { var withBlock = My.MyProject.Forms.FrmEditAddRailList; if (shouldRemoveRow) { if (withBlock.miniUnitDT[withBlock.focusedMiniUnit].MiniUnitId != 0) { muService.Delete(withBlock.miniUnitDT[withBlock.focusedMiniUnit].MiniUnitId); } withBlock.miniUnitDT.RemoveAt(withBlock.focusedMiniUnit); withBlock.focusedMiniUnit -= 1; } for (int i = 0, loopTo = withBlock.miniUnitDT.Count - 1; i <= loopTo; i++) { muRow = withBlock.miniUnitDT[i]; muRow.TotalBilled = (decimal?)dgvMiniUnits.Rows[i].Cells[3].Value; } withBlock.checkArrowButtons(); withBlock.PopulateMU(); } Close(); }
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); }
public void LoadForm() { firstLoad = true; exclusionList.Clear(); GrainLocationList.Clear(); VWBagBindingSource.DataSource = BagInventoryService.GetAllBags(); dtpStorage.Value = DateAndTime.Now; SelectedBag = null; lblCustomer.Text = ""; lblCargoType.Text = ""; lblCommodityGrade.Text = ""; dgvGrainLocations.Rows.Clear(); exclusionList.Add("RELEASED"); { var withBlock = cboUnitSources; withBlock.DataSource = MiniUnitService.GetAll(exclusionList); withBlock.DisplayMember = "MiniUnitNumber"; withBlock.ValueMember = "MiniUnitId"; } cboUnitSources.SelectedIndex = -1; firstLoad = false; }
private void loadDataGrid() { switch (unitSourcesTabControl.SelectedIndex) { case 0: { dgvBookingUnit.DataSource = MinibookingMiniUnitAssignmentService.GetByUnitSourceId(focusedUnitID); break; } case 1: { VWUnitSourceMiniUnitBindingSource.DataSource = MiniUnitService.GetUsMuVwByUSId(focusedUnitID); break; } case 2: { break; } // populateReconciliation() } }
private void dgvAllBookings_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) { bool value = Conversions.ToBoolean(dgvAllBookings.Rows[e.RowIndex].Cells[0].Value); VW_BookingMinibooking mbRow; VW_UnitSourceMiniUnit muRow; mbRow = (VW_BookingMinibooking)dgvAllBookings.Rows[e.RowIndex].DataBoundItem; if (value == false) { dgvAllBookings.Rows[e.RowIndex].Cells[0].Value = true; numbSelectMU = +1; // selectedUnits.Add(muID, MUSource) // Check if mini unit is already assigned to mini booking for (int i = 0, loopTo = dgvMiniUnit.Rows.Count - 1; i <= loopTo; i++) { muRow = (VW_UnitSourceMiniUnit)dgvMiniUnit.Rows[i].DataBoundItem; // check if mu was already assigned if (Information.IsNothing(muRow.CommodityId) || muRow.CommodityId == 0) { var result = My.MyProject.Forms.MessageBoxCeresYesNo.ShowDialog("Warning:", "There's no commodity added to the unit '" + muRow.MiniunitNumber + "' 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) { My.MyProject.Forms.FrmEditAddRailList.isNewRecord = false; var unit = UnitSourceService.GetVWById(muRow.UnitSourceId); var unitList = new List <VW_UnitSource>(); unitList.Add(unit); My.MyProject.Forms.FrmEditAddRailList.isMultiEdit = false; My.MyProject.Forms.FrmEditAddRailList.isNewRecord = false; My.MyProject.Forms.FrmEditAddRailList.LoadForm(unitList); Close(); MdlLoadingSetting.showDialogForm(My.MyProject.Forms.FrmEditAddRailList, My.MyProject.Forms.FrmParentScreen); } else { shouldNotAssignList.Add(muRow.ToString() + "|" + mbRow.MiniBookingId.ToString()); } } // If cmdty and grade doesnt exist in mb, ask if should add. else if (MdlBookingManagement.miniUnitMissingCommodity(mbRow.MiniBookingId, muRow.CommodityId, muRow.GradeId)) { var result = My.MyProject.Forms.MessageBoxCeresYesNo.ShowDialog("Commodity and Rate doesn't match", "The commodity and grade of the unit '" + muRow.MiniunitNumber + "' (" + muRow.GradeCode + " " + muRow.CommodityCode + ") is not added to the booking '" + mbRow.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(mbRow.MiniBookingId, muRow.CommodityId, muRow.GradeId); getCmdyAndGrades(mbRow.MiniBookingId); // muRow = //VWUnitSourceMiniUnitBindingSource.DataSource.Item(muRow) = MiniUnitService.GetVWByMUId(muRow.MiniUnitId); } else { shouldNotAssignList.Add(muRow.MiniUnitId.ToString() + "|" + mbRow.MiniBookingId.ToString()); } } else if (MdlBookingManagement.miniUnitAlreadyAssigned(muRow.MiniUnitId, mbRow.MiniBookingId, Conversions.ToBoolean(0))) { shouldNotAssignList.Add(muRow.MiniUnitId.ToString() + "|" + mbRow.MiniBookingId.ToString()); My.MyProject.Forms.MessageBoxCeresOK.ShowDialog("Unit source already added to booking", "Selected Unit source is already added to the booking " + mbRow.BookingNumber + ", so it will not be added again.", this); } // If cmdty and grade doesnt exist in mb, ask if should add. if (mbRow.CustomerId != muRow.CustomerId) { var result = My.MyProject.Forms.MessageBoxCustomerMatchingWarning.ShowDialog(mbRow, muRow, this); if (result == DialogResult.Yes & shouldChangeCustomer == true) { muRow.CustomerId = mbRow.CustomerId; MdlBookingManagement.updateCustomer(MiniUnitService.GetById(muRow.MiniUnitId)); } else { shouldNotAssignList.Add(muRow.MiniUnitId.ToString() + "|" + mbRow.MiniBookingId.ToString()); } } } } else { dgvAllBookings.Rows[e.RowIndex].Cells[0].Value = false; numbSelectMU = -1; for (int i = 0, loopTo1 = dgvMiniUnit.Rows.Count - 1; i <= loopTo1; i++) { muRow = (VW_UnitSourceMiniUnit)dgvMiniUnit.Rows[i].DataBoundItem; shouldNotAssignList.Remove(muRow.MiniUnitId.ToString() + "|" + mbRow.MiniBookingId.ToString()); } } } checkAsnButton(); }
private void tbCreateUnits_Click(object sender, EventArgs e) { if (MandatoryFieldsOk()) { var unitService = new UnitSourceService(); int insertedUSId; var muService = new MiniUnitService(); string unitBilled; if (cboCargoType.Text.Equals("BULK")) { unitBilled = Conversions.ToString(cboWeightUnit.SelectedItem); } else { unitBilled = "PC"; } // My.MyProject.Forms.FrmParentScreen.showLOadForm(); foreach (var unit in UnitList) { UnitSource ExistingUnit; MiniUnit mu; if (unit.UnitId != 0) { ExistingUnit = AllUnits.Where(u => u.UnitSourceId == unit.UnitId).ToList()[0]; // ExistingUnit.UnitStatusId = cboStatus.SelectedValue ExistingUnit.UnitType = Conversions.ToString(cboType.SelectedItem); ExistingUnit.CargoTypeId = Conversions.ToInteger(cboCargoType.SelectedValue); ExistingUnit.LastUpdate = DateAndTime.Now; ExistingUnit.TotalBilled = (double?)unit.TotalBilled; ExistingUnit.OriginalUnitNumber = unit.OriginalUnitNumber; bool isSaved = unitService.AddOrUpdate(ExistingUnit); insertedUSId = unit.UnitId; var muList = new List <MiniUnit>(); muList = MiniUnitService.GetAllByUSId(unit.UnitId); foreach (var currentMu in muList) { mu = currentMu; if (muList.Count == 1) { mu.TotalBilled = unit.TotalBilled; } mu.BilledByUnitUnitType = unitBilled; mu.UnBilledByUnitUnitType = unitBilled; mu.CustomerId = Conversions.ToInteger(cboCustomer.SelectedValue); mu.GradeId = Conversions.ToInteger(cboGrade.SelectedValue); mu.CommodityId = Conversions.ToInteger(cboCommodity.SelectedValue); muService.InsertOrUpdate(mu); } } else { var us = new UnitSource(); us.UnitNumber = unit.UnitNumber; us.OriginalUnitNumber = unit.OriginalUnitNumber; us.UnitStatusId = unit.UnitStatusId; us.UnitType = Conversions.ToString(cboType.SelectedItem); us.CargoTypeId = Conversions.ToInteger(cboCargoType.SelectedValue); us.OriginLocation = ""; us.UnitLine = ""; us.ETALocation = ""; us.Sequence = ""; us.Track = ""; us.LastLocation = ""; us.DemurageDays = 0; us.InTransitDays = 0; us.TotalBilled = (double?)unit.TotalBilled; us.LastUpdate = DateAndTime.Now; us.ActiveUpdates = true; us.Active = true; us.RecordKey = 0; us.CargoDescription = ""; us.ShipperId = 0; us.ETADate = default; us.BillDate = default; us.CallDate = default; us.AvailableDate = default; us.ArrivalDate = default; us.ReleaseDate = default; unitService.AddOrUpdate(us); insertedUSId = unitService.GetLastUnitSourceId(); mu = new MiniUnit(); mu.MiniUnitOrder = 1; mu.UnitSourceId = insertedUSId; mu.TotalBilled = unit.TotalBilled; mu.UnBilled = 0; mu.BilledByUnit = 0; mu.BilledByUnitUnitType = unitBilled; mu.UnBilledByUnit = 0; mu.UnBilledByUnitUnitType = unitBilled; mu.MULocation = ""; mu.Comments = ""; mu.CustomerId = Conversions.ToInteger(cboCustomer.SelectedValue); mu.GradeId = Conversions.ToInteger(cboGrade.SelectedValue); mu.CommodityId = Conversions.ToInteger(cboCommodity.SelectedValue); mu.BalanceToStorageAllowed = true; mu.isMultiMU = false; muService.InsertOrUpdate(mu); } } // My.MyProject.Forms.FrmParentScreen.HideLoadForm(); var result = My.MyProject.Forms.MessageBoxCeresYesNo.ShowDialog("Success!", "Units added with success. Do you want continue creating/updating units?", My.Resources.Resources.icon_available, this); if (!(result == DialogResult.Yes)) { Close(); } else { UnitList.Clear(); AllUnits = UnitSourceService.GetByActiveStatus(Conversions.ToBoolean(1)); tbUnits.Text = ""; } } }
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()); } } } }