public static bool Delete(int ID) { using (var context = new Connection.Model.BarcodeEntity()) { try { context.TblBarcode.Remove(context.TblBarcode.Find(ID)); context.SaveChanges(); return(true); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); return(false); } } }
public static bool Create(Connection.Model.TblBarcode AllGoodsInstance) { using (var context = new Connection.Model.BarcodeEntity()) { try { context.TblBarcode.Add(AllGoodsInstance); context.SaveChanges(); return(true); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); return(false); } } }
public static bool Update(Connection.Model.TblInventory ObjectName) { using (var context = new Connection.Model.BarcodeEntity()) { try { var Ins = context.TblInventory.Where(a => a.Shka == ObjectName.Shka).FirstOrDefault(); Ins.Name = ObjectName.Name; context.SaveChanges(); return(true); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); return(false); } } }
public static bool Delete(int ID) { using (var context = new Connection.Model.BarcodeEntity()) { try { if (context.TblBarcode.Any(a => a.GoodsID == ID)) { System.Windows.Forms.MessageBox.Show("براي اين كالا باركد تعريف شده است، ابتدا باركدها را حذف نماييد"); return(false); } context.TblInventory.Remove(context.TblInventory.Find(ID)); context.SaveChanges(); return(true); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); return(false); } } }