Example #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            WarehouseStock stock = ((WarehouseStock)gridStock.SelectedRows[0].Tag);

            if (stock == null)
            {
                return;
            }

            int count;

            if (!Int32.TryParse(tbNumber.Text, out count) || count < 0)
            {
                return;
            }

            if (tbNumber.Tag == null)
            {
                return;
            }

            int originalCount = (int)tbNumber.Tag;

            if (MessageBox.Show(this, "Frissíteni akarja a cikk \"" + stock.WarehouseName + "\" raktárban lévő számát?\nEredeti darabszám: " + originalCount.ToString() +
                                "\nÚj darabszám: " + count.ToString(),
                                "Módosítás",
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question) == DialogResult.Yes)
            {
                Stock stockRow = Global.Database.SelectOne <Stock>("stock", new Dictionary <string, object>()
                {
                    { "ItemID", _stockItemID },
                    { "WarehouseID", stock.WarehouseID }
                });

                if (stockRow == null)
                {
                    Error("Hiba az adatbázis elérése közben!", "Hiba");
                    return;
                }

                stockRow.Count = count;

                if (Global.Database.Update <Stock>("stock", stockRow))
                {
                    stock.ItemCount = count;

                    DataGridManager.UpdateRow <WarehouseStock>(gridStock.SelectedRows[0], stock);

                    DataChanged = true;

                    tbNumber.Tag      = count;
                    btnUpdate.Enabled = false;
                }
                else
                {
                    Error("Hiba az adat módosítása közben!", "Hiba");
                }
            }
        }
Example #2
0
        public void WhenSerializingProductStocks_AnStockWithCorrectProductsShouldBeReturned()
        {
            List <DepartmentStock> departmentStocks = new List <DepartmentStock>();
            var electronicProducts = new Product[] {
                new Phone("iphone12", "productowner", 800, "cardinal", "Apple", "IPhone"),
                new Laptop("dell15", "productOwner", 3000, "cardinal", "dell", "dellbrand", (decimal)1.2, new Dictionary <string, string>())
            };
            var departmentStock = new DepartmentStock("*****@*****.**", "electronics", electronicProducts);

            departmentStocks.Add(departmentStock);


            WarehouseStock expected = new WarehouseStock("Store Name", 2, departmentStocks);

            JsonSerializerOptions options = new JsonSerializerOptions();

            var descriminatorTypeMap = new Dictionary <string, Func <string, Type> >();

            descriminatorTypeMap.Add(typeof(Book).FullName, (descriminator) => typeof(Book));
            descriminatorTypeMap.Add(typeof(Phone).FullName, (descriminator) => typeof(Phone));
            descriminatorTypeMap.Add(typeof(Laptop).FullName, (descriminator) => typeof(Laptop));
            options.Converters.Add(new PolymorphicJsonConverter <Product>(descriminatorTypeMap, "$type"));

            var serialized = System.Text.Json.JsonSerializer.Serialize(expected, options);

            Assert.NotNull(serialized);

            WarehouseStock actual = System.Text.Json.JsonSerializer.Deserialize <WarehouseStock>(serialized, options);

            Assert.IsType <Phone>(actual.Departments.ElementAt(0).Products.ElementAt(0));
            Assert.IsType <Laptop>(actual.Departments.ElementAt(0).Products.ElementAt(1));
        }
        public void DeleteStock(int WarehouseStockID)
        {
            WarehouseStock _dbEntry = _context.WarehouseStocks.Find(WarehouseStockID);

            _dbEntry.Enabled = false;
            _context.SaveChanges();
        }
        public ActionResult AddProduct(WarehouseProductJoin warehouseProductJoin)
        {
            var products = new WarehouseProduct();
            var stock    = new WarehouseStock();

            products.PId         = warehouseProductJoin.Wproducts.PId.ToUpper();
            products.Name        = warehouseProductJoin.Wproducts.Name;
            products.Price       = warehouseProductJoin.Wproducts.Price;
            products.Type        = Request.Form["PType"];
            products.Category    = Request.Form["PCategory"];
            products.Description = warehouseProductJoin.Wproducts.Description;

            stock.ProductID = warehouseProductJoin.Wproducts.PId;
            stock.Quantity  = warehouseProductJoin.WStock.Quantity;
            stock.ShelveNo  = warehouseProductJoin.WStock.ShelveNo;

            try
            {
                _context.WarehouseProducts.Add(products);
                _context.WarehouseStocks.Add(stock);
                _context.SaveChanges();
            }
            catch
            {
                return(View());
            }
            return(Redirect("~/Warehouse/Index"));
        }
        public ActionResult Edit(string id)
        {
            var product = _context.WarehouseProducts.SingleOrDefault(p => p.PId == id);
            var stock   = _context.WarehouseStocks.SingleOrDefault(s => s.ProductID == id);

            if (product == null)
            {
                return(HttpNotFound());
            }
            var warehouseProductJoin = new WarehouseProductJoin();

            if (stock == null)
            {
                int quantity = 0;
                warehouseProductJoin.Wproducts = product;
                WarehouseStock warehouseStock = new WarehouseStock();
                warehouseStock.Quantity     = quantity;
                warehouseStock.ShelveNo     = "N/A";
                warehouseProductJoin.WStock = warehouseStock;
            }
            else
            {
                warehouseProductJoin.Wproducts = product;
                warehouseProductJoin.WStock    = stock;
            }
            return(View(warehouseProductJoin));
        }
        //库存新增
        public PurchaseContentGridRowModel(string mrPurDate, WarehouseStock StockItem)
        {
            cell    = new string[26];
            cell[0] = "";
            cell[1] = "0";
            cell[2] = "0";
            cell[3] = StockItem.WarehouseStockID.ToString();
            cell[4] = StockItem.Name;
            int _qty = StockItem.PlanQty - StockItem.Quantity > 0? StockItem.PlanQty - StockItem.Quantity:0;

            cell[5]  = _qty.ToString();
            cell[6]  = StockItem.MaterialNumber;
            cell[7]  = StockItem.Specification;
            cell[8]  = StockItem.Material;
            cell[9]  = "";
            cell[10] = "";
            cell[11] = "";
            cell[12] = StockItem.SupplierName;
            cell[13] = "false";

            cell[14] = "新建";
            cell[15] = "0";
            cell[16] = mrPurDate;
            cell[17] = "XX";
            cell[18] = "";
            cell[19] = "";
            cell[20] = "";
            cell[21] = "";
            cell[22] = "";
            cell[23] = "";
            cell[24] = "";
            cell[25] = "0";
        }
Example #7
0
        protected override string[] FormatExportRecord(object obj)
        {
            string factoryCode, warehouseCode, itemCode, warehouseQty, lingqty, openQty, actualQty, cycleCode;

            if (obj is WarehouseStock)
            {
                WarehouseStock item = (WarehouseStock)obj;
                factoryCode = item.FactoryCode;
                //segmentCode = item.SegmentCode;
                warehouseCode = item.WarehouseCode;
                itemCode      = item.ItemCode;
                openQty       = Math.Round(Convert.ToDecimal(item.OpenQty), 2).ToString();
                actualQty     = "";
                cycleCode     = "";
                warehouseQty  = "";
                lingqty       = "";
            }
            else
            {
                WarehouseCycleCountDetail item = (WarehouseCycleCountDetail)obj;
                factoryCode = item.FactoryCode;
                //segmentCode = item.SegmentCode;
                warehouseCode = item.WarehouseCode;
                itemCode      = item.ItemCode;
                warehouseQty  = Math.Round(Convert.ToDecimal(item.Qty), 2).ToString();                          //离散数量
                lingqty       = Math.Round(Convert.ToDecimal(item.LineQty), 2).ToString();                      //在制品虚拆数量
                openQty       = Math.Round(Convert.ToDecimal(item.Warehouse2LineQty), 2).ToString();            //账面数量 = 离散数量 + 在制品虚拆数量
                actualQty     = Math.Round(Convert.ToDecimal(item.PhysicalQty), 2).ToString();
                cycleCode     = item.CycleCountCode;
            }

            string[] strArr = new string[] {};
            if (isWHCycle)
            {
                strArr =
                    new string[] { factoryCode,
                                   //segmentCode,
                                   warehouseCode,
                                   itemCode,
                                   GetItemName(itemCode),
                                   warehouseQty,                                                        //离散数量
                                   lingqty,                                                             //在制品虚拆数量
                                   openQty,                                                             //账面数量 = 离散数量 + 在制品虚拆数量
                                   "" };
            }
            else
            {
                strArr =
                    new string[] { factoryCode,
                                   //segmentCode,
                                   warehouseCode,
                                   itemCode,
                                   GetItemName(itemCode),
                                   openQty,
                                   "" };
            }
            return(strArr);
        }
Example #8
0
        public BulkUpdateResult Update(List <BulkWarehouseStockUpdateDTO> dtoList)
        {
            var warehouseStocks = _statelessSession.Query <WarehouseStock>()
                                  .Where(stock => stock.Site.Id == _site.Id && !stock.IsDeleted &&
                                         stock.ProductVariant != null &&
                                         stock.ProductVariant.SKU != null &&
                                         stock.Warehouse != null && !stock.ProductVariant.IsDeleted)
                                  .Fetch(stock => stock.ProductVariant)
                                  .Fetch(stock => stock.Warehouse)
                                  .ToList();
            var dictionary = warehouseStocks
                             .GroupBy(stock => stock.ProductVariant.SKU)
                             .ToDictionary(stocks => stocks.Key,
                                           stocks => stocks.ToDictionary(stock => stock.Warehouse.Id, stock => stock));

            HashSet <BulkWarehouseStockUpdateDTO> dtos = dtoList.ToHashSet();
            var stockToUpdate = new HashSet <WarehouseStock>();

            using (ITransaction transaction = _statelessSession.BeginTransaction())
            {
                foreach (BulkWarehouseStockUpdateDTO dto in dtos)
                {
                    if (!dictionary.ContainsKey(dto.SKU) || !dictionary[dto.SKU].ContainsKey(dto.WarehouseId))
                    {
                        continue;
                    }

                    WarehouseStock stock = dictionary[dto.SKU][dto.WarehouseId];
                    if (stock.StockLevel == dto.StockLevel)
                    {
                        continue;
                    }

                    stock.StockLevel = dto.StockLevel;
                    stockToUpdate.Add(stock);
                }
                foreach (WarehouseStock stock in stockToUpdate)
                {
                    _statelessSession.Update(stock);
                }
                transaction.Commit();
            }

            return(new BulkUpdateResult
            {
                IsSuccess = true,
                Messages = new List <string>
                {
                    string.Format(
                        _stringResourceProvider.GetValue("Bulk Stock Update - number processed", "{0} items processed"),
                        dtos.Count()),
                    string.Format(
                        _stringResourceProvider.GetValue("Bulk Stock Update - number updated", "{0} items updated"),
                        stockToUpdate.Count)
                }
            });
        }
        public int EleInStock(string Name)
        {
            WarehouseStock _stock = new WarehouseStock();

            _stock.Name          = Name;
            _stock.Quantity      = 1;
            _stock.Specification = "";
            _stock.Enabled       = true;
            _context.WarehouseStocks.Add(_stock);
            _context.SaveChanges();
            return(_stock.WarehouseStockID);
        }
Example #10
0
        // GET api/status/{warehouseId}
        public InboundOrderResponse Get(int warehouseId)
        {
            log.Info("orderIn for warehouseId: " + warehouseId);
            var operationsManager = new Employee(employeeRepository.GetOperationsManager(warehouseId));

            //date time log before
            log.Debug(String.Format("Found operations manager: {0}", operationsManager));
            var warehouseHeldItems = stockRepository.GetStockByWarehouseId(warehouseId);//gets warehouseID
            //datetime after

            Dictionary <Company, List <InboundOrderLine> > orderlinesByCompany = new Dictionary <Company, List <InboundOrderLine> >();

            foreach (var item in warehouseHeldItems)
            {
                var warehouseStock = new WarehouseStock(item);

                if (warehouseStock.Held < warehouseStock.LowerThresh && !warehouseStock.Discontinued)
                {
                    var orderQuantity = Math.Max(item.lowerThresh * 3 - item.held, warehouseStock.MinimumOrderQuantity);

                    if (!orderlinesByCompany.ContainsKey(warehouseStock.Company))
                    {
                        orderlinesByCompany.Add(warehouseStock.Company, new List <InboundOrderLine>());
                    }

                    orderlinesByCompany[warehouseStock.Company].Add(
                        new InboundOrderLine()
                    {
                        gtin     = warehouseStock.CompanyId,
                        name     = warehouseStock.ProductName,
                        quantity = orderQuantity
                    });
                }
            }

            log.Debug(String.Format("Constructed order lines: {0}", orderlinesByCompany));

            var orderSegments = orderlinesByCompany.Select(ol => new OrderSegment()
            {
                OrderLines = ol.Value,
                Company    = ol.Key
            });

            log.Info("Constructed inbound order");

            return(new InboundOrderResponse()
            {
                OperationsManager = operationsManager,
                WarehouseId = warehouseId,
                OrderSegments = orderSegments.ToList()
            });
        }
Example #11
0
 private void LoadGrid()
 {
     try
     {
         DataSet ds    = new DataSet();
         String  query = "EXEC Get_Stock_Report '',''";
         ds = dba.GetDataSet(query, "ConnDB230");
         WarehouseStock.DataSource = ds;
         WarehouseStock.DataBind();
     }
     catch (Exception ex)
     { throw ex; }
 }
Example #12
0
        private void UpdateManagePanel(bool enabled)
        {
            panelManage.Enabled = enabled;

            if (panelManage.Enabled)
            {
                WarehouseStock stock = ((WarehouseStock)gridStock.SelectedRows[0].Tag);

                lblWarehouse.Text = String.Format((string)lblWarehouse.Tag, stock.WarehouseName);

                tbNumber.Tag  = stock.ItemCount;
                tbNumber.Text = stock.ItemCount.ToString();
            }
        }
Example #13
0
        protected override string[] FormatExportRecord(object obj)
        {
            WarehouseStock item = (WarehouseStock)obj;

            string[] strValue = new string[] { item.FactoryCode,
                                               //item.SegmentCode,
                                               item.WarehouseCode,
                                               item.ItemCode,
                                               item.EAttribute1,
                                               item.OpenQty.ToString(),
                                               IsAllowed(item) };
            item = null;
            return(strValue);
        }
Example #14
0
        //选择来源工厂、工段,查询所有仓库

        /*
         * private void FillWarehouseFrom(object sender, System.EventArgs e)
         * {
         *      this.drpWarehouseCodeQuery.Items.Clear();
         *      if (this.drpFactoryCodeQuery.SelectedValue == string.Empty)
         *      {
         *              this.drpSegmentCodeQuery.SelectedValue = string.Empty;
         *      }
         *      else
         *              this.FillWarehouse(this.drpFactoryCodeQuery, this.drpSegmentCodeQuery, this.drpWarehouseCodeQuery);
         * }
         * private void FillWarehouse(DropDownList drpFactory, DropDownList drpSeg, DropDownList drp)
         * {
         *      if(_facade==null){_facade = new WarehouseFacade(base.DataProvider);}
         *      string factoryCode = drpFactory.SelectedValue;
         *      string segCode = drpSeg.SelectedValue;
         *      object[] objs = this._facade.GetWarehouseByFactorySeg(segCode, factoryCode, true);
         *      drp.Items.Clear();
         *      drp.Items.Add("");
         *      if (objs != null)
         *      {
         *              for (int i = 0; i < objs.Length; i++)
         *              {
         *                      Warehouse wh = (Warehouse)objs[i];
         *                      drp.Items.Add(new ListItem(wh.WarehouseCode, wh.WarehouseCode));
         *                      wh = null;
         *              }
         *      }
         *      objs = null;
         * }
         */
        #endregion


        #region Export
        protected override string[] FormatExportRecord(object obj)
        {
            WarehouseStock stock = (WarehouseStock)obj;

            string[] strArr =
                new string[] { stock.FactoryCode,
                               //stock.SegmentCode,
                               stock.WarehouseCode,
                               stock.ItemCode,
                               GetItemName(stock.ItemCode),
                               stock.OpenQty.ToString() };
            stock = null;
            return(strArr);
        }
Example #15
0
        public async Task <IActionResult> OnPostExportAsync(int currentPage, int pageSize, string searchString, string sortOrder)
        {
            WarehouseStock = await InitiateView(currentPage, pageSize, searchString, sortOrder);

            string   sWebRootFolder = _hostingEnvironment.WebRootPath;
            string   sFileName      = @"Warehouse Stock Data.xlsx";
            string   URL            = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, sFileName);
            FileInfo file           = new FileInfo(Path.Combine(sWebRootFolder, sFileName));
            var      memory         = new MemoryStream();

            using (var fs = new FileStream(Path.Combine(sWebRootFolder, sFileName), FileMode.Create, FileAccess.Write))
            {
                ExcelPackage package = new ExcelPackage();
                package.Workbook.Worksheets.Add("Warehouse Stock");
                ExcelWorksheet categoriesSheet = package.Workbook.Worksheets["Warehouse Stock"];
                using (var range = categoriesSheet.Cells["A1:F1"])
                {
                    range.Style.Font.Bold        = true;
                    range.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
                    range.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(23, 121, 186));
                    range.Style.Font.Color.SetColor(Color.White);
                }
                categoriesSheet.Cells[1, 1].Value = "Id";
                categoriesSheet.Cells[1, 2].Value = "Stock Name";
                categoriesSheet.Cells[1, 3].Value = "Unit";
                categoriesSheet.Cells[1, 4].Value = "Price";
                categoriesSheet.Cells[1, 5].Value = "In Stock";
                categoriesSheet.Cells[1, 6].Value = "Supplier";
                for (int r = 0; r < WarehouseStock.Count(); r++)
                {
                    categoriesSheet.Cells[r + 2, 1].Value = WarehouseStock.ToList()[r].Id;
                    categoriesSheet.Cells[r + 2, 2].Value = WarehouseStock.ToList()[r].StockName;
                    categoriesSheet.Cells[r + 2, 3].Value = WarehouseStock.ToList()[r].Unit;
                    categoriesSheet.Cells[r + 2, 4].Value = WarehouseStock.ToList()[r].Price;
                    categoriesSheet.Cells[r + 2, 5].Value = WarehouseStock.ToList()[r].InStock;
                    categoriesSheet.Cells[r + 2, 6].Value = _context.Suppliers.FirstOrDefault(s => s.Id == WarehouseStock.ToList()[r].SupplierId).Name;
                    categoriesSheet.Cells[1, 1, 1, 6].AutoFitColumns();
                }

                package.SaveAs(fs);
                package.Dispose();
            }
            using (var stream = new FileStream(Path.Combine(sWebRootFolder, sFileName), FileMode.Open))
            {
                await stream.CopyToAsync(memory);
            }
            memory.Position           = 0;
            TempData["StatusMessage"] = "Warehouse stock list succcessfully exported to file " + sFileName + ".";
            return(File(memory, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", sFileName));
        }
Example #16
0
        private void CheckEmptyStock(WarehouseStock stock, Item item)
        {
            if (!(stock is EmptyWarehouseStock))
            {
                return;
            }

            Stock newEmptyStock = new Stock()
            {
                Warehouse = stock.WarehouseID,
                ItemID    = item.ID,
                Count     = 0
            };

            Global.Database.InsertInto <Stock>("stock", newEmptyStock);
        }
Example #17
0
        protected override Infragistics.WebUI.UltraWebGrid.UltraGridRow GetGridRow(object obj)
        {
            WarehouseStock stock = (WarehouseStock)obj;

            Infragistics.WebUI.UltraWebGrid.UltraGridRow row =
                new Infragistics.WebUI.UltraWebGrid.UltraGridRow(
                    new object[] {
                stock.FactoryCode,
                //stock.SegmentCode,
                stock.WarehouseCode,
                stock.ItemCode,
                GetItemName(stock.ItemCode),
                Math.Round(stock.OpenQty, 2),
                ""
            });
            stock = null;
            return(row);
        }
Example #18
0
        protected override Infragistics.WebUI.UltraWebGrid.UltraGridRow GetGridRow(object obj)
        {
            WarehouseStock ws = (WarehouseStock)obj;

            try
            {
                int iCode = int.Parse(ws.WarehouseCode);
                ws.WarehouseCode = new string('0', 4 - ws.WarehouseCode.Length) + ws.WarehouseCode;
            }
            catch
            {}
            return(new Infragistics.WebUI.UltraWebGrid.UltraGridRow(
                       new object[] { "",
                                      ws.FactoryCode,
                                      //ws.SegmentCode,
                                      ws.WarehouseCode,
                                      ws.ItemCode,
                                      ws.EAttribute1,
                                      ws.OpenQty,
                                      IsAllowed(ws) }));
        }
        private void btnShip_Click(object sender, System.EventArgs e)
        {
            if (ValidateInput())
            {
                Item           item      = ((Item)cbItem.Items[cbItem.SelectedIndex]);
                WarehouseStock warehouse = ((WarehouseStock)cbWarehouse.Items[cbWarehouse.SelectedIndex]);
                if (warehouse is EmptyWarehouseStock)
                {
                    Stock newEmptyStock = new Stock()
                    {
                        Warehouse = warehouse.WarehouseID,
                        ItemID    = item.ID,
                        Count     = 0
                    };

                    Global.Database.InsertInto <Stock>("stock", newEmptyStock);
                }

                if (cbSell.Checked)
                {
                    Stock stock = Global.Database.SelectOne <Stock>("stock", new Dictionary <string, object>()
                    {
                        { "ItemID", item.ID },
                        { "WarehouseID", warehouse.WarehouseID }
                    });

                    int count = Convert.ToInt32(tbCount.Text);

                    if (stock.Count < count)
                    {
                        Error("Nincs elég \"" + item.Name + "\" a \"" + warehouse.WarehouseName + "\" raktárban.\nSzállítnány: " + count.ToString() + "\nRaktárban: " + stock.Count.ToString(), "Hiba");
                        return;
                    }
                }

                DialogResult = System.Windows.Forms.DialogResult.OK;
            }
        }
        private XmlTextReader getWarehouseStockValue(XmlTextReader reader)
        {
            WarehouseStock newWarehousestock = new WarehouseStock();

            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                case "id":
                    newWarehousestock.Id = Int32.Parse(reader.Value);
                    break;

                case "amount":
                    newWarehousestock.Amount = Int32.Parse(reader.Value);
                    break;

                case "price":
                    newWarehousestock.Price = Double.Parse(reader.Value);
                    break;

                case "stockvalue":
                    newWarehousestock.StockValue = Double.Parse(reader.Value);
                    break;

                case "startamount":
                    newWarehousestock.StartAmount = Int32.Parse(reader.Value);
                    break;

                case "pct":
                    newWarehousestock.PCT = Double.Parse(reader.Value);
                    break;
                }
            }

            this.WarehouseStocks.Add(newWarehousestock);
            return(reader);
        }
Example #21
0
        private void btnShip_Click(object sender, System.EventArgs e)
        {
            if (ValidateInput())
            {
                Item item = ((Item)cbItem.Items[cbItem.SelectedIndex]);

                WarehouseStock fromStock = ((WarehouseStock)cbFrom.Items[cbFrom.SelectedIndex]);
                CheckEmptyStock(fromStock, item);

                WarehouseStock toStock = ((WarehouseStock)cbTo.Items[cbTo.SelectedIndex]);
                CheckEmptyStock(toStock, item);

                int count = Convert.ToInt32(tbCount.Text);

                if (fromStock.ItemCount < count)
                {
                    Error("Nincs elég \"" + item.Name + "\" a \"" + fromStock.WarehouseName + "\" raktárban.\nSzállítnány: " + count.ToString() + "\nRaktárban: " + fromStock.ItemCount.ToString(), "Hiba");
                }
                else
                {
                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
            }
        }
Example #22
0
        protected override Infragistics.WebUI.UltraWebGrid.UltraGridRow GetGridRow(object obj)
        {
            string factoryCode, warehouseCode, itemCode, warehouseQty, lingqty, openQty, actualQty, cycleCode;

            if (obj is WarehouseStock)
            {
                WarehouseStock item = (WarehouseStock)obj;
                factoryCode = item.FactoryCode;
                //segmentCode = item.SegmentCode;
                warehouseCode = item.WarehouseCode;
                itemCode      = item.ItemCode;
                openQty       = Math.Round(Convert.ToDecimal(item.OpenQty), 2).ToString();
                actualQty     = "";
                cycleCode     = "";
                warehouseQty  = "";
                lingqty       = "";
            }
            else
            {
                WarehouseCycleCountDetail item = (WarehouseCycleCountDetail)obj;
                factoryCode = item.FactoryCode;
                //segmentCode = item.SegmentCode;
                warehouseCode = item.WarehouseCode;
                itemCode      = item.ItemCode;
                warehouseQty  = Math.Round(Convert.ToDecimal(item.Qty), 2).ToString();                          //离散数量
                lingqty       = Math.Round(Convert.ToDecimal(item.LineQty), 2).ToString();                      //在制品虚拆数量
                openQty       = Math.Round(Convert.ToDecimal(item.Warehouse2LineQty), 2).ToString();            //账面数量 = 离散数量 + 在制品虚拆数量
                actualQty     = Math.Round(Convert.ToDecimal(item.PhysicalQty), 2).ToString();
                cycleCode     = item.CycleCountCode;
            }

            Infragistics.WebUI.UltraWebGrid.UltraGridRow row = new UltraGridRow();
            if (isWHCycle)
            {
                row =
                    new Infragistics.WebUI.UltraWebGrid.UltraGridRow(
                        new object[] {
                    factoryCode,
                    //segmentCode,
                    warehouseCode,
                    GetWarehouseStatusLabel(obj),
                    itemCode,
                    GetItemName(itemCode),
                    warehouseQty,                                                    /*	-------离散数量*/
                    lingqty,                                                         /* -------在制品虚拆数量*/
                    openQty,                                                         /*	-------账面数量 = 离散数量 + 在制品虚拆数量*/
                    actualQty,
                    GetWarehouseStatus(obj),
                    cycleCode,
                    ""
                });
            }
            else
            {
                row =
                    new Infragistics.WebUI.UltraWebGrid.UltraGridRow(
                        new object[] {
                    factoryCode,
                    //segmentCode,
                    warehouseCode,
                    GetWarehouseStatusLabel(obj),
                    itemCode,
                    GetItemName(itemCode),
                    openQty,                                                    /*	-------离散数量*/
                    actualQty,
                    GetWarehouseStatus(obj),
                    cycleCode,
                    ""
                });
            }
            return(row);
        }
 public void Update(WarehouseStock stock)
 {
     _session.Transact(session => session.Update(stock));
 }
Example #24
0
 public ViewResult Edit(WarehouseStock stock)
 {
     return(View(stock));
 }
Example #25
0
 public RedirectToRouteResult Edit_POST(WarehouseStock stock)
 {
     _warehouseStockAdminService.Update(stock);
     return(RedirectToAction("Index", new { sku = stock.ProductVariant.SKU }));
 }
        private WarehouseStock GetStock(string Specification, int WarehouseID)
        {
            WarehouseStock _dbEntry = _context.WarehouseStocks.Where(w => w.Specification == Specification).Where(w => w.WarehouseID == WarehouseID).FirstOrDefault();

            return(_dbEntry);
        }
Example #27
0
        private string IsAllowed(WarehouseStock ws)
        {
            if (_facade == null)
            {
                _facade = new WarehouseFacade(base.DataProvider);
            }
            //判断库存是否已初始化
            if (this._facade.QueryWarehouseStockCount(string.Empty, ws.WarehouseCode, /*ws.SegmentCode,*/ ws.FactoryCode) > 0)
            {
                throw new Exception(string.Format("$WarehouseInit_AlreadyInit [{0},{1}]", ws.FactoryCode, /*ws.SegmentCode,*/ ws.WarehouseCode));
            }
            if (htItems == null)
            {
                //将所有物料资料取出
                htItems = new Hashtable();
                object[] objs = this._facade.GetAllWarehouseItem();
                if (objs != null)
                {
                    for (int i = 0; i < objs.Length; i++)
                    {
                        WarehouseItem item = (WarehouseItem)objs[i];
                        htItems.Add(item.ItemCode, item.ItemName);
                        item = null;
                    }
                }
                objs = null;

                //将所有仓库资料取出
                htWarehouse = new Hashtable();
                objs        = this._facade.GetAllWarehouse();
                if (objs != null)
                {
                    for (int i = 0; i < objs.Length; i++)
                    {
                        Warehouse item = (Warehouse)objs[i];
                        htWarehouse.Add(string.Format("{0}-{1}", item.FactoryCode, /*item.SegmentCode,*/ item.WarehouseCode), "");
                        item = null;
                    }
                }
                objs = null;

                //取出Boolean的描述
                strBoolYes = FormatHelper.DisplayBoolean("1", this.languageComponent1);
                strBoolNo  = FormatHelper.DisplayBoolean("0", this.languageComponent1);
            }

            try
            {
                int iCode = int.Parse(ws.WarehouseCode);
                ws.WarehouseCode = new string('0', 4 - ws.WarehouseCode.Length) + ws.WarehouseCode;
            }
            catch
            {}
            ws.ItemCode = ws.ItemCode.ToUpper();
            if (ws.FactoryCode != string.Empty
                //&& ws.SegmentCode != string.Empty
                && ws.WarehouseCode != string.Empty &&
                ws.ItemCode != string.Empty &&
                ws.OpenQty > 0 &&
                htItems.ContainsKey(ws.ItemCode) &&
                htWarehouse.ContainsKey(string.Format("{0}-{1}", ws.FactoryCode, /* ws.SegmentCode,*/ ws.WarehouseCode)))
            {
                return(strBoolYes);
            }
            else
            {
                return(strBoolNo);
            }
        }
        public int Save(WarehouseStock WarehouseStock)
        {
            WarehouseStock _dbEntry;
            bool           _isNew = false;

            if (WarehouseStock.WarehouseStockID == 0)
            {
                _dbEntry = _context.WarehouseStocks.Where(w => w.Name == WarehouseStock.Name)
                           .Where(w => w.MaterialNumber == WarehouseStock.MaterialNumber)
                           .Where(w => w.Specification == WarehouseStock.Specification)
                           .Where(w => w.SupplierName == WarehouseStock.SupplierName)
                           .FirstOrDefault();

                if (_dbEntry == null)
                {
                    WarehouseStock.Material = WarehouseStock.Material == null ? "" : WarehouseStock.Material;
                    _context.WarehouseStocks.Add(WarehouseStock);
                    _isNew = true;
                }
                else
                {
                    _dbEntry.Name                = WarehouseStock.Name;
                    _dbEntry.Specification       = WarehouseStock.Specification;
                    _dbEntry.SafeQuantity        = WarehouseStock.SafeQuantity;
                    _dbEntry.WarehouseID         = WarehouseStock.WarehouseID;
                    _dbEntry.Enabled             = WarehouseStock.Enabled;
                    _dbEntry.MaterialNumber      = WarehouseStock.MaterialNumber;
                    _dbEntry.SupplierID          = WarehouseStock.SupplierID;
                    _dbEntry.SupplierName        = WarehouseStock.SupplierName;
                    _dbEntry.PurchaseItemID      = WarehouseStock.PurchaseItemID;
                    _dbEntry.PurchaseType        = WarehouseStock.PurchaseType;
                    _dbEntry.StockType           = WarehouseStock.StockType;
                    _dbEntry.InStockTime         = WarehouseStock.InStockTime;
                    _dbEntry.InStockQty          = WarehouseStock.InStockQty;
                    _dbEntry.WarehouseUserID     = WarehouseStock.WarehouseUserID;
                    _dbEntry.Material            = WarehouseStock.Material == null ? "" : WarehouseStock.Material;
                    _dbEntry.MoldNumber          = WarehouseStock.MoldNumber;
                    _dbEntry.PlanQty             = WarehouseStock.PlanQty;
                    _dbEntry.WarehousePositionID = WarehouseStock.WarehousePositionID;
                    _dbEntry.OutStockQty         = WarehouseStock.OutStockQty;
                }
            }
            else
            {
                _dbEntry                     = _context.WarehouseStocks.Find(WarehouseStock.WarehouseStockID);
                _dbEntry.Name                = WarehouseStock.Name;
                _dbEntry.Specification       = WarehouseStock.Specification;
                _dbEntry.SafeQuantity        = WarehouseStock.SafeQuantity;
                _dbEntry.WarehouseID         = WarehouseStock.WarehouseID;
                _dbEntry.Enabled             = WarehouseStock.Enabled;
                _dbEntry.MaterialNumber      = WarehouseStock.MaterialNumber;
                _dbEntry.SupplierID          = WarehouseStock.SupplierID;
                _dbEntry.SupplierName        = WarehouseStock.SupplierName;
                _dbEntry.PurchaseItemID      = WarehouseStock.PurchaseItemID;
                _dbEntry.PurchaseType        = WarehouseStock.PurchaseType;
                _dbEntry.StockType           = WarehouseStock.StockType;
                _dbEntry.InStockTime         = WarehouseStock.InStockTime;
                _dbEntry.InStockQty          = WarehouseStock.InStockQty;
                _dbEntry.WarehouseUserID     = WarehouseStock.WarehouseUserID;
                _dbEntry.Material            = WarehouseStock.Material;
                _dbEntry.MoldNumber          = WarehouseStock.MoldNumber;
                _dbEntry.PlanQty             = WarehouseStock.PlanQty;
                _dbEntry.WarehousePositionID = WarehouseStock.WarehousePositionID;
                _dbEntry.OutStockQty         = WarehouseStock.OutStockQty;
            }
            _context.SaveChanges();

            if (_isNew)
            {
                return(WarehouseStock.WarehouseStockID);
            }
            else
            {
                return(_dbEntry.WarehouseStockID);
            }
        }
Example #29
0
        //PUT /api/Warehouses/Completed/1
        public void Completed(string id, string shelfNo)
        {
            string date = DateTime.Now.ToString("d", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            var    warehouseOrderType    = _context.WarehouseOrderTypes.SingleOrDefault(ot => ot.OId == id);
            List <WarehouseOrder> orders = _context.WarehouseOrders.Where(o => o.OId == id).ToList();
            bool added = false;

            if (warehouseOrderType.type == 1)
            {
                for (int i = 0; i < orders.Count; i++)
                {
                    bool found = false;
                    try
                    {
                        var PID         = orders[i].PId;
                        int q           = orders[i].PQuantity;
                        var ProductInDb =
                            _context.WarehouseStocks.SingleOrDefault(pid => pid.ProductID.Equals(PID));
                        ProductInDb.Quantity = ProductInDb.Quantity + q;
                        found = true;
                        added = true;
                        _context.SaveChanges();
                    }
                    catch (Exception e)
                    {
                    }
                    if (found == false)
                    {
                        try
                        {
                            var ProductAdd = new WarehouseStock();
                            ProductAdd.ProductID = orders[i].PId;
                            ProductAdd.ShelveNo  = shelfNo;
                            ProductAdd.Quantity  = orders[i].PQuantity;
                            _context.WarehouseStocks.Add(ProductAdd);
                            added = true;
                            _context.SaveChanges();
                        }
                        catch (Exception e)
                        {
                        }
                    }
                    if (added == true)
                    {
                        var completedOrder = new WarehouseCompletedOrders();
                        completedOrder.OId        = id;
                        completedOrder.PId        = orders[i].PId;
                        completedOrder.PQuantity  = orders[i].PQuantity;
                        completedOrder.TotalPrice = orders[i].TotalPrice;
                        completedOrder.Date       = DateTime.Parse(date);
                        _context.WarehouseCompletedOrderses.Add(completedOrder);
                        _context.WarehouseOrders.Remove(orders[i]);
                        _context.SaveChanges();
                    }
                }
            }
            if (warehouseOrderType.type == 2)
            {
                for (int i = 0; i < orders.Count; i++)
                {
                    try
                    {
                        var PID         = orders[i].PId;
                        int q           = orders[i].PQuantity;
                        var ProductInDb =
                            _context.WarehouseStocks.SingleOrDefault(pid => pid.ProductID.Equals(PID));

                        ProductInDb.Quantity = ProductInDb.Quantity - q;
                        _context.SaveChanges();
                        added = true;
                    }
                    catch (Exception e)
                    {
                    }
                    if (added == true)
                    {
                        var completedOrder = new WarehouseCompletedOrders();
                        completedOrder.OId          = id;
                        completedOrder.PId          = orders[i].PId;
                        completedOrder.PQuantity    = orders[i].PQuantity;
                        completedOrder.TotalPrice   = orders[i].TotalPrice;
                        completedOrder.Date         = DateTime.Parse(date);
                        completedOrder.Notification = 0;
                        _context.WarehouseCompletedOrderses.Add(completedOrder);
                        _context.WarehouseOrders.Remove(orders[i]);
                        _context.SaveChanges();
                    }
                }
            }
            _context.SaveChanges();
        }
        public BulkUpdateResult Update(List <BulkWarehouseStockUpdateDTO> dtoList)
        {
            var errors          = new List <string>();
            var warehouseStocks = _statelessSession.Query <WarehouseStock>()
                                  .Where(stock => stock.Site.Id == _site.Id && !stock.IsDeleted &&
                                         stock.ProductVariant != null &&
                                         stock.ProductVariant.SKU != null &&
                                         stock.Warehouse != null && !stock.ProductVariant.IsDeleted)
                                  .Fetch(stock => stock.ProductVariant)
                                  .Fetch(stock => stock.Warehouse)
                                  .ToList();

            var duplicates = warehouseStocks
                             .GroupBy(x => new { x.ProductVariantSKU, x.Warehouse.Id })
                             .Where(group => group.Count() > 1)
                             .Select(group => new BulkWarehouseStockUpdateDTO
            {
                SKU         = group.Key.ProductVariantSKU,
                WarehouseId = group.Key.Id
            }).ToList();

            if (duplicates.Any())
            {
                foreach (var bulkWarehouseStockUpdateDto in duplicates)
                {
                    errors.Add($"A duplicate SKU of {bulkWarehouseStockUpdateDto.SKU} was found for warehouse Id {bulkWarehouseStockUpdateDto.WarehouseId} in the database.");
                }

                return(new BulkUpdateResult
                {
                    IsSuccess = false,
                    Messages = errors
                });
            }

            var dictionary = warehouseStocks
                             .GroupBy(stock => stock.ProductVariant.SKU)
                             .ToDictionary(stocks => stocks.Key,
                                           stocks => stocks.ToDictionary(stock => stock.Warehouse.Id, stock => stock));

            HashSet <BulkWarehouseStockUpdateDTO> dtos = dtoList.ToHashSet();
            var stockToUpdate = new HashSet <WarehouseStock>();

            using (ITransaction transaction = _statelessSession.BeginTransaction())
            {
                foreach (BulkWarehouseStockUpdateDTO dto in dtos)
                {
                    if (!dictionary.ContainsKey(dto.SKU) || !dictionary[dto.SKU].ContainsKey(dto.WarehouseId))
                    {
                        continue;
                    }

                    WarehouseStock stock = dictionary[dto.SKU][dto.WarehouseId];
                    if (stock.StockLevel == dto.StockLevel)
                    {
                        continue;
                    }

                    stock.StockLevel = dto.StockLevel;
                    stockToUpdate.Add(stock);
                }
                foreach (WarehouseStock stock in stockToUpdate)
                {
                    _statelessSession.Update(stock);
                }
                transaction.Commit();
            }

            return(new BulkUpdateResult
            {
                IsSuccess = true,
                Messages = new List <string>
                {
                    string.Format(
                        _stringResourceProvider.GetValue("Bulk Stock Update - number processed", "{0} items processed"),
                        dtos.Count()),
                    string.Format(
                        _stringResourceProvider.GetValue("Bulk Stock Update - number updated", "{0} items updated"),
                        stockToUpdate.Count)
                }
            });
        }