public bool AddStock(CreateStock stock) { if (stock == null) { return(false); } return(_stockDAO.AddStock(stock.ProductId, stock.Quantity, stock.LastUpdated)); }
public ActionResult CreateStock(CreateStock stock) { StockService stockService = new StockService(); if (stockService.CreateStock(stock)) { TempData["CreateStock"] = 1; } else { TempData["CreateStock"] = 0; } return(Redirect(Request.UrlReferrer.ToString())); }
public bool CreateStock(CreateStock stock) { try { RepositoryContainer.GetInstance <StockRepository>().Create(new Stock { Product_ID = stock.Product_ID, Color = stock.Color, Size = stock.Size, Quantity = 0 }); return(true); } catch { return(false); } }
private void BtnSaveStock_Click(object sender, EventArgs e) { var isValidQuantity = ValidateStockQuantity(); var isValidProduct = ValidateStockProduct(); if (isValidProduct && isValidQuantity) { int quantity; int productId; if (!int.TryParse(txtQuantity.Text, out quantity) || !int.TryParse(cbProduct.SelectedValue.ToString(), out productId)) { MessageBox.Show("Stock not added, invalid data"); } else { if (_stockBUS.CheckExistingStock(productId)) { // Update stock _stockBUS.UpdateStock(productId, quantity); MessageBox.Show("Stock updated"); LoadStockDataInGridview(); } else { // Create stock var createStock = new CreateStock { ProductId = productId, Quantity = quantity, LastUpdated = DateTime.Now }; _stockBUS.AddStock(createStock); MessageBox.Show("Stock created"); LoadStockDataInGridview(); } } } else { MessageBox.Show("Please enter valid stock details"); } }
public async Task <IActionResult> CreateStock([FromBody] CreateStock.Request request, [FromServices] CreateStock createStock) => Ok(await createStock.Do(request));
private void ProcessExcel() { Log("导出Excel文件..."); ExcelEdit ed = new ExcelEdit(); ed.Create(); int index = 1; ed.SetCellValue("Sheet1", index, 1, "图序号范围"); ed.SetCellValue("Sheet1", index, 2, "面料编号"); ed.SetCellValue("Sheet1", index, 3, "面料名称"); ed.SetCellValue("Sheet1", index, 4, "总米数"); ed.SetCellValue("Sheet1", index, 5, "实际米数"); index++; // 面料名称、面料编号、规则名列表、文件路径列表、米数列表、图号列表 foreach (var item in FacePathTuples) { if (item.Item3.Count == 0) { continue; } string strnumrange = item.Item6.Count >= 2 ? item.Item6.First() + "-" + item.Item6.Last() : item.Item6[0]; ed.SetCellValue("Sheet1", index, 1, strnumrange); double totalmeter = 0.0; foreach (var fi in item.Item5) { totalmeter += fi; } ed.SetCellValue("Sheet1", index, 2, item.Item2); ed.SetCellValue("Sheet1", index, 3, item.Item1); ed.SetCellValue("Sheet1", index, 4, totalmeter); ed.SetCellValue("Sheet1", index, 5, item.Item5.Count * Ratio + totalmeter); index++; } string excelname = Url.Substring(Url.LastIndexOf('\\') + 1); ExcelUrl = Url + "\\" + excelname + ".xlsx"; ed.SaveAs(ExcelUrl); ed.Close(); Log("导出Excel文件结束"); if (MessageBox.Show("是否更新库存表?", "更新", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { bool b0 = System.IO.File.Exists(ExcelUrl); if (!b0) { Log("找不到样表文件" + ExcelUrl + "更新失败"); return; } string stockexcel = Url + "\\库存.xlsx"; bool b2 = System.IO.File.Exists(stockexcel); if (!b2) { Log("找不到库存表文件" + stockexcel + "更新失败"); return; } try { if (!CreateStock.Create(stockexcel, ExcelUrl, "")) { Log("更新库存表失败!请检查文件内容有效性!"); } else { Log("更新库存表成功!"); } } catch (Exception) { Log("更新库存表失败!请检查文件内容有效性!"); } } }
public void Post([FromBody] CreateStock s) { var entity = StockModel.Create(s.Name, s.Code, s.StockRecords); _repository.Add(entity); }
public void Process(int startindex, float ratio) { StartIndex = startindex; Ratio = ratio; Log("查找文件..."); List <string> files = new List <string>(); GetAllFiles(Url, ref files); if (files.Count == 0) { Log("没有找到文件,结束"); return; } Log("查找小样文件..."); List <FileInfo> fileinfos = new List <FileInfo>(); int totalindex = StartIndex; foreach (var f in files) { FileInfo fi; if (ParseFileName(Path.GetFileNameWithoutExtension(f), out fi)) { fi.Url = f; fi.Number = totalindex.ToString() + "号"; fileinfos.Add(fi); totalindex++; } } if (fileinfos.Count == 0) { Log("没有找到米样文件,结束"); return; } Log("找到" + fileinfos.Count.ToString() + "个小样文件,开始重命名..."); foreach (var item in fileinfos) { string newname = item.Number + "-" + item.ReguName + Path.GetExtension(item.Url); Rename(item.Url, newname); } Log("重命名结束..."); Log("导出Excel文件..."); { ExcelEdit ed = new ExcelEdit(); ed.Create(); int index = 1; ed.SetCellValue("Sheet1", index, 1, "图号"); ed.SetCellValue("Sheet1", index, 2, "描述"); index++; foreach (var item in fileinfos) { ed.SetCellValue("Sheet1", index, 1, item.Number); string disc = item.Format + item.Disc + "-"; foreach (var fn in item.FaceNameCount) { disc += fn.Item1.Item1 + "(" + fn.Item2.ToString() + ")个、"; } disc.TrimEnd('、'); ed.SetCellValue("Sheet1", index, 2, disc); index++; } string excelname = Url.Substring(Url.LastIndexOf('\\') + 1); ExcelUrl1 = Url + "\\小样" + excelname + "1.xlsx"; ed.SaveAs(ExcelUrl1); ed.Close(); } { int nCount = Config.Settings.lstFaceInfo.Count; List <Tuple <string, string, List <int> > > sortfacenamecount = new List <Tuple <string, string, List <int> > >(); for (int i = 0; i < nCount; i++) { sortfacenamecount.Add(new Tuple <string, string, List <int> >(Config.Settings.lstFaceInfo[i].Index.ToString() + "#", Config.Settings.lstFaceInfo[i].FaceName, new List <int>())); } foreach (var item in fileinfos) { foreach (var fn in item.FaceNameCount) { var res = sortfacenamecount.Where(s => s.Item1 == fn.Item1.Item2); if (res.Count() != 0) { res.ElementAt(0).Item3.Add(fn.Item2); } else { Log("文件" + item.Url + "的面料类型" + fn.Item1 + "没有定义"); } } } ExcelEdit ed = new ExcelEdit(); ed.Create(); int index = 1; ed.SetCellValue("Sheet1", index, 1, "面料编号"); ed.SetCellValue("Sheet1", index, 2, "面料名称"); ed.SetCellValue("Sheet1", index, 3, "个数"); ed.SetCellValue("Sheet1", index, 4, "实际米数"); index++; foreach (var item in sortfacenamecount) { if (item.Item3.Count == 0) { continue; } ed.SetCellValue("Sheet1", index, 1, item.Item1); ed.SetCellValue("Sheet1", index, 2, item.Item2); int totalcount = 0; foreach (var fn in item.Item3) { totalcount += fn; } ed.SetCellValue("Sheet1", index, 3, totalcount); ed.SetCellValue("Sheet1", index, 4, totalcount * Ratio); index++; } string excelname = Url.Substring(Url.LastIndexOf('\\') + 1); ExcelUrl2 = Url + "\\小样" + excelname + "2.xlsx"; ed.SaveAs(ExcelUrl2); ed.Close(); } Log("导出Excel文件结束"); { if (MessageBox.Show("是否更新库存表?", "更新", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { bool b0 = System.IO.File.Exists(ExcelUrl2); if (!b0) { Log("找不到小样表文件" + ExcelUrl2 + ",更新失败"); return; } string stockexcel = Url + "\\库存.xlsx"; bool b2 = System.IO.File.Exists(stockexcel); if (!b2) { Log("找不到库存表文件" + stockexcel + "更新失败"); return; } try { if (!CreateStock.Create(stockexcel, "", ExcelUrl2)) { Log("更新库存表失败!请检查文件内容有效性!"); } else { Log("更新库存表成功!"); } } catch (Exception) { Log("更新库存表失败!请检查文件内容有效性!"); } } } }
public async Task <IActionResult> CreateStock([FromBody] StockDto stockDto, [FromServices] CreateStock createStock) { return(Ok(await createStock.ExecAsync(stockDto))); }
public Task <object> CreateStock( [FromBody] CreateStock.Form request, [FromServices] CreateStock createStock) => createStock.Do(request);