示例#1
0
        public void CloneReceiveForErrorCorrection(int confirmationStatusID, ReceivePallet receivePallet, ReceiveDoc receiveDoc, decimal pack, User user, int itemId, int storeId, int receiptId, int manufacturerId, ItemUnit itemUnit, DateTime convertedEthDate, bool changeExpiryDate = false, DateTime?ExpiryDate = null, bool changeBatchNo = false, string batchNo = null)
        {
            var newReceiveDoc = receiveDoc.Clone();

            newReceiveDoc.ItemID = itemId;

            if (changeBatchNo)
            {
                newReceiveDoc.BatchNo = batchNo;
            }

            if (changeExpiryDate)
            {
                if (ExpiryDate.HasValue)
                {
                    newReceiveDoc.ExpDate = ExpiryDate.Value;
                }
                else
                {
                    newReceiveDoc.SetColumnNull("ExpDate");
                }
            }

            newReceiveDoc.ManufacturerId = manufacturerId;
            newReceiveDoc.SetColumn("UnitID", itemUnit.ID);
            newReceiveDoc.Quantity          = pack * itemUnit.QtyPerUnit;
            newReceiveDoc.QuantityLeft      = pack * itemUnit.QtyPerUnit;
            newReceiveDoc.NoOfPack          = pack;
            newReceiveDoc.InvoicedNoOfPack  = pack;
            newReceiveDoc.QtyPerPack        = itemUnit.QtyPerUnit;
            newReceiveDoc.Date              = convertedEthDate;
            newReceiveDoc.ReceivedBy        = user.UserName;
            newReceiveDoc.StoreID           = storeId;
            newReceiveDoc.RefNo             = receiptId.ToString();
            newReceiveDoc.EurDate           = DateTimeHelper.ServerDateTime;
            newReceiveDoc.Confirmed         = true;
            newReceiveDoc.ConfirmedDateTime = DateTimeHelper.ServerDateTime;
            newReceiveDoc.ReturnedStock     = false;
            newReceiveDoc.ReceiptID         = receiptId;

            newReceiveDoc.Save();

            //Now Save the ReceiveDocConfirmation

            ReceiveDocConfirmation rdConf = new ReceiveDocConfirmation();

            rdConf.AddNew();
            rdConf.ReceiveDocID                = newReceiveDoc.ID;
            rdConf.ReceivedByUserID            = user.ID;
            rdConf.ReceiptConfirmationStatusID = confirmationStatusID;
            rdConf.Save();

            ReceivePallet newReceivePallet = new ReceivePallet();

            newReceivePallet.AddNew();
            newReceivePallet.ReceiveID         = newReceiveDoc.ID;
            newReceivePallet.ReceivedQuantity  = pack * itemUnit.QtyPerUnit;
            newReceivePallet.Balance           = pack * itemUnit.QtyPerUnit;
            newReceivePallet.ReservedStock     = 0;
            newReceivePallet.BoxSize           = 0;
            newReceivePallet.PalletID          = receivePallet.PalletID;
            newReceivePallet.IsOriginalReceive = true;
            if (!receivePallet.IsColumnNull("PalletLocationID"))
            {
                newReceivePallet.PalletLocationID = receivePallet.PalletLocationID;
            }
            newReceivePallet.Save();
        }
        public void CloneReceiveForErrorCorrection(int confirmationStatusID, ReceivePallet receivePallet, ReceiveDoc receiveDoc, decimal pack, User user, int itemId, int storeId, int receiptId, int manufacturerId, ItemUnit itemUnit, DateTime convertedEthDate, bool changeExpiryDate = false, DateTime? ExpiryDate = null, bool changeBatchNo = false, string batchNo = null)
        {
            var newReceiveDoc = receiveDoc.Clone();

            newReceiveDoc.ItemID = itemId;

            if (changeBatchNo)
            {
                newReceiveDoc.BatchNo = batchNo;
            }

            if (changeExpiryDate)
            {
                if (ExpiryDate.HasValue)
                {
                    newReceiveDoc.ExpDate = ExpiryDate.Value;
                }
                else
                {
                    newReceiveDoc.SetColumnNull("ExpDate");
                }
            }

            newReceiveDoc.ManufacturerId = manufacturerId;
            newReceiveDoc.SetColumn("UnitID", itemUnit.ID);
            newReceiveDoc.Quantity = pack * itemUnit.QtyPerUnit;
            newReceiveDoc.QuantityLeft = pack * itemUnit.QtyPerUnit;
            newReceiveDoc.NoOfPack = pack;
            newReceiveDoc.InvoicedNoOfPack = pack;
            newReceiveDoc.QtyPerPack = itemUnit.QtyPerUnit;
            newReceiveDoc.Date = convertedEthDate;
            newReceiveDoc.ReceivedBy = user.UserName;
            newReceiveDoc.StoreID = storeId;
            newReceiveDoc.RefNo = receiptId.ToString();
            newReceiveDoc.EurDate = DateTimeHelper.ServerDateTime;
            newReceiveDoc.Confirmed = true;
            newReceiveDoc.ConfirmedDateTime = DateTimeHelper.ServerDateTime;
            newReceiveDoc.ReturnedStock = false;
            newReceiveDoc.ReceiptID = receiptId;

            newReceiveDoc.Save();

            //Now Save the ReceiveDocConfirmation

            ReceiveDocConfirmation rdConf = new ReceiveDocConfirmation();
            rdConf.AddNew();
            rdConf.ReceiveDocID = newReceiveDoc.ID;
            rdConf.ReceivedByUserID = user.ID;
            rdConf.ReceiptConfirmationStatusID = confirmationStatusID;
            rdConf.Save();

            ReceivePallet newReceivePallet = new ReceivePallet();
            newReceivePallet.AddNew();
            newReceivePallet.ReceiveID = newReceiveDoc.ID;
            newReceivePallet.ReceivedQuantity = pack * itemUnit.QtyPerUnit;
            newReceivePallet.Balance = pack * itemUnit.QtyPerUnit;
            newReceivePallet.ReservedStock = 0;
            newReceivePallet.BoxSize = 0;
            newReceivePallet.PalletID = receivePallet.PalletID;
            newReceivePallet.IsOriginalReceive = true;
            if (!receivePallet.IsColumnNull("PalletLocationID"))
            {
                newReceivePallet.PalletLocationID = receivePallet.PalletLocationID;
            }
            newReceivePallet.Save();
        }