public int 菜品信息_AddNew(菜品信息EditModel model) { int _count = 0; using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required)) { using (var context = new BDKRContext()) { var r = new Repository<货品信息>(context); var e = r.GetSingle(t => t.编码 == model.编码); if (null != e) throw new Exception("菜品信息当前已存在"); e = new 货品信息 { 单位 = model.单位, 名称 = model.菜品名称, 备注 = model.附加说明, 拼音 = UtilHelper.PinYin(model.菜品名称), 是否菜品 = true, 编码 = model.编码, 规格 = model.规格, 货品类别编码 = model.菜品类别 }; if (model.当前销售价格 > 0) { var cj = new 销售价格表 { 价格 = model.当前销售价格, 创建时间 = DateTime.Now, 编码 = 销售价格_GetNewCode(), 货品信息编码 = model.编码, 附加说明 = "" }; var _jg = new Repository<销售价格表>(context); _jg.AddNew(cj); } _count = r.AddNew(e); if (model.Details != null && model.Details.Count > 0) { var _bcode = 货品BOM_GetNewCode(); } } ts.Complete(); } return _count; }
public List<门店ViewModel> 门店信息_GetList() { using (var context = new BDKRContext()) { var rep = new Repository<门店信息>(context); return rep.GetList<门店ViewModel>(t => t.ConvertToViewModel()); } }
public int 门店信息_Delete(string 门店编码) { using (var context = new BDKRContext()) { var r = new Repository<门店信息>(context); var e = r.GetSingle(t => t.编码 == 门店编码); if (null == e) throw new Exception("门店信息并不存在"); if (e.仓库信息List != null && e.仓库信息List.Count > 0) throw new Exception("门店所属仓库信息存在"); if (e.员工信息List != null && e.员工信息List.Count > 0) throw new Exception("门店所属员工信息存在"); if (e.实时库存明细List != null && e.实时库存明细List.Count > 0) throw new Exception("门店所属实时库存信息存在"); if (e.收支费用流水清单List != null && e.收支费用流水清单List.Count > 0) throw new Exception("门店所属收支费用明细表存在"); if (e.日常费用明细表List != null && e.日常费用明细表List.Count > 0) throw new Exception("门店所属日常费用明细表存在"); if (e.菜品销售单List != null && e.菜品销售单List.Count > 0) throw new Exception("门店所属菜品销售单存在"); if (e.费用汇总表List != null && e.费用汇总表List.Count > 0) throw new Exception("门店所属费用汇总表存在"); if (e.采购进货单List != null && e.采购进货单List.Count > 0) throw new Exception("门店所属采购进货单存在"); if (e.餐厅损益表List != null && e.餐厅损益表List.Count > 0) throw new Exception("门店所属餐厅损益表存在"); return r.Remove(e, t => t.编码 == 门店编码); } }
public int 仓库信息_Update(仓库EditModel model) { using (var context = new BDKRContext()) { var r = new Repository<仓库信息>(context); var e = r.GetSingle(t => t.编码 == model.编码); if (null == e) throw new Exception("该仓库信息并不存在"); e.仓库名称 = model.仓库名称; e.仓库类别编码 = model.类别编码; e.制品缓冲库 = model.制品缓冲库; //e.门店信息编码 = model.门店编码; e.附件说明 = model.附加说明; return r.Edit(e); } }
public List<仓库ViewModel> 仓库信息_GetList(仓库Filter filter) { using (var context = new BDKRContext()) { var rep = new Repository<仓库信息>(context); return rep.GetList<仓库ViewModel>(t => t.ConvertToViewModel(), t => { if (filter != null) { if (filter.关键词.Length > 0 && !filter.关键词.Contains(t.仓库名称)) return false; } return true; }); } }
public string 销售价格_GetNewCode() { using (var context = new BDKRContext()) { var r = new Repository<销售价格表>(context); var maxcode = r.Max<string>(t => t.编码, t => t.编码.StartsWith("XJ")) ?? "XJ0000"; return "XJ" + (int.Parse(maxcode.Substring(2)) + 1).ToString("0000"); } }
public string 货品BOM明细_GetNewCode() { using (var context = new BDKRContext()) { var r = new Repository<货品BOM明细>(context); var maxcode = r.Max<string>(t => t.编码, t => t.编码.StartsWith("BMD0000")) ?? "BMD0000"; return "BMD" + (int.Parse(maxcode.Substring(3)) + 1).ToString("0000"); } }
public int 货品类别_Delete(string 货品类别编码) { using (var context = new BDKRContext()) { var r = new Repository<货品类别>(context); var e = r.GetSingle(t => t.编码 == 货品类别编码); if (null == e) throw new Exception("该类别信息并不存在"); return r.Remove(e, t => t.编码 == 货品类别编码); } }
public int 货品信息_AddNew(货品信息EditModel model) { using (var context = new BDKRContext()) { var r = new Repository<货品信息>(context); var n = new 货品信息 { 单位 = model.单位, 名称 = model.货品名称, 备注 = model.附加说明, 拼音 = UtilHelper.PinYin(model.货品名称), 是否菜品 = false, 编码 = model.编码, 规格 = model.规格型号, 货品类别编码 = model.货品类别 }; //TODO:未考虑价格因素 return r.AddNew(n, t => t.编码 == model.编码); } }
public int 货品类别_AddNew(货品类别EditModel model) { using (var context = new BDKRContext()) { var r = new Repository<货品类别>(context); var n = new 货品类别 { 编码 = model.编码, 名称 = model.类别名称, 备注 = model.备注信息 }; return r.AddNew(n, t => t.编码 == model.编码); } }
public int 货品类别_Update(货品类别EditModel model) { using (var context = new BDKRContext()) { var r = new Repository<货品类别>(context); var e = r.GetSingle(t => t.编码 == model.编码); if (null == e) throw new Exception("该类别信息并不存在"); return r.Edit(e, t => t.编码 == model.编码); } }
public string 货品类别_GetNewCode() { using (var context = new BDKRContext()) { var r = new Repository<货品类别>(context); var maxcode = r.Max(t => t.编码, t => t.编码.StartsWith("LB")) ?? "LB000"; var _max = int.Parse(maxcode.Substring(2)); return "LB" + (_max + 1).ToString("000"); } }
public List<货品类别ViewModel> 货品类别_GetList() { using (var context = new BDKRContext()) { var list = new List<货品类别ViewModel>(); context.货品类别S.ToList() .ForEach(t => { list.Add(t.ConvertToViewModel()); }); return list; } }
public void 门店信息_Update(门店EditModel model) { using (var context = new BDKRContext()) { var r = new Repository<门店信息>(context); var e = r.GetSingle(t => t.编码 == model.编码); if (null == e) throw new Exception("门店信息并不存在"); r.Edit(e, t => t.编码 == model.编码); } }
public List<菜品信息ViewModel> 菜品信息_GetList(菜品信息Filter filter) { using (var context = new BDKRContext()) { var q = from t in context.货品信息S where t.是否菜品 == true select t; if (filter.关键词 != null && filter.关键词.Length > 0) q = from t in q where (t.名称 != null && t.名称.Contains(filter.关键词)) || (t.拼音 != null && t.拼音.Contains(filter.关键词)) select t; if (filter.菜品类别编码 != null && filter.菜品类别编码.Length > 0) q = from t in q where (filter.菜品类别编码.Contains(t.货品类别编码)) select t; var list = new List<菜品信息ViewModel>(); q.ToList() .ForEach(t => { list.Add(t.ConvertToViewModel_菜品信息()); }); return list; } }
public List<货品信息ViewModel> 货品信息_GetList(货品信息Filter filter) { using (var context = new BDKRContext()) { var q = from t in context.货品信息S select t; if (filter.关键词 != null && filter.关键词.Length > 0) q = from t in q where (t.名称 != null && t.名称.Contains(filter.关键词)) || (t.拼音 != null && t.拼音.Contains(filter.关键词)) select t; if (filter.货品类别编码 != null && filter.货品类别编码.Length > 0) { q = from t in q where filter.货品类别编码.Contains(filter.货品类别编码) select t; } //TODO:价格区间暂时未做 var list = new List<货品信息ViewModel>(); q.ToList() .ForEach(t => { list.Add(t.ConvertToViewModel()); }); return list; } }
public int 销售价格_AddNew(销售价格EditModel model) { using (var context = new BDKRContext()) { var _货品 = context.货品信息S.FirstOrDefault(t => t.编码 == model.货品信息编码); if (null == _货品) throw new Exception("菜品信息并不存在"); var _o = context.销售价格表S.Where(t => t.货品信息编码 == model.货品信息编码) .OrderByDescending(t => t.创建时间).FirstOrDefault(); if (null == _o || _o.价格 != model.当前销售价格) { var _n = new 销售价格表 { 价格 = model.当前销售价格, 创建时间 = DateTime.Now, 编码 = model.编码, 货品信息编码 = model.货品信息编码, 附加说明 = model.附加说明 }; context.销售价格表S.Add(_n); } return context.SaveChanges(); } }
public int 货品信息_Delete(string 货品信息编码) { using (var context = new BDKRContext()) { var r = new Repository<货品信息>(context); var e = r.GetSingle(t => t.编码 == 货品信息编码); if (null == e) throw new Exception("货品信息并不存在"); if (e.实时库存List != null && e.实时库存List.Count > 0) throw new Exception("实时库存存在此货品信息"); if (e.货品BOMList != null && e.货品BOMList.Count > 0) throw new Exception("货品BOM中存在此货品信息"); if (e.采购进货单明细List != null && e.采购进货单明细List.Count > 0) throw new Exception("采购进货单明细中存在此货品信息"); return r.Remove(e, t => t.编码 == 货品信息编码); } }
public void 货品BOM_AddNew(货品BOMEditModel model) { using (var trans = new TransactionScope(TransactionScopeOption.Required)) { using (var context = new BDKRContext()) { var bom = new 货品BOM { 备注 = model.附加说明, 更新时间 = DateTime.Now, 编码 = model.编码, 货品信息编码 = model.货品信息编码, 过期时间 = null }; context.货品BOMS.Add(bom); context.SaveChanges(); if (model.Details != null && model.Details.Count > 0) { model.Details.ForEach(t => { var _n = new 货品BOM明细 { 单份数量 = t.单份数量, 单位 = t.单位, 编码 = 货品BOM明细_GetNewCode(), 货品BOM编码 = model.编码, 货品信息编码 = t.货品信息编码 }; context.货品BOM明细S.Add(_n); context.SaveChanges(); }); } } trans.Complete(); } }
public void 员工信息_AddNew(员工信息EditModel model) { using (var context = new BDKRContext()) { var r = new Repository<员工信息>(context); var n = new 员工信息 { 入职日期 = model.入职日期, 姓名 = model.员工姓名, 工号 = model.工号, 当前基本工资 = model.当前基本工资, 拼音 = UtilHelper.PinYin(model.员工姓名), 编码 = model.编码, 职位 = model.职位, 联系电话 = model.联系电话, 身份证号 = model.身份证号, 门店编码 = model.门店编码, 附加说明 = model.附加说明 }; r.AddNew(n, t => t.编码 == model.编码); } }
public int 仓库信息_AddNew(仓库EditModel model) { using (var context = new BDKRContext()) { var n = new 仓库信息 { 仓库名称 = model.仓库名称, 仓库类别编码 = model.类别编码, 制品缓冲库 = model.制品缓冲库, 编码 = model.编码, 门店信息编码 = model.门店编码, 附件说明 = model.附加说明 }; context.仓库信息S.Add(n); return context.SaveChanges(); } }
public void 员工信息_Delete(string 员工信息编码) { using (var context = new BDKRContext()) { var r = new Repository<员工信息>(context); var e = r.GetSingle(t => t.编码 == 员工信息编码); if (null == e) throw new Exception("该员工信息不存在"); r.Remove(e, t => t.编码 == 员工信息编码); } }
public int 仓库信息_Delete(string 仓库信息编码) { using (var context = new BDKRContext()) { var r = new Repository<仓库信息>(context); var e = r.GetSingle(t => t.编码 == 仓库信息编码); if (null == e) throw new Exception("仓库信息并不存在"); if (e.实时库存明细List != null && e.实时库存明细List.Count > 0) throw new Exception("实时库存中含有此仓库信息,无法删除!"); if (e.采购进货单明细List != null && e.采购进货单明细List.Count > 0) throw new Exception("采购进货单明细中含有此仓库信息,无法删除!"); return r.Remove(e); } }
public List<员工信息ViewModel> 员工信息_GetList(员工信息Filter filter) { using (var context = new BDKRContext()) { var q = from t in context.员工信息S select t; if (filter.关键词 != null && filter.关键词.Length > 0) q = from t in q where (t.姓名 != null && t.姓名.Contains(filter.关键词)) || (t.拼音 != null && t.拼音.Contains(filter.关键词)) || (t.工号 != null && t.工号.Contains(filter.关键词)) || (t.联系电话 != null && t.联系电话.Contains(filter.关键词)) || (t.身份证号 != null && t.身份证号.Contains(filter.关键词)) select t; if (filter.门店编码 != null && filter.门店编码.Length > 0) q = from t in q where filter.门店编码.Contains(t.门店编码) select t; var list = new List<员工信息ViewModel>(); q.ToList() .ForEach(t => { list.Add(t.ConvertToViewModel()); }); return list; } }
public 仓库EditModel 仓库信息_GetEditModelById(string 仓库信息编码) { using (var context = new BDKRContext()) { var r = new Repository<仓库信息>(context); var e = r.GetSingle(t => t.编码 == 仓库信息编码); if (null != e) return e.ConvertToEditModel(); return null; } }
public void 员工信息_Update(员工信息EditModel model) { using (var context = new BDKRContext()) { var r = new Repository<员工信息>(context); var e = r.GetSingle(t => t.编码 == model.编码); if (null == e) throw new Exception("员工信息并不存在"); if (e.姓名 != model.员工姓名) e.拼音 = UtilHelper.PinYin(model.员工姓名); e.姓名 = model.员工姓名; e.入职日期 = model.入职日期; e.工号 = model.工号; e.当前基本工资 = model.当前基本工资; e.职位 = model.职位; e.联系电话 = model.联系电话; e.身份证号 = model.身份证号; e.门店编码 = model.门店编码; e.附加说明 = model.附加说明; r.Edit(e, t => t.编码 == model.编码); } }
public string 门店信息_GetNewCode() { using (var context = new BDKRContext()) { var rep = new Repository<门店信息>(context); var maxcode = rep.Max<string>(t => t.编码, t => t.编码.StartsWith("MD")) ?? "MD00"; var _max = int.Parse(maxcode.Substring(2)); return string.Format("MD{0}", (_max + 1).ToString("00")); } }
public void 门店信息_AddNew(门店EditModel model) { using (var context = new BDKRContext()) { var r = new Repository<门店信息>(context); var n = new 门店信息 { 名称 = model.门店名称, 地址 = model.门店地址, 备注 = model.附加说明, 店长 = model.店长, 编码 = model.编码, 联系电话 = model.联系电话 }; r.AddNew(n, t => t.编码 == model.编码); } }