コード例 #1
0
        //Import
        public ActionResult Import()
        {
            return View();

            this.purchaseInvoiceService.UserID = this.purchaseOrderService.UserID;
            this.goodsReceiptService.UserID = this.purchaseOrderService.UserID;

            PurchaseOrderDTO purchaseOrderDTO = null;
            CommoditiesApiController commoditiesApi = new CommoditiesApiController(this.commodityRepository);

            int warehouseID = 0; int commodityCategoryID = 0; int countRow = 0;

            var purchaseOrderEntity = this.purchaseOrderRepository.GetEntity();
            if (purchaseOrderEntity != null) return View(); //Check to exit if not empty

            ICollection<Inventory_30_06_33> Inventory_30_06_33s = this.purchaseOrderRepository.GetEntities<Inventory_30_06_33>().OrderBy(o => o.WarehouseID).ThenBy(ob => ob.SupplierID).ToList();
            foreach (Inventory_30_06_33 Inventory_30_06_33 in Inventory_30_06_33s)
            {
                countRow = countRow + 1;

                if (warehouseID != (int)Inventory_30_06_33.WarehouseID || commodityCategoryID != (int)Inventory_30_06_33.SupplierID || countRow > 55)
                {
                    if (purchaseOrderDTO != null) this.SaveInit3006(purchaseOrderDTO, warehouseID);

                    commodityCategoryID = (int)Inventory_30_06_33.SupplierID;
                    warehouseID = (int)Inventory_30_06_33.WarehouseID;
                    countRow = 0;

                    purchaseOrderDTO = new PurchaseOrderDTO();
                    purchaseOrderDTO.EntryDate = new DateTime(2015, 06, 30);
                    purchaseOrderDTO.SupplierID = 1;
                    purchaseOrderDTO.PriceTermID = 1;
                    purchaseOrderDTO.PaymentTermID = 1;
                    purchaseOrderDTO.PreparedPersonID = this.purchaseOrderService.UserID;
                    purchaseOrderDTO.ApproverID = this.purchaseOrderService.UserID;
                }

                PurchaseOrderDetailDTO purchaseOrderDetailDTO = new PurchaseOrderDetailDTO();
                purchaseOrderDetailDTO.CommodityID = Inventory_30_06_33.CommodityID;
                purchaseOrderDetailDTO.CommodityCode = Inventory_30_06_33.Description;
                purchaseOrderDetailDTO.CommodityName = Inventory_30_06_33.DescriptionOfficial;
                purchaseOrderDetailDTO.CommodityTypeID = (int)Inventory_30_06_33.ItemTypeID;

                purchaseOrderDetailDTO.ChassisCode = Inventory_30_06_33.SerialNo.Trim() == "" ? null : Inventory_30_06_33.SerialNo.Trim();
                purchaseOrderDetailDTO.EngineCode = Inventory_30_06_33.FixedAsset.Trim() == "" ? null : Inventory_30_06_33.FixedAsset.Trim();
                purchaseOrderDetailDTO.ColorCode = Inventory_30_06_33.ColorCode.Trim() == "" ? null : Inventory_30_06_33.ColorCode.Trim();

                purchaseOrderDetailDTO.Origin = Inventory_30_06_33.WHInputID.ToString();
                purchaseOrderDetailDTO.Packing = Inventory_30_06_33.WHInputDate.ToString();

                purchaseOrderDetailDTO.Quantity = (decimal)Inventory_30_06_33.QuantityEnd;
                purchaseOrderDetailDTO.UnitPrice = (decimal)Inventory_30_06_33.UPriceNMDInventory;
                purchaseOrderDetailDTO.VATPercent = 10;
                purchaseOrderDetailDTO.GrossPrice = Math.Round(purchaseOrderDetailDTO.UnitPrice * (1 + purchaseOrderDetailDTO.VATPercent / 100), 0);

                purchaseOrderDetailDTO.Amount = Math.Round(purchaseOrderDetailDTO.Quantity * purchaseOrderDetailDTO.UnitPrice, 0);
                purchaseOrderDetailDTO.GrossAmount = Math.Round(purchaseOrderDetailDTO.Quantity * purchaseOrderDetailDTO.GrossPrice, 0);
                purchaseOrderDetailDTO.VATAmount = Math.Round(purchaseOrderDetailDTO.GrossAmount - purchaseOrderDetailDTO.Amount, 0);

                purchaseOrderDetailDTO.QuantityInvoice = 0;

                purchaseOrderDTO.TotalQuantity = Math.Round(purchaseOrderDTO.TotalQuantity + purchaseOrderDetailDTO.Quantity, 0);
                purchaseOrderDTO.TotalAmount = Math.Round(purchaseOrderDTO.TotalAmount + purchaseOrderDetailDTO.Amount, 0);
                purchaseOrderDTO.TotalVATAmount = Math.Round(purchaseOrderDTO.TotalVATAmount + purchaseOrderDetailDTO.VATAmount, 0);
                purchaseOrderDTO.TotalGrossAmount = Math.Round(purchaseOrderDTO.TotalGrossAmount + purchaseOrderDetailDTO.GrossAmount, 0);

                purchaseOrderDTO.GetDetails().Add(purchaseOrderDetailDTO);

            }

            if (purchaseOrderDTO != null) this.SaveInit3006(purchaseOrderDTO, warehouseID);

            return View();
        }
コード例 #2
0
        //Import
        public ActionResult Import072015()
        {
            return View();
            return View();
            return View();

            this.purchaseInvoiceService.UserID = this.purchaseOrderService.UserID;
            this.goodsReceiptService.UserID = this.purchaseOrderService.UserID;

            PurchaseOrderDTO purchaseOrderDTO = null;
            CommoditiesApiController commoditiesApi = new CommoditiesApiController(this.commodityRepository);

            string loHANG = ""; int countRow = 0; int warehouseID = 0;

            ICollection<RAWDATA_07_2015> RAWDATA_07_2015s = this.purchaseOrderRepository.GetEntities<RAWDATA_07_2015>().Where(w => w.WarehouseID == this.purchaseOrderService.LocationID).OrderBy(o => o.LOHANG).ToList();
            foreach (RAWDATA_07_2015 RAWDATA_07_2015 in RAWDATA_07_2015s)
            {
                countRow = countRow + 1;

                if (loHANG != RAWDATA_07_2015.LOHANG || countRow > 30)
                {
                    if (purchaseOrderDTO != null) this.SaveInit3006(purchaseOrderDTO, warehouseID); //Luu y: Moi lan RUN cai foreach nay: la chi load THE SAME WarehouseID, VI VAY, CAI RAWDATA_07_2015.WarehouseID LUON GIONG NHAU

                    loHANG = RAWDATA_07_2015.LOHANG;
                    countRow = 0;

                    purchaseOrderDTO = new PurchaseOrderDTO();
                    purchaseOrderDTO.EntryDate = RAWDATA_07_2015.NGAYGIAO;
                    purchaseOrderDTO.SupplierID = 1;
                    purchaseOrderDTO.PriceTermID = 1;
                    purchaseOrderDTO.PaymentTermID = 1;
                    purchaseOrderDTO.PreparedPersonID = this.purchaseOrderService.UserID;
                    purchaseOrderDTO.ApproverID = this.purchaseOrderService.UserID;

                    purchaseOrderDTO.ConfirmReference = RAWDATA_07_2015.LOHANG + RAWDATA_07_2015.LOHANG != RAWDATA_07_2015.DONHANG ? " [" + RAWDATA_07_2015.DONHANG + "]" : "";
                }

                PurchaseOrderDetailDTO purchaseOrderDetailDTO = new PurchaseOrderDetailDTO();
                warehouseID = RAWDATA_07_2015.WarehouseID;
                purchaseOrderDetailDTO.CommodityID = (int)RAWDATA_07_2015.CommodityID;
                purchaseOrderDetailDTO.CommodityCode = RAWDATA_07_2015.MAHANG;
                purchaseOrderDetailDTO.CommodityName = RAWDATA_07_2015.TEN_VN;
                purchaseOrderDetailDTO.CommodityTypeID = (int)RAWDATA_07_2015.CommodityTypeID;

                purchaseOrderDetailDTO.ChassisCode = RAWDATA_07_2015.SOKHUNG == null ? null : (RAWDATA_07_2015.SOKHUNG.Trim() == "" ? null : RAWDATA_07_2015.SOKHUNG.Trim());
                purchaseOrderDetailDTO.EngineCode = RAWDATA_07_2015.SOMAY == null ? null : (RAWDATA_07_2015.SOMAY.Trim() == "" ? null : RAWDATA_07_2015.SOMAY.Trim());
                purchaseOrderDetailDTO.ColorCode = RAWDATA_07_2015.MAUXE == null ? null : (RAWDATA_07_2015.MAUXE.Trim() == "" ? null : RAWDATA_07_2015.MAUXE.Trim());

                purchaseOrderDetailDTO.Quantity = (decimal)RAWDATA_07_2015.SOLUONG;
                purchaseOrderDetailDTO.UnitPrice = (decimal)RAWDATA_07_2015.DONGIA;
                purchaseOrderDetailDTO.VATPercent = 10;
                purchaseOrderDetailDTO.GrossPrice = Math.Round(purchaseOrderDetailDTO.UnitPrice * (1 + purchaseOrderDetailDTO.VATPercent / 100), 0);

                purchaseOrderDetailDTO.Amount = Math.Round(purchaseOrderDetailDTO.Quantity * purchaseOrderDetailDTO.UnitPrice, 0);
                purchaseOrderDetailDTO.GrossAmount = Math.Round(purchaseOrderDetailDTO.Quantity * purchaseOrderDetailDTO.GrossPrice, 0);
                purchaseOrderDetailDTO.VATAmount = Math.Round(purchaseOrderDetailDTO.GrossAmount - purchaseOrderDetailDTO.Amount, 0);

                purchaseOrderDetailDTO.QuantityInvoice = 0;

                purchaseOrderDTO.TotalQuantity = Math.Round(purchaseOrderDTO.TotalQuantity + purchaseOrderDetailDTO.Quantity, 0);
                purchaseOrderDTO.TotalAmount = Math.Round(purchaseOrderDTO.TotalAmount + purchaseOrderDetailDTO.Amount, 0);
                purchaseOrderDTO.TotalVATAmount = Math.Round(purchaseOrderDTO.TotalVATAmount + purchaseOrderDetailDTO.VATAmount, 0);
                purchaseOrderDTO.TotalGrossAmount = Math.Round(purchaseOrderDTO.TotalGrossAmount + purchaseOrderDetailDTO.GrossAmount, 0);

                purchaseOrderDTO.GetDetails().Add(purchaseOrderDetailDTO);

            }

            if (purchaseOrderDTO != null) this.SaveInit3006(purchaseOrderDTO, warehouseID);

            return View();
        }