public void AddStockOut(int[] selectedIds, int[] selectedValues, string user) { StockOutDetail note = new StockOutDetail(); note.detailProductList = new List <Product>(); var newList = new List <StockOutDetail>(); if (outList == null) { note.detailId = 1; } else { note.detailId = outList.Last().detailId + 1; newList = new List <StockOutDetail>(outList); } //Assign value for new note note.detailUser = user; note.detailDateAdded = DateTime.Now; note.detailProductList = new List <Product>(); note.detailStockChange = new List <StockTracker>(); List <Product> changedProducts = new List <Product>(); (note.detailProductList, note.detailStockChange, changedProducts) = UpdateNoteProductList(selectedIds, selectedValues, isPlus: false); if (note.detailProductList != null && note.detailStockChange != null && changedProducts != null) { newList.Add(note); //Update database UpdateProductList(changedProducts); LocalDataAccess.WriteDataStockOut(rootPath, stockOutFile, newList); } }
public ActionResult DeleteConfirmed(int id) { StockOutDetail stockOutDetail = db.StockOutDetails.Find(id); db.StockOutDetails.Remove(stockOutDetail); db.SaveChanges(); return(RedirectToAction("Index")); }
private void btnLưu_Click(object sender, EventArgs e) { if (txtMaPX.Text == "" || txtTenNguoiNhan.Text == "" || txtCMND.Text == "") { MessageBox.Show("Vui lòng điền đủ thông tin phiên xuất kho", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { //luu thong tin phien vao stockout, cap nhat trang thai barcode thanh false(da xuat kho), luu thong tin bang stockoutdetail //luu thong tin phien vao stockout StockOut so = new StockOut(); so.StockOutCode = txtMaPX.Text; so.UserID = txtUser.Text; so.DateOut = DateTime.Parse(dateNgayPX.EditValue.ToString()); so.RecipientName = txtTenNguoiNhan.Text; so.IDCard = txtCMND.Text; so.Company = txtCongTy.Text; so.TotalWeight = double.Parse(txtTongTrongLuong.Text); so.Quantity = Int32.Parse(txtSoLuong.Text); so.Note = txtGhiChu.Text; //Kiem tra trung stockoutcode StockOut var = (from s in dc.StockOuts where s.StockOutCode == so.StockOutCode select s).FirstOrDefault(); if (var == null) { dc.StockOuts.InsertOnSubmit(so); dc.SubmitChanges(); } else { MessageBox.Show("Mã phiên xuất kho bị trùng lặp", "Thông báo", MessageBoxButtons.OK); } //cập nhật trang thai barcode thanh false (da xuat kho) for (int i = 0; i < gridViewBarcode.RowCount; i++) { BarcodeDetail bd = (from c in dc.BarcodeDetails where c.Barcode == gridViewBarcode.GetRowCellValue(i, "Barcode").ToString() select c).FirstOrDefault(); if (bd != null) { bd.Status = false; dc.SubmitChanges(); } } //luu thong tin stockout detail for (int i = 0; i < gridViewBarcode.RowCount; i++) { StockOutDetail sod = new StockOutDetail(); sod.StockOutCode = txtMaPX.Text; sod.Barcode = gridViewBarcode.GetRowCellValue(i, "Barcode").ToString(); dc.StockOutDetails.InsertOnSubmit(sod); dc.SubmitChanges(); } MessageBox.Show("Lưu phiên xuất kho thành công", "Thông báo", MessageBoxButtons.OK); } }
public ActionResult Edit([Bind(Include = "Id,StockOutId,ProductId,Qty")] StockOutDetail stockOutDetail) { if (ModelState.IsValid) { db.Entry(stockOutDetail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProductId = new SelectList(db.Products, "Id", "Name", stockOutDetail.ProductId); ViewBag.StockOutId = new SelectList(db.StockOuts, "Id", "Description", stockOutDetail.StockOutId); return(View(stockOutDetail)); }
// GET: StockOutDetails/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StockOutDetail stockOutDetail = db.StockOutDetails.Find(id); if (stockOutDetail == null) { return(HttpNotFound()); } return(View(stockOutDetail)); }
// GET: StockOutDetails/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StockOutDetail stockOutDetail = db.StockOutDetails.Find(id); if (stockOutDetail == null) { return(HttpNotFound()); } ViewBag.ProductId = new SelectList(db.Products, "Id", "Name", stockOutDetail.ProductId); ViewBag.StockOutId = new SelectList(db.StockOuts, "Id", "Description", stockOutDetail.StockOutId); return(View(stockOutDetail)); }
public static List <StockOutDetail> ReadDataStockOut(string rootPath, string fileName) { string filePath = Path.Combine(rootPath, fileName); string text = ""; if (File.Exists(filePath)) { text = File.ReadAllText(filePath); try { var readList = JsonSerializer.Deserialize <List <SupportClass> >(text, options); List <StockOutDetail> trackList = new List <StockOutDetail>(); foreach (var item in readList) { List <Product> products = JsonSerializer.Deserialize <List <Product> >(item.detailProductList); List <StockTracker> changes = JsonSerializer.Deserialize <List <StockTracker> >(item.detailStockChange); StockOutDetail itemNew = new StockOutDetail { detailId = item.detailId, detailDateAdded = item.detailDateAdded, detailUser = item.detailUser, detailProductList = products, detailStockChange = changes }; trackList.Add(itemNew); } return(trackList); } catch (Exception) { return(null); } } return(null); }
private void btnStockOutDetails_Click(object sender, EventArgs e) { Form formStockOutDetail = new StockOutDetail(); formStockOutDetail.ShowDialog(); }
public bool ModifyStockOutDetail(string checkCode, int AccountID, StockOutDetail entity, ref string ErrMsg) { if (!CheckingCheckCode(checkCode, AccountID, ref ErrMsg)) return false; if (entity == null) { ErrMsg = "实体不能为空"; return false; } if (string.IsNullOrEmpty(entity.GLassID)) { ErrMsg = "Glass ID不能为空!"; return false; } if (entities.StockOutDetails.Any(p => p.GLassID == entity.GLassID))//只能用于GLASSID替换,如果修改其他 不修改GLASSID 这地方会有问题 { ErrMsg = "新的Glass ID已存在"; return false; } try { var entry = entities.Entry<StockOutDetail>(entity); if (entry.State == EntityState.Detached) { entities.Set<StockOutDetail>().Attach(entity); entry.State = EntityState.Modified; } if (entities.SaveChanges() <= 0) { ErrMsg = "修改失败"; return false; } return true; } catch (Exception ex) { ErrMsg = ex.Message; return false; } }
public bool AddStockOutDetail(string checkCode, int AccountID, StockOutDetail entity, bool IsCheck, ref int QtyCount, ref StockOutDetail entityID, ref string ErrMsg) { if (!CheckingCheckCode(checkCode, AccountID, ref ErrMsg)) return false; if (entity == null) { ErrMsg = "数据为空"; return false; } try { if (entities.StockOutDetails.Any(p => p.GLassID == entity.GLassID)) { ErrMsg = "GlassID 不能重复"; return false; } StockLotOut sl = entities.StockLotOuts.FirstOrDefault(p => p.ID == entity.StockLotOutID); // StockLot sl = entities.StockLots.FirstOrDefault(p => p.ID == entity.StockLotOutID); if (sl == null) { ErrMsg = "LotNo不存在或已删除"; return false; } if (sl.Status>=1) { ErrMsg = "该LotNo出库已结束,不能扫描GlassID进行出库"; return false; } //if(sl.Status>=3) //{ // ErrMsg="该LotNo出库已结束,不能扫描GlassID进行出库"; // return false; //} int iOutCount = entities.StockOutDetails.Count(p => p.StockLotOutID == sl.ID); if ( sl.PCSQty <= iOutCount) { ErrMsg = "当前剩余出库数量为0"; return false; } FormWork fw = entities.FormWorks.FirstOrDefault(p => p.ProductModel == sl.ProModel); if (fw == null) { ErrMsg = "该型号的模板不存在或已被删除,无法出库"; return false; } if (IsCheck) { #region 2013年8月8日 22:23:19 验证是否已出库 StockLot stockLot = entities.StockLots.Include("StockDetails").FirstOrDefault(p => p.LotNo == sl.LotNo); if (stockLot == null) { ErrMsg = "该LotNo的入库数据不存在或已被删除,无法进行出库扫描"; return false; } if (!stockLot.StockDetails.Any(p => p.GlassID == entity.GLassID)) { ErrMsg = "当前LotNo下不存在该GlassID的入库记录,无法出库"; return false; } #endregion string[] strArray = fw.IDKeyWords.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string tmpStr = strArray[strArray.Length - 1]; if (entity.GLassID.Length < int.Parse(tmpStr.Substring(0, tmpStr.Length - 1))) { ErrMsg = "与模板的关键字不匹配,不能出库"; return false; } for (int i = 0; i < entity.GLassID.Length; i++) { for (int j = 0; j < strArray.Length; j++) { if ((i + 1) == int.Parse(strArray[j].Substring(0, strArray[j].Length - 1))) { if (entity.GLassID[i].ToString() != (strArray[j].Substring(strArray[j].Length - 1))) { ErrMsg = "与模板的关键字不匹配,不能出库"; return false; } } } } } entity.CreateDt = DateTime.Now; entities.StockOutDetails.Add(entity); if (entities.SaveChanges() <= 0) { ErrMsg = "添加失败"; return false; } QtyCount = iOutCount + 1; entityID = entity; return true; } catch (Exception ex) { ErrMsg = ex.Message; return false; } }
public bool DeleteStockOutDetail(string checkCode, int AccountID, StockOutDetail entity, ref string ErrMsg) { if (!CheckingCheckCode(checkCode, AccountID, ref ErrMsg)) return false; if (entity == null) { ErrMsg = "Glass ID信息为空"; return false; } StockOutDetail _tmp = entities.StockOutDetails.FirstOrDefault(p => p.ID == entity.ID); if (_tmp == null) { ErrMsg = "该Glass ID不存在或已删除"; return false; } try { entities.StockOutDetails.Remove(_tmp); if (entities.SaveChanges() <= 0) { ErrMsg = "删除失败"; return false; } return true; } catch (Exception ex) { ErrMsg = ex.Message; return false; } }
public IAsyncResult BeginDeleteStockOutDetail(string checkCode, int AccountID, StockOutDetail entity, ref string ErrMsg, AsyncCallback callback, object asyncState) { throw new NotImplementedException(); }
public IAsyncResult BeginAddStockOutDetail(string checkCode, int AccountID, StockOutDetail entity, bool IsCheck, ref int QtyCount, ref StockOutDetail entityID, ref string ErrMsg, AsyncCallback callback, object asyncState) { throw new NotImplementedException(); }
public bool AddStockOutDetail(string checkCode, int AccountID, StockOutDetail entity, bool IsCheck, ref int QtyCount, ref StockOutDetail entityID, ref string ErrMsg) { throw new NotImplementedException(); }
public bool ModifyStockOutDetail(string checkCode, int AccountID, StockOutDetail entity, ref string ErrMsg) { throw new NotImplementedException(); }
public bool EndAddStockOutDetail(ref int QtyCount, ref StockOutDetail entityID, ref string ErrMsg, IAsyncResult result) { throw new NotImplementedException(); }