public void CreateDetailTransactionsForErrorCorrection(Order order, BLL.PickList picklist,
                                        Issue stvLog, int receiptPalletId, int receiptID, User user, DateTime convertedEthDate
                                        , int newItemId, int newUnitId, int newManufacturerId, decimal pickedPack
                                        , decimal Convertedpack, int confirmationStatusId, bool changeExpiryDate
                                        , DateTime? ExpiryDate, bool changeBatchNo, string batchNo)
        {
            //Load the ReceivePallet First From that we Get the Information that We need
            ReceivePallet receivePalletOriginal = new ReceivePallet();
            receivePalletOriginal.LoadByPrimaryKey(receiptPalletId);

            ReceiveDoc receiveDocOriginal = new ReceiveDoc();
            receiveDocOriginal.LoadByPrimaryKey(receivePalletOriginal.ReceiveID);

            //Load ItemUnit Detail for For ItemUnit Change;
            ItemUnit newItemUnit = new ItemUnit();
            newItemUnit.LoadByPrimaryKey(newUnitId);

              // Generate PicklistDetail With OrderDetail information
            PickListService pickListService = new PickListService();
            PickListDetail pickListDetail = pickListService.CreatePicklistDetailWithOrder(receiveDocOriginal, receivePalletOriginal, order, picklist,
                                                          pickedPack);
            // Generate IssueDoc from picklistDetail and substract the quantity from receiveDoc
            IssueService issueService = new IssueService();
            issueService.CreateIssueFromPicklist(pickListDetail, order, convertedEthDate, stvLog, user);

            if (Convertedpack > 0)
            {
                //duplicate The ReceiveDoc and ReceiptPallet
                ReceiveService receiveService = new ReceiveService();
                receiveService.CloneReceiveForErrorCorrection(confirmationStatusId, receivePalletOriginal, receiveDocOriginal
                                                                , Convertedpack, user, newItemId
                                                                , receiveDocOriginal.StoreID, receiptID
                                                                , newManufacturerId, newItemUnit, convertedEthDate,changeExpiryDate,ExpiryDate,changeBatchNo,batchNo);
            }
        }
Exemple #2
0
        private Issue HandleTransferBeforeReceipt(User user, int activityId, out Order order, out PickList picklist)
        {
            int orderType   = OrderType.CONSTANTS.ERROR_CORRECTION_TRANSFER;
            int paymentType = PaymentType.Constants.ERROR_CORRECTION;
            int orderStatus = OrderStatus.Constant.ISSUED;


            order = Order.GenerateOrder(null, orderType,
                                        orderStatus, activityId,
                                        paymentType, user.FullName, GeneralInfo.Current.InstitutionID, user.ID, 0);


            picklist = PickList.GeneratePickList(order.ID);

            var issueService = new IssueService();

            return(issueService.CreateSTVLog(null, false, picklist, order, null, activityId, false, user.ID));
        }
Exemple #3
0
        public void CreateDetailTransactionsForErrorCorrection(Order order, BLL.PickList picklist,
                                                               Issue stvLog, int receiptPalletId, int receiptID, User user, DateTime convertedEthDate
                                                               , int newItemId, int newUnitId, int newManufacturerId, decimal pickedPack
                                                               , decimal Convertedpack, int confirmationStatusId, bool changeExpiryDate
                                                               , DateTime?ExpiryDate, bool changeBatchNo, string batchNo)
        {
            //Load the ReceivePallet First From that we Get the Information that We need
            ReceivePallet receivePalletOriginal = new ReceivePallet();

            receivePalletOriginal.LoadByPrimaryKey(receiptPalletId);

            ReceiveDoc receiveDocOriginal = new ReceiveDoc();

            receiveDocOriginal.LoadByPrimaryKey(receivePalletOriginal.ReceiveID);

            //Load ItemUnit Detail for For ItemUnit Change;
            ItemUnit newItemUnit = new ItemUnit();

            newItemUnit.LoadByPrimaryKey(newUnitId);

            // Generate PicklistDetail With OrderDetail information
            PickListService pickListService = new PickListService();
            PickListDetail  pickListDetail  = pickListService.CreatePicklistDetailWithOrder(receiveDocOriginal, receivePalletOriginal, order, picklist,
                                                                                            pickedPack);
            // Generate IssueDoc from picklistDetail and substract the quantity from receiveDoc
            IssueService issueService = new IssueService();

            issueService.CreateIssueFromPicklist(pickListDetail, order, convertedEthDate, stvLog, user);

            if (Convertedpack > 0)
            {
                //duplicate The ReceiveDoc and ReceiptPallet
                ReceiveService receiveService = new ReceiveService();
                receiveService.CloneReceiveForErrorCorrection(confirmationStatusId, receivePalletOriginal, receiveDocOriginal
                                                              , Convertedpack, user, newItemId
                                                              , receiveDocOriginal.StoreID, receiptID
                                                              , newManufacturerId, newItemUnit, convertedEthDate, changeExpiryDate, ExpiryDate, changeBatchNo, batchNo);
            }
        }
        private void btnDispose_Click(object sender, EventArgs e)
        {
            if (!dxValidationProvider1.Validate()) return;

            TransferService transferService = new TransferService();
            IssueService issueService = new IssueService();

            if (XtraMessageBox.Show("Please Confirm that you want to dispose the selected items", "Warning", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                int activityID = Convert.ToInt32(glkActivity.EditValue);
                var dt = (DataView)grdSelectedExpiredItemsView.DataSource;

                Order order = OrderForDisposal(activityID);
                PickList picklist = PickList.GeneratePickList(order.ID);

                BLL.Issue stvLog = issueService.CreateSTVLog(null, false, picklist, order, null, activityID, false, CurrentContext.UserId);

                foreach (DataRow row in dt.Table.Rows)
                {
                    ReceiveDoc rd = new ReceiveDoc();
                    ReceivePallet rp = new ReceivePallet();

                    rd.LoadByPrimaryKey((int)row["ReceiveDocID"]);
                    rp.LoadByReceiveDocID((int)row["ReceiveDocID"]);

                    var picklistDetail = transferService.GeneratePickListDetail(rd, rp, order, picklist);
                    issueService.CreateIssueFromPicklist(picklistDetail, order, DateTime.Now, stvLog, CurrentContext.LoggedInUser);
                }

                HCMIS.Reports.Workflow.Activities.Disposal disposalPrintout = new HCMIS.Reports.Workflow.Activities.Disposal(glkActivity.Text, txtLicenseNo.Text, DateTime.Now, ((DataView)grdSelectedExpiredItemsView.DataSource).Table);
                disposalPrintout.PrintDialog();

                RefreshSelection();
                txtLicenseNo.ResetText();
            }
        }
        private Issue HandleTransferBeforeReceipt(User user, int activityId,out Order order,out PickList picklist)
        {
            int orderType = OrderType.CONSTANTS.ERROR_CORRECTION_TRANSFER;
            int paymentType = PaymentType.Constants.ERROR_CORRECTION;
            int orderStatus = OrderStatus.Constant.ISSUED;

            order = Order.GenerateOrder(null, orderType,
                                        orderStatus, activityId,
                                        paymentType, user.FullName,GeneralInfo.Current.InstitutionID, user.ID, 0);

            picklist = PickList.GeneratePickList(order.ID);

            var issueService = new IssueService();
            return issueService.CreateSTVLog(null, false, picklist, order, null, activityId, false, user.ID);
        }
        public void InitializeCommit(int userId,int warehouseID)
        {
            var user = new User();
            user.LoadByPrimaryKey(userId);
            InventoryCommitMemberInstance.User = user;

            // open transaction
            InventoryCommitMemberInstance.Transaction = TransactionMgr.ThreadTransactionMgr();

            // create the order here
            InventoryCommitMemberInstance.Order = Order.GenerateOrder(null, OrderType.CONSTANTS.INVENTORY,
                                                                        OrderStatus.Constant.ISSUED, ActivityID,
                                                                        PaymentType.Constants.INVENTORY, user.FullName,
                                                                        GeneralInfo.Current.InstitutionID, user.ID,0);

            // create the picklist here
            InventoryCommitMemberInstance.PickList = PickList.GeneratePickList(InventoryCommitMemberInstance.Order.ID);

            // create the issue header
            IssueService issueService = new IssueService();
            InventoryCommitMemberInstance.Issue = issueService.CreateSTVLog(null, false
                                                                                , InventoryCommitMemberInstance.PickList
                                                                                , InventoryCommitMemberInstance.Order
                                                                                , null, ActivityID, false, user.ID);

            // create the reciept header
            ReceiveService receiveService = new ReceiveService();
            InventoryCommitMemberInstance.Receipt = receiveService.CreateFakeReceiptWithInvoicePO(OrderType.CONSTANTS.INVENTORY
                                                                                    , ActivityID,GeneralInfo.Current.SupplierID, "Inventory"
                                                                                    , InventoryCommitMemberInstance.Issue.IDPrinted
                                                                                    , ReceiptType.CONSTANTS.BEGINNING_BALANCE, user.ID, ReceiptConfirmationStatus.Constants.RECEIVE_QUANTITY_CONFIRMED, warehouseID);
        }
        internal void Commit(DateTime ethiopianDate, BackgroundWorker backgroundWorker = null)
        {
            InventoryCommitMemberInstance.Transaction.BeginTransaction();
            //TODO: Create the order detail, pass the order id above this inventory object
            int count = 0;

            if (backgroundWorker != null)
            {
                backgroundWorker.ReportProgress(0, "Detail");
            }
            //Add the System Damaged quantity, System Sound Quantity and System Expired Quantity to generate this.
            decimal endingSoundBalance, endingDamagedBalance, endExpiredBalance;
            endingSoundBalance = !IsColumnNull("SystemSoundQuantity") ? SystemSoundQuantity : 0;
            endingDamagedBalance = !IsColumnNull("SystemDamagedQuantity") ? SystemDamagedQuantity : 0;
            endExpiredBalance = !IsColumnNull("SystemExpiredQuantity") ? SystemExpiredQuantity : 0;

            decimal endingTotalBalance = endingSoundBalance + endingDamagedBalance + endExpiredBalance;

            ItemUnit itemUnit = new ItemUnit();
            itemUnit.LoadByPrimaryKey(UnitID);
            if (IsColumnNull("ReceiveDocID") && IsColumnNull("DamagedReceiveDocID")) // This has been recently added to
            {

                if (endingTotalBalance > 0)
                {

                    OrderDetail.GenerateOrderDetail(UnitID, ActivityID, endingTotalBalance,
                                                    InventoryCommitMemberInstance.Order.ID, itemUnit.QtyPerUnit, ItemID);

                    //TODO: Get the receive doc details for this inventory object
                    ReceivePallet receivePallet = new ReceivePallet();
                    receivePallet.LoadForInventory(this);
                    receivePallet.Rewind();

                    while (!receivePallet.EOF)
                    {

                        //Review: New Code
                        PickListDetail pickListDetail = PickListDetail.GeneratePickListDetail(receivePallet,
                                                                                              InventoryCommitMemberInstance
                                                                                                  .PickList.ID,
                                                                                              Convert.ToDecimal(
                                                                                                  receivePallet.Balance));

                        //TODO: Create the issueDoc, pass the picklistdetail, orderid and picklist above
                        IssueService issueService = new IssueService();

                        IssueDoc issueDoc = issueService.CreateIssueFromPicklist(pickListDetail,
                                                                                 InventoryCommitMemberInstance.Order,
                                                                                 ethiopianDate,
                                                                                 InventoryCommitMemberInstance.Issue,
                                                                                 InventoryCommitMemberInstance.User);

                        //Link IssueDoc to InventoryTable
                        // Could have put it on the issueService method but it would have decrease the useablity
                        IssueDocInventory issueDocInventory = new IssueDocInventory();
                        issueDocInventory.AddNew();
                        issueDocInventory.InventoryID = ID;
                        issueDocInventory.IssueDocID = issueDoc.ID;
                        issueDocInventory.Save();

                        receivePallet.MoveNext();
                        count++;
                        if (backgroundWorker != null)
                        {
                            backgroundWorker.ReportProgress(
                                Convert.ToInt32((Convert.ToDecimal(count) / Convert.ToDecimal(receivePallet.RowCount)) * 100),
                                "Detail");
                        }
                    }

                }
                //TODO: Create the receive (use the inventory object itself)
                ReceiveService receiveService = new ReceiveService();
                if (!IsColumnNull("InventorySoundQuantity") && InventorySoundQuantity > 0)
                {
                    ReceiveDoc receiveDoc = receiveService.CreateInventoryReceive(this,
                                                                                  InventoryCommitMemberInstance.Receipt.
                                                                                      ID, QuantityType.Sound,
                                                                                  ethiopianDate,
                                                                                  InventoryCommitMemberInstance.User);
                    ReceiveDocID = receiveDoc.ID;
                }

                if (!IsColumnNull("InventoryExpiredQuantity") && InventoryExpiredQuantity > 0)
                {
                    ReceiveDoc receiveDoc = receiveService.CreateInventoryReceive(this,
                                                                                  InventoryCommitMemberInstance.Receipt.
                                                                                      ID, QuantityType.Expired,
                                                                                  ethiopianDate,
                                                                                  InventoryCommitMemberInstance.User);
                    ReceiveDocID = receiveDoc.ID;
                }

                if (!IsColumnNull("InventoryDamagedQuantity") && InventoryDamagedQuantity > 0)
                {
                    ReceiveDoc receiveDoc = receiveService.CreateInventoryReceive(this,
                                                                                  InventoryCommitMemberInstance.Receipt.
                                                                                      ID, QuantityType.Damaged,
                                                                                  ethiopianDate,
                                                                                  InventoryCommitMemberInstance.User);
                    DamagedReceiveDocID = receiveDoc.ID;
                }

                if (backgroundWorker != null)
                {
                    backgroundWorker.ReportProgress(100, "Detail");
                }

            }
            else
            {

                if (!IsColumnNull("ReceiveDocID"))
                {

                    ReceiveDoc receiveDoc = new ReceiveDoc();
                    receiveDoc.LoadByPrimaryKey(ReceiveDocID);
                    receiveDoc.ChangeQuantity(!IsColumnNull("InventorySoundQuantity") ? InventorySoundQuantity
                                                            : !IsColumnNull("InventoryExpiredQuantity") ? InventoryExpiredQuantity
                                                                                        : 0);

                }

                if (!IsColumnNull("DamagedReceiveDocID"))
                {
                    ReceiveDoc receiveDoc = new ReceiveDoc();
                    receiveDoc.LoadByPrimaryKey(DamagedReceiveDocID);
                    receiveDoc.ChangeQuantity(InventoryDamagedQuantity);
                }
            }
            IsDraft = false;
            Save();
            InventoryCommitMemberInstance.Transaction.CommitTransaction();
        }