Exemple #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (GoodToGo())
            {
                var giService = new GrainInventoryService();
                // '1 - RECEIVE
                // '2 - SEND
                // '3 - USE
                // '4 - ADJUST

                if (isNewInventory)
                {
                    if (!Information.IsNothing(SelectedBag))
                    {
                        giService.InsertGrainInventory(UnitObj.CustomerId, SelectedBag.BagId, Conversions.ToSingle(lblTotalQuantity.Text), UnitObj.MiniUnitId);
                    }
                    else
                    {
                        giService.InsertGrainInventory(UnitObj.CustomerId, 0, Conversions.ToSingle(lblTotalQuantity.Text), UnitObj.MiniUnitId);
                    }

                    foreach (var grainLoc in GrainLocationList)
                    {
                        giService.InsertGrainInvStorageLocation(giService.GetLastGrainInvetoryId(), grainLoc.StorageTypeId, grainLoc.StorageId, (float)grainLoc.QtyInStorage, DateAndTime.Now);
                        giService.InsertGrainInventoryTransaction(giService.GetLastGrainInvetoryId(), 1, (float)grainLoc.QtyInStorage, DateAndTime.Now);
                        giService.InsertGrainInvTransactionGrainStorageLocation(giService.GetLastGrainInventoryTransactionId(), giService.GetLastGrainInvStorageLocationId());
                    }
                }

                My.MyProject.Forms.FrmGrainInvList.dgvInventory.DataSource = GrainInventoryService.GetAllGrainInventory();
                Close();
            }
        }
Exemple #2
0
        private void AssignUnitsToBookings()
        {
            string muIDmbID;
            var    bus = new MinibookingMiniUnitAssignmentService();
            var    gis = new GrainInventoryService();
            VW_BookingMinibooking mbRow;
            VW_UnitSourceMiniUnit unitRowUnit;
            VW_GrainUnitStorage   unitRowStorage;

            for (int i = 0, loopTo = dgvSelectedBkg.Rows.Count - 1; i <= loopTo; i++)
            {
                mbRow = (VW_BookingMinibooking)dgvSelectedBkg.Rows[i].DataBoundItem;
                if (tabUnits.SelectedIndex == 0)
                {
                    for (int s = 0, loopTo1 = dgvMiniUnits.Rows.Count - 1; s <= loopTo1; s++)
                    {
                        if (Conversions.ToBoolean(Operators.ConditionalCompareObjectEqual(dgvMiniUnits.Rows[s].Cells[0].Value, true, false)))
                        {
                            unitRowUnit = (VW_UnitSourceMiniUnit)dgvMiniUnits.Rows[s].DataBoundItem;
                            muIDmbID    = unitRowUnit.MiniUnitId.ToString() + "|" + mbRow.MiniBookingId.ToString();

                            // If mini munit key and mini booking key is not on the should not assign list,
                            // then assign unit to bkg
                            if (!shouldNotAssignList.Contains(muIDmbID))
                            {
                                // 'dbCeres.assignUnitsToMiniBkgs(unitID, mbID, bkgNumber, unitNumber, recordKey)
                                bus.Insert(mbRow.MiniBookingId, unitRowUnit.MiniUnitId);
                                EmployeeActivityLogService.Insert(My.MyProject.Forms.FrmLoginWindow._userID, "UnitId: " + unitRowUnit.MiniUnitId.ToString() + " | MbId: " + mbRow.MiniBookingId.ToString(), "ASSIGN", "UNIT", "Unit Source " + unitRowUnit.MiniunitNumber + " assigned to booking " + mbRow.BookingNumber);
                            }
                        }
                    }
                }
                else
                {
                    for (int s = 0, loopTo2 = dgvStorageUnits.Rows.Count - 1; s <= loopTo2; s++)
                    {
                        if (Conversions.ToBoolean(Operators.ConditionalCompareObjectEqual(dgvStorageUnits.Rows[s].Cells[0].Value, true, false)))
                        {
                            unitRowStorage = (VW_GrainUnitStorage)dgvStorageUnits.Rows[s].DataBoundItem;
                            muIDmbID       = unitRowStorage.MiniUnitId.ToString() + "|" + mbRow.MiniBookingId.ToString();

                            // If mini munit key and mini booking key is not on the should not assign list,
                            // then assign unit to bkg
                            if (!shouldNotAssignList.Contains(muIDmbID))
                            {
                                gis.InsertGrainInvMinibookingAssignment(mbRow.MiniBookingId, unitRowStorage.GrainInvStorageLocationId, (float)unitRowStorage.QtyInStorage, DateAndTime.Now);
                                gis.InsertGrainInventoryTransaction(unitRowStorage.GrainInventoryId, (int)MdlEnum.TransactionType.ASSIGNMENT, (float)unitRowStorage.QtyInStorage, DateAndTime.Now);
                                gis.InsertGrainInvMinibookingTransaction(mbRow.MiniBookingId, gis.GetLastGrainInventoryTransactionId());
                                EmployeeActivityLogService.Insert(My.MyProject.Forms.FrmLoginWindow._userID, "UnitId: " + unitRowStorage.MiniUnitId.ToString() + " | MbId: " + mbRow.MiniBookingId.ToString(), "ASSIGN", "UNIT", "Storage Unit Source " + unitRowStorage.StorageUnitNumber + " assigned to booking " + mbRow.BookingNumber);
                            }
                        }
                    }
                }

                var cep = new CeresExcelPendingSync();
                cep.RecordId      = mbRow.MiniBookingId;
                cep.EmployeeId    = My.MyProject.Forms.FrmLoginWindow._userID;
                cep.SyncType      = "UNIT ASSIGNMENT";
                cep.ExtraInfo     = "";
                cep.CurrentStatus = "QUEUE";
                cep.QtyOfAttempts = 0;
                cep.SyncMessage   = "ADDED TO QUEUE";
                cep.CreatedAt     = DateAndTime.Now;
                CeresExcService.AddOrUpdate(cep);
            }

            shouldNotAssignList.Clear();
            assignBunifuButton1.Update();
            checkAsnButton();
        }