//修改收银方式 返回修改成功后的方式 public CashType updateCashType(CashType cashType) { try { if (cashType == null || cashType.Id == 0) { return null; } using (ChooseDishesEntities entities = new ChooseDishesEntities()) { //先查询 后修改 var type = entities.CashType.SingleOrDefault(bt => bt.Id == cashType.Id); if (type != null) { if (!type.Keys.Equals(cashType.Keys)) { var type1 = entities.CashType.Where(bt => bt.Keys == cashType.Keys).ToList(); if (type1.Count > 1) { return null; } } type.IsBillIncome = cashType.IsBillIncome; type.IsPaid = cashType.IsPaid; type.IsPrivilege = cashType.IsPrivilege; type.IsScore = cashType.IsScore; type.KeepRecharge = cashType.KeepRecharge; type.Keys = cashType.Keys; type.LossesUsing = cashType.LossesUsing; type.Name = cashType.Name; type.Rate = cashType.Rate; type.ReceptionUseing = cashType.ReceptionUseing; type.RechargeUsing = cashType.RechargeUsing; type.Status = cashType.Status; type.SupplierUsing = cashType.SupplierUsing; type.UpdateBy = type.UpdateBy; type.UpdateDatetime = DateTime.Now; type.UseingKeys = cashType.UseingKeys; entities.SaveChanges(); } } return cashType; } catch (Exception e) { e.ToString(); return null; } }
public CashType CreateCashType(CashTypeBean cashType) { CashType ct = new CashType(); ct.AllDiscount = cashType.AllDiscount; ct.CashBaseTypeId = cashType.CashBaseTypeId; ct.Code = cashType.Code; ct.CreateBy = cashType.CreateBy; ct.CreateDatetime = cashType.CreateDatetime; ct.Deleted = cashType.Deleted; ct.Id = cashType.Id; ct.IsBillIncome = cashType.IsBillIncome; ct.IsPaid = cashType.IsPaid; ct.IsPrivilege = cashType.IsPrivilege; ct.IsScore = cashType.IsScore; ct.KeepRecharge = cashType.KeepRecharge; ct.Keys = cashType.Keys; ct.LossesUsing = cashType.LossesUsing; ct.Name = cashType.Name; ct.Rate = cashType.Rate; ct.ReceptionUseing = cashType.ReceptionUseing; ct.RechargeUsing = cashType.RechargeUsing; ct.Status = cashType.Status; ct.SupplierUsing = cashType.SupplierUsing; ct.UpdateBy = cashType.UpdateBy; ct.UpdateDatetime = cashType.UpdateDatetime; ct.UseingKeys = cashType.UseingKeys; return ct; }
//添加收银方式 返回添加成功后的收银方式 public CashType addCashType(CashType cashType) { //try //{ if (cashType == null) { return null; } CashType newCashType = null; using (ChooseDishesEntities entities = new ChooseDishesEntities()) { //快捷键不能相同 编号不能相同 var list = entities.CashType.Where(bt =>bt.Deleted==0 && (bt.Code == cashType.Code) || (bt.Keys == cashType.Keys)).ToList() ; if (list != null&&list.Count>0) { return null; } entities.CashType.Add(cashType); entities.SaveChanges(); var typenew = entities.CashType.SingleOrDefault(bt => bt.Code == cashType.Code); if (typenew != null) { newCashType = typenew; } } return newCashType; //} //catch (Exception e) //{ // e.ToString(); // return null; //} }
public CashTypeBean CreateCashTypeBean(CashType cashType) { this.AllDiscount = cashType.AllDiscount; this.CashBaseTypeId = cashType.CashBaseTypeId; this.Code = cashType.Code; this.CreateBy = cashType.CreateBy; this.CreateDatetime = cashType.CreateDatetime; this.Deleted = cashType.Deleted; this.Id = cashType.Id; this.IsBillIncome = cashType.IsBillIncome; this.IsPaid = cashType.IsPaid; this.IsPrivilege = cashType.IsPrivilege; this.IsScore = cashType.IsScore; this.KeepRecharge = cashType.KeepRecharge; this.Keys = cashType.Keys; this.LossesUsing = cashType.LossesUsing; this.Name = cashType.Name; this.Rate = cashType.Rate; this.ReceptionUseing = cashType.ReceptionUseing; this.RechargeUsing = cashType.RechargeUsing; this.Status = cashType.Status; this.SupplierUsing = cashType.SupplierUsing; this.UpdateBy = cashType.UpdateBy; this.UpdateDatetime = cashType.UpdateDatetime; this.UseingKeys = cashType.UseingKeys; this.CashBaseTypeName = TiQuName(cashType.CashBaseTypeId); return this; }