/// <summary> /// 修改数据到表TblCommodity /// </summary> /// <param name="name" Commodity的U_nam名字</param> /// <param name="commodity">更新成的表</param> public bool UpdataCommoditys(string id, Commodity commodity, string path) { using (WarehouseERPDAL dB = new WarehouseERPDAL()) { try { var model = dB.commoditys.Where(c => c.Co_Id.ToString() == id).FirstOrDefault(); if (model != null && !model.Equals(new Commodity())) { BarCode barCode = new BarCode(); if (model.Co_bar_code != commodity.Co_bar_code) { barCode.DeleteFile(path + model.Co_bar_code + ".jdg"); barCode.Code(commodity.Co_bar_code, path); } Change(ref model, commodity); } dB.SaveChanges(); return(true); } catch (Exception e) { return(false); } } }
/// <summary> /// 移除名称为编号为id的物品 /// </summary> /// <param name="id"></param> public void DeleteCommodity(string id, string path) { //int my_id = Convert.ToInt32(id); WarehouseERPDAL dB = new WarehouseERPDAL(); var model = dB.commoditys.Where(c => c.Co_Id.ToString() == id).FirstOrDefault(); if (model != null && !model.Equals(new Commodity())) { BarCode barCode = new BarCode(); barCode.DeleteFile(path); dB.commoditys.Remove(model); } dB.SaveChanges(); }