예제 #1
0
        public ActionResult SaveStockIn(string InvoiceNo, string Notes, List <StockInRequest> stockIns)
        {
            StockIn result      = new StockIn();
            StockIn FinalResult = new StockIn();

            //if (ModelState.IsValid)
            {
                foreach (var item in stockIns)
                {
                    result.InvoiceNo      = InvoiceNo;
                    result.Notes          = Notes;
                    result.IsActive       = true;
                    result.CreatedDate    = DateTime.Now;
                    result.ProductionDate = DateTime.Now;
                    result.CreatedBy      = CurrentSession.GetCurrentSession().UserName;
                    result.SupplierId     = 0;
                    result.ProductId      = item.ProductId;
                    result.BaleWeight     = 0;
                    result.WarehouseId    = item.WarehouseId;
                    result.SupplierId     = 1;
                    result.BaleQty        = item.Qty;
                    result.WeightInMon    = item.Qty;
                    FinalResult           = serviceStockIn.Save(result, Notes);
                }
            }

            return(Json(FinalResult, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult SaveStockIn(string InvoiceNo, string Notes, List <StockIn> stockIns)
        {
            StockIn result = new StockIn();
            var     brands = _brandService.GetAll();
            var     sizes  = _sizeService.GetAll();
            var     apis   = _apiService.GetAll();

            var stockOutInvoice = "";

            foreach (var item in stockIns)
            {
                var brand = brands.Where(a => a.Id == item.BrandId).FirstOrDefault();
                var size  = sizes.Where(a => a.Id == item.SizeId).FirstOrDefault();
                var api   = apis.Where(a => a.Id == item.APIId).FirstOrDefault();

                item.Notes       = Notes;
                item.InvoiceNo   = InvoiceNo;
                item.BrandName   = brand.BrandName;
                item.APIName     = item.APIName;
                item.SizeName    = size.Name;
                item.CreatedDate = DateTime.Now;
                item.CreatedBy   = CurrentSession.GetCurrentSession().UserName;
                if (!item.ProductionDate.HasValue)
                {
                    item.ProductionDate = DateTime.Now;
                }
                item.StockInPrice = item.Rate * item.BaleQty;
                serviceStockIn.Save(item);
                stockOutInvoice = item.StockOutInvoiceNo;
            }
            //stocOut Invoice Update
            var stockOuts = stockOutService.GetStockChallan(stockOutInvoice);

            foreach (var item in stockOuts)
            {
                item.AlreadyProcessed = true;
                item.UpdatedDate      = DateTime.Now;
                item.UpdatedBy        = CurrentSession.GetCurrentSession().UserName;
                stockOutService.Update(item, item.Id);
            }
            return(Json(true, JsonRequestBehavior.AllowGet));
        }