private void SaveData() { try { var receiveWgh = lblWeight.Text.ToDecimal(); var createBy = Helper.GetLocalIPAddress(); using (var db = new SlaughterhouseEntities()) { var receive = db.receives.Where(p => p.receive_no.Equals(lblReceiveNo.Text)).SingleOrDefault(); int remainQty = receive.farm_qty - receive.head_qty.ToString().ToInt16(); if (remainQty == 0) { throw new Exception("จำนวนรับครบแล้ว ไม่สามารถรับเพิ่มได้!"); } //int receive_qty = receive.receive_item.Where(p => p.product_code.Equals(product.product_code)).Sum(p => p.receive_qty); //if (receive.farm_qty - receive_qty == 0) //{ // throw new Exception("จำนวนรับครบแล้ว ไม่สามารถรับเพิ่มได้!"); //} int seq = receive.receive_item.Where(p => p.product_code.Equals(product.product_code)).Count(); seq += 1; barcode_no = Helper.GetMaxBarcode(); //int count = db.barcodes.Count(); //if (count == 0) //{ // barcode_no = string.Format("{0}0000000001", plant.plant_id).ToLong(); //} //else //{ // barcode_no = db.barcodes.Max(p => p.barcode_no) + 1; // if (barcode_no.ToString().Length > 11) // { // var tempBarcode = barcode_no.ToString().TrimStart('1'); // var running = tempBarcode.ToLong(); // var code = running.ToString().PadLeft(10, '0'); // barcode_no = ("1" + code).ToLong(); // } //} var item = new receive_item { receive_no = receive.receive_no, product_code = product.product_code, seq = seq, lot_no = receive.lot_no, sex_flag = "", receive_qty = 1, receive_wgh = receiveWgh, chill_qty = 0, chill_wgh = 0, barcode_no = barcode_no, create_by = createBy }; //string stock_no = db.stock_item_running.Where(p => p.doc_no.Equals(receive.receive_no)).Select(p => p.stock_no).SingleOrDefault(); using (DbContextTransaction transaction = db.Database.BeginTransaction()) { try { //insert barcode //var qrData = string.Format("{0}|00{1}{2}", barcode_no, item.product_code, Convert.ToInt64(receiveWgh * 10000).ToString().PadLeft(6, '0')); //insert barcode var barcode = new barcode { barcode_no = barcode_no, product_code = item.product_code, production_date = plant.production_date, lot_no = receive.lot_no, qty = 1, wgh = receiveWgh, active = true, create_by = createBy, qrcode_image = Helper.GenerateQRCode(barcode_no.ToString()), //location_code = locationCode, }; //var barcode = new barcode //{ // barcode_no = barcode_no, // product_code = item.product_code, // production_date = plant.production_date, // lot_no = receive.lot_no, // qty = 1, // wgh = receiveWgh, // active = true, // create_by = createBy //}; db.barcodes.Add(barcode); db.receive_item.Add(item); //insert stock //var stock = new stock //{ // stock_date = plant.production_date, // stock_no = stock_no, // stock_item = item.seq, // product_code = item.product_code, // stock_qty = item.receive_qty, // stock_wgh = item.receive_wgh, // ref_document_no = receive.receive_no, // ref_document_type = Constants.REV, // lot_no = receive.lot_no, // location_code = locationCode, // barcode_no = barcode_no, // transaction_type = 1, // create_by = createBy //}; //db.stocks.Add(stock); receive.head_qty += item.receive_qty; receive.head_wgh += item.receive_wgh; db.SaveChanges(); transaction.Commit(); } catch (Exception) { transaction.Rollback(); throw; } } } } catch (Exception) { throw; } }
private void SaveData() { try { var receiveWgh = lblWeight.Text.ToDecimal(); string createBy = Helper.GetLocalIPAddress(); var productionDate = plant.production_date; using (var db = new SlaughterhouseEntities()) { var receive = db.receives.Where(p => p.receive_no.Equals(lblReceiveNo.Text)).SingleOrDefault(); //var carcassQty = receive.carcass_qty == 0 ? receive.carcass_qty : (receive.carcass_qty / RECEIVE_QTY); if (receive.farm_qty - receive.carcass_qty == 0) { throw new Exception("จำนวนรับครบแล้ว\rไม่สามารถรับเพิ่มได้!"); } int seq = receive.receive_item.Where(p => p.product_code.Equals(product.product_code)).Count(); ////หารับหมูเป็นมาตัดออกจาก stock //var swine = receive.receive_item.Where(p => p.product_code == "P001" // && p.seq == seq).Select(p => new { p.receive_qty, p.receive_wgh }).SingleOrDefault(); seq += 1; //string stock_no = db.stock_item_running.Where(p => p.doc_no.Equals(receive.receive_no)).Select(p => p.stock_no).SingleOrDefault(); string stock_no = ""; var stockDocument = (from p in db.document_generate where p.document_type == Constants.STK select p).SingleOrDefault(); //check stock_item_running var stockItemRunning = db.stock_item_running.Where(p => p.doc_no.Equals(receive.receive_no)).SingleOrDefault(); if (stockItemRunning == null) { //get new stock doc no stock_no = Constants.STK + stockDocument.running.ToString().PadLeft(10 - Constants.STK.Length, '0'); } else { stock_no = stockItemRunning.stock_no; } using (DbContextTransaction transaction = db.Database.BeginTransaction()) { try { var item = new receive_item { receive_no = receive.receive_no, product_code = product.product_code, seq = seq, lot_no = receive.lot_no, sex_flag = sexFlag, receive_qty = 1, receive_wgh = receiveWgh, chill_qty = 0, chill_wgh = 0, create_by = createBy }; db.receive_item.Add(item); //var stocks = new List<stock>(); //stocks.Add(new stock //{ // stock_date = productionDate, // stock_no = stock_no, // stock_item = item.seq, // product_code = item.product_code, // stock_qty = item.receive_qty, // stock_wgh = item.receive_wgh, // ref_document_no = receive.receive_no, // ref_document_type = Constants.REV, // lot_no = receive.lot_no, // location_code = 1, // barcode_no = 0, // transaction_type = 2, // create_by = item.create_by //}); //insert stock var stock = new stock { stock_date = productionDate, stock_no = stock_no, stock_item = item.seq, product_code = item.product_code, stock_qty = 1, stock_wgh = receiveWgh, ref_document_no = receive.receive_no, ref_document_type = Constants.REV, lot_no = receive.lot_no, location_code = 2, //ห้องเย็นเก็บหมุซีก barcode_no = 0, transaction_type = 1, create_by = createBy }; db.stocks.Add(stock); receive.carcass_qty += 1; receive.carcass_wgh += receiveWgh; if (stockItemRunning == null) { //insert stock_item_running var newStockItem = new stock_item_running { doc_no = receive.receive_no, stock_no = stock_no, stock_item = 1, create_by = createBy }; db.stock_item_running.Add(newStockItem); //update document_generate stockDocument.running += 1; db.Entry(stockDocument).State = System.Data.Entity.EntityState.Modified; } else { //update stock_item_running stockItemRunning.stock_item += 1; db.Entry(stockItemRunning).State = System.Data.Entity.EntityState.Modified; } db.SaveChanges(); transaction.Commit(); } catch (Exception) { transaction.Rollback(); throw; } } } } catch (Exception) { throw; } }
//private static void PlayNotificationSound(string sound) //{ // var soundsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Sounds"); // var soundFile = Path.Combine(soundsFolder, sound + ".wav"); // using (var player = new System.Media.SoundPlayer(soundFile)) // { // player.Play(); // } //} private bool SaveData() { try { var receive_wgh = lblWeight.Text.ToDecimal(); using (var db = new SlaughterhouseEntities()) { //update receive var receive = db.receives.Where(p => p.receive_no.Equals(lblReceiveNo.Text)).SingleOrDefault(); int stock_qty = receive.receive_item.Where(p => p.product_code.Equals(product.product_code)).Sum(p => p.receive_qty); if (receive.factory_qty - stock_qty == 0) { throw new Exception("จำนวนรับครบแล้ว ไม่สามารถรับเพิ่มได้!"); } int seq = receive.receive_item.Where(p => p.product_code.Equals(product.product_code)).Count(); //int seq = db.receive_item.Where(p => p.receive_no == receive.receive_no).Count(); seq += 1; var item = new receive_item { receive_no = receive.receive_no, product_code = product.product_code, seq = seq, lot_no = receive.lot_no, sex_flag = "", receive_qty = 1, receive_wgh = receive_wgh, chill_qty = 0, chill_wgh = 0, create_by = Constants.CREATE_BY }; string stock_no = db.stock_item_running.Where(p => p.doc_no.Equals(receive.receive_no)).Select(p => p.stock_no).SingleOrDefault(); //var documentGenerate = (from p in db.document_generate where p.document_type == Constants.STK select p).SingleOrDefault(); //check stock_item_running //var stockItemRunning = db.stock_item_running.Where(p => p.doc_no.Equals(receive.receive_no)).SingleOrDefault(); //if (stockItemRunning == null) //{ // //get new stock doc no // stock_no = Constants.STK + documentGenerate.running.ToString().PadLeft(10 - Constants.STK.Length, '0'); //} //else //{ // stock_no = stockItemRunning.stock_no; //} using (DbContextTransaction transaction = db.Database.BeginTransaction()) { try { //receive.factory_qty += item.receive_qty; //receive.factory_wgh += item.receive_wgh; //db.Entry(receive).State = EntityState.Modified; db.receive_item.Add(item); //insert stock var stock = new stock { stock_date = DateTime.Today, stock_no = stock_no, stock_item = item.seq, product_code = item.product_code, stock_qty = item.receive_qty, stock_wgh = item.receive_wgh, ref_document_no = receive.receive_no, ref_document_type = Constants.REV, lot_no = receive.lot_no, location_code = 2, //ห้องเย็นเก็บหมุซีก barcode_no = 0, transaction_type = 1, create_by = item.create_by }; db.stocks.Add(stock); //รับหมูซีก เครื่องใน ไม่ต้อง update stock_item_running เพราะเริ่มตาม receive_item.seq //if (stockItemRunning == null) //{ // //insert stock_item_running // var newStockItem = new stock_item_running // { // doc_no = receive.receive_no, // stock_no = stock_no, // stock_item = 1, // create_by = item.create_by // }; // db.stock_item_running.Add(newStockItem); // //update document_generate // documentGenerate.running += 1; // db.Entry(documentGenerate).State = EntityState.Modified; //} //else //{ // //update stock_item_running // stockItemRunning.stock_item += 1; // db.Entry(stockItemRunning).State = EntityState.Modified; //} db.SaveChanges(); transaction.Commit(); } catch (Exception) { transaction.Rollback(); throw; } } } return(true); } catch (Exception) { throw; } }
//private void BtnControl(bool start, bool ok, bool close) //{ // btnStart.Enabled = start; // BtnOK.Enabled = ok; // btnStop.Enabled = close; //} private bool SaveData() { try { var weight = lblWeight.Text.ToDecimal(); using (var db = new SlaughterhouseEntities()) { //update receive var receive = db.receives.Where(p => p.receive_no.Equals(lblReceiveNo.Text)).SingleOrDefault(); if (receive.farm_qty - receive.factory_qty == 0) { throw new Exception("จำนวนรับครบแล้ว ไม่สามารถรับเพิ่มได้!"); } int seq = receive.receive_item.Count(); //int seq = db.receive_item.Where(p => p.receive_no == receive.receive_no).Count(); seq += 1; var item = new receive_item { receive_no = receive.receive_no, product_code = productCode, seq = seq, lot_no = receive.lot_no, sex_flag = sexFlag, receive_qty = 1, receive_wgh = weight, chill_qty = 0, chill_wgh = 0, create_by = Constants.CREATE_BY }; string stock_no = ""; var documentGenerate = (from p in db.document_generate where p.document_type == Constants.STK select p).SingleOrDefault(); //check stock_item_running var stockItemRunning = db.stock_item_running.Where(p => p.doc_no.Equals(receive.receive_no)).SingleOrDefault(); if (stockItemRunning == null) { //get new stock doc no stock_no = Constants.STK + documentGenerate.running.ToString().PadLeft(10 - Constants.STK.Length, '0'); } else { stock_no = stockItemRunning.stock_no; } using (DbContextTransaction transaction = db.Database.BeginTransaction()) { try { receive.factory_qty += item.receive_qty; receive.factory_wgh += item.receive_wgh; db.Entry(receive).State = System.Data.Entity.EntityState.Modified; db.receive_item.Add(item); //insert stock var stock = new stock { stock_date = receive.receive_date, stock_no = stock_no, stock_item = item.seq, product_code = item.product_code, stock_qty = item.receive_qty, stock_wgh = item.receive_wgh, ref_document_no = receive.receive_no, ref_document_type = Constants.REV, lot_no = receive.lot_no, location_code = 1, barcode_no = 0, transaction_type = 1, create_by = item.create_by }; if (stockItemRunning == null) { //insert stock_item_running var newStockItem = new stock_item_running { doc_no = receive.receive_no, stock_no = stock_no, stock_item = 1, create_by = item.create_by }; db.stock_item_running.Add(newStockItem); //update document_generate documentGenerate.running += 1; db.Entry(documentGenerate).State = System.Data.Entity.EntityState.Modified; } else { //update stock_item_running stockItemRunning.stock_item += 1; db.Entry(stockItemRunning).State = System.Data.Entity.EntityState.Modified; } db.stocks.Add(stock); db.SaveChanges(); transaction.Commit(); lblMessage.Text = Constants.SAVE_SUCCESS; } catch (Exception) { transaction.Rollback(); throw; } } } //ReceiveItem receiveItem = new ReceiveItem //{ // ReceiveNo = receive.ReceiveNo, // ProductCode = this.productCode, // SexFlag = sexFlag, // ReceiveQty = 1, // ReceiveWgh = lblWeight.Text.ToDecimal(), // CreateBy = "Auto" //}; //return ReceiveController.InsertItem(receiveItem); return true; } catch (Exception) { throw; } }
private void SaveData() { try { var receiveNo = lblReceiveNo.Text; var receiveWgh = lblWeight.Text.ToDecimal(); var receiveQty = lblQty.Text.ToInt16(); var createBy = Helper.GetLocalIPAddress(); using (var db = new SlaughterhouseEntities()) { //int plantID = System.Configuration.ConfigurationManager.AppSettings["plantID"].ToInt16(); //var productionDate = db.plants.Find(plantID).production_date; //update receive var receive = db.receives.Find(receiveNo); //int receive_qty = receive.receive_item.Where(p => p.product_code.Equals(productSelected.product_code)).Sum(p => p.receive_qty); //if (receive.farm_qty - receive_qty == 0) //{ // throw new Exception("จำนวนรับครบแล้ว\rไม่สามารถรับเพิ่มได้!"); //} int seq = receive.receive_item.Where(p => p.barcode_no > 0).Count(); //var receiveByProductBom = db.receive_item_by_product.Find(receiveNo, CoreProductCode, CoreProductCode); //var receiveByProduct = db.receive_item_by_product.Find(receiveNo, CoreProductCode, productSelected.product_code); //if (receiveByProductBom.target_qty - receiveByProduct.actual_qty == 0) //{ // throw new Exception("จำนวนรับครบแล้ว\rไม่สามารถรับเพิ่มได้!"); //} //var maxValue = db.barcodes.Max(x => (long?)x.barcode_no) ?? 0; //if (maxValue == 0) //{ // barcode_no = string.Format("{0}0000000001", plantID).ToLong(); //} //else //{ // barcode_no = maxValue + 1; //} //int count = db.barcodes.Count(); //if (count == 0) //{ // barcode_no = string.Format("{0}0000000001", plantID).ToLong(); //} //else //{ // barcode_no = db.barcodes.Max(p => p.barcode_no) + 1; // if (barcode_no.ToString().Length > 11) // { // var tempBarcode = barcode_no.ToString().TrimStart('1'); // var running = tempBarcode.ToLong(); // var code = running.ToString().PadLeft(10, '0'); // barcode_no = string.Format("{0}{1}", plantID, code).ToLong(); // } //} //int seq = db.receive_item.Where(p => p.receive_no == receive.receive_no).Count(); // seq += 1; barcode_no = Helper.GetMaxBarcode(); var item = new receive_item { receive_no = receive.receive_no, product_code = productSelected.product_code, seq = seq, lot_no = receive.lot_no, sex_flag = "", receive_qty = receiveQty, receive_wgh = receiveWgh, chill_qty = 0, chill_wgh = 0, barcode_no = barcode_no, create_by = createBy }; //string stock_no = ""; //var stockDocument = (from p in db.document_generate where p.document_type == Constants.STK select p).SingleOrDefault(); ////check stock_item_running //var stockItemRunning = db.stock_item_running.Where(p => p.doc_no.Equals(receive.receive_no)).SingleOrDefault(); //if (stockItemRunning == null) //{ // //get new stock doc no // stock_no = Constants.STK + stockDocument.running.ToString().PadLeft(10 - Constants.STK.Length, '0'); //} //else //{ // stock_no = stockItemRunning.stock_no; //} //var stockNo = StockHelper.GetStockNo(receiveNo).stock_no; using (DbContextTransaction transaction = db.Database.BeginTransaction()) { try { //var qrData = string.Format("{0}|00{1}{2}", barcode_no, item.product_code, Convert.ToInt64(receiveWgh * 10000).ToString().PadLeft(6, '0')); //insert barcode var barcode = new barcode { barcode_no = barcode_no, product_code = productSelected.product_code, production_date = productionDate, lot_no = receive.lot_no, qty = receiveQty, wgh = receiveWgh, active = true, create_by = createBy, qrcode_image = Helper.GenerateQRCode(barcode_no.ToString()), //location_code = LocationCode, }; db.barcodes.Add(barcode); db.receive_item.Add(item); //var stocks = new List<stock>(); //stocks.Add(new stock //{ // stock_date = DateTime.Today, // stock_no = stock_no, // stock_item = item.seq, // product_code = item.product_code, // stock_qty = item.receive_qty, // stock_wgh = item.receive_wgh, // ref_document_no = receive.receive_no, // ref_document_type = Constants.REV, // lot_no = receive.lot_no, // location_code = 1, // barcode_no = 0, // transaction_type = 2, // create_by = item.create_by //}); //insert stock //var stock = new stock //{ // stock_date = productionDate, // stock_no = stockNo, // stock_item = seq, // product_code = productSelected.product_code, // stock_qty = receiveQty, // stock_wgh = receiveWgh, // ref_document_no = receive.receive_no, // ref_document_type = Constants.REV, // lot_no = receive.lot_no, // location_code = LocationCode, // barcode_no = barcode_no, // transaction_type = 1, // create_by = createBy //}; //db.stocks.Add(stock); switch (CoreProductCode) { //case "04001": // receive.head_qty += item.receive_qty; // receive.head_wgh += item.receive_wgh; // break; case "00-0101": receive.byproduct_red_qty += receiveQty; receive.byproduct_red_wgh += receiveWgh; break; case "00-0201": receive.byproduct_white_qty += receiveQty; receive.byproduct_white_wgh += receiveWgh; break; } db.Entry(receive).State = System.Data.Entity.EntityState.Modified; //if (CoreProductCode == productSelected.product_code) //{ // //var bomItems = (from a in db.boms // // join b in db.bom_item on a.bom_code equals b.bom_code // // where a.product_code == BomProductCode // // select b).ToList(); // var listOfByProduct = db.receive_item_by_product.Where(p => p.receive_no.Equals(receiveNo) // && p.bom_product_code == CoreProductCode // && p.product_code != CoreProductCode).ToList(); // foreach (var proudct in listOfByProduct) // { // proudct.actual_qty += 1; // proudct.actual_wgh += 1; // //db.Entry(proudct).State = System.Data.Entity.EntityState.Modified; // } // receiveByProductBom.actual_qty += listOfByProduct.Count; // receiveByProductBom.actual_wgh += item.receive_wgh; // //listOfByProduct.ForEach(p => p.actual_qty += item.receive_qty, p.actual_wgh = item.receive_wgh); //} //else //{ // receiveByProductBom.actual_qty += item.receive_qty; // receiveByProductBom.actual_wgh += item.receive_wgh; // receiveByProduct.actual_qty += item.receive_qty; // receiveByProduct.actual_wgh += item.receive_wgh; // //db.Entry(receiveByProduct).State = System.Data.Entity.EntityState.Modified; //} db.SaveChanges(); transaction.Commit(); //PrintBarcode(); } catch (Exception) { transaction.Rollback(); throw; } } } } catch (Exception) { throw; } }
private bool SaveData() { try { decimal receive_wgh = lblWeight.Text.ToDecimal(); string create_by = Helper.GetLocalIPAddress(); using (var db = new SlaughterhouseEntities()) { //update receive var receive = db.receives.Where(p => p.receive_no.Equals(lblReceiveNo.Text)).SingleOrDefault(); int seq = receive.receive_item.Where(p => p.product_code.Equals(product.product_code)).Count(); barcode_no = db.barcodes.Max(p => p.barcode_no) + 1; //int seq = db.receive_item.Where(p => p.receive_no == receive.receive_no).Count(); seq += 1; var item = new receive_item { receive_no = receive.receive_no, product_code = product.product_code, seq = seq, sex_flag = "", lot_no = receive.lot_no, receive_qty = 1, receive_wgh = receive_wgh, chill_qty = 0, chill_wgh = 0, barcode_no = barcode_no, create_by = create_by }; string stock_no = db.stock_item_running.Where(p => p.doc_no.Equals(receive.receive_no)).Select(p => p.stock_no).SingleOrDefault(); using (DbContextTransaction transaction = db.Database.BeginTransaction()) { try { //insert barcode var barcode = new barcode { barcode_no = barcode_no, product_code = item.product_code, production_date = DateTime.Today, lot_no = receive.lot_no, qty = 1, wgh = receive_wgh, create_by = create_by }; db.barcodes.Add(barcode); //insert receive_item db.receive_item.Add(item); //insert stock var stock = new stock { stock_date = DateTime.Today, stock_no = stock_no, stock_item = item.seq, product_code = barcode.product_code, stock_qty = barcode.qty, stock_wgh = barcode.wgh, ref_document_no = receive.receive_no, ref_document_type = Constants.REV, lot_no = barcode.lot_no, location_code = _locationCode, barcode_no = barcode_no, transaction_type = 1, create_by = create_by }; db.stocks.Add(stock); db.SaveChanges(); transaction.Commit(); PrintBarcode(); return(true); } catch (Exception) { transaction.Rollback(); throw; } } } } catch (Exception) { throw; } }
private void SaveData() { try { var weight = lblWeight.Text.ToDecimal(); using (var db = new SlaughterhouseEntities()) { //update receive var receive = db.receives.Find(lblReceiveNo.Text); if (receive.farm_qty - receive.factory_qty == 0) { throw new Exception("ไม่สามารถรับเพิ่มได้! \rจำนวนรับครบแล้ว"); } int seq = receive.receive_item.Count(); //int seq = db.receive_item.Where(p => p.receive_no == receive.receive_no).Count(); seq += 1; //string stock_no = ""; //var stockDocument = (from p in db.document_generate where p.document_type == Constants.STK select p).SingleOrDefault(); ////check stock_item_running //var stockItemRunning = db.stock_item_running.Where(p => p.doc_no.Equals(receive.receive_no)).SingleOrDefault(); //if (stockItemRunning == null) //{ // //get new stock doc no // stock_no = Constants.STK + stockDocument.running.ToString().PadLeft(10 - Constants.STK.Length, '0'); //} //else //{ // stock_no = stockItemRunning.stock_no; //} using (DbContextTransaction transaction = db.Database.BeginTransaction()) { try { var item = new receive_item { receive_no = receive.receive_no, product_code = product.product_code, seq = seq, lot_no = receive.lot_no, sex_flag = sexFlag, receive_qty = 1, receive_wgh = weight, chill_qty = 0, chill_wgh = 0, create_by = createBy }; db.receive_item.Add(item); receive.factory_qty += 1; receive.factory_wgh += weight; receive.receive_flag = 1; db.Entry(receive).State = System.Data.Entity.EntityState.Modified; ////insert stock //var stock = new stock //{ // stock_date = productionDate, // stock_no = stock_no, // stock_item = item.seq, // product_code = item.product_code, // stock_qty = item.receive_qty, // stock_wgh = item.receive_wgh, // ref_document_no = receive.receive_no, // ref_document_type = Constants.REV, // lot_no = receive.lot_no, // location_code = 1, // barcode_no = 0, // transaction_type = 1, // create_by = item.create_by //}; //if (stockItemRunning == null) //{ // //insert stock_item_running // var newStockItem = new stock_item_running // { // doc_no = receive.receive_no, // stock_no = stock_no, // stock_item = 1, // create_by = item.create_by // }; // db.stock_item_running.Add(newStockItem); // //update document_generate // stockDocument.running += 1; // db.Entry(stockDocument).State = System.Data.Entity.EntityState.Modified; //} //else //{ // //update stock_item_running // stockItemRunning.stock_item += 1; // db.Entry(stockItemRunning).State = System.Data.Entity.EntityState.Modified; //} //db.stocks.Add(stock); db.SaveChanges(); transaction.Commit(); lblMessage.Text = Constants.SAVE_SUCCESS; } catch (Exception) { transaction.Rollback(); throw; } } } } catch (Exception) { throw; } }