//根据外卖客户id修改外卖客户信息 public bool UpdateTakeoutClientInfo(TakeoutClientInfo info) { if (info == null) { return false; } //修改 直接修改 using (ChooseDishesEntities entities = new ChooseDishesEntities()) { try { var type = entities.TakeoutClientInfo.SingleOrDefault(bt => bt.OrderPeopleId == info.OrderPeopleId); if (type != null) { type.Order_people = info.Order_people; type.Mobile = info.Mobile; type.Status = info.Status; type.Telephone = info.Telephone; type.Update_by = info.Update_by; type.Update_datetime = info.Update_datetime; type.Address = info.Address; type.Deleted = info.Deleted; entities.SaveChanges(); return true; } } catch (Exception e) { e.ToString(); return false; } return false; } }
public bool AddTakeoutClientInfo(TakeoutClientInfo info) { if (info == null) { return false; } //添加 using (ChooseDishesEntities entities = new ChooseDishesEntities()) { try { entities.TakeoutClientInfo.Add(info); entities.SaveChanges(); return true; } catch (Exception e) { e.ToString(); return false; } } }
//确定落单 private void CommitOrder() { if (string.IsNullOrEmpty(ContactNumber)) { MessageBox.Show("请填写联系电话"); return; } if (string.IsNullOrEmpty(OrderPeople)) { MessageBox.Show("请填写或者选择订餐人"); return; } if (string.IsNullOrEmpty(Address)) { MessageBox.Show("请填写订餐人地址"); return; } bool flag = false; //1.将订餐人信息插入到外卖客户信息表中 TakeoutClientInfo info = _DataService.FindTakeoutClientByTelephone(ContactNumber); if (info == null) { info = new TakeoutClientInfo() { OrderPeopleId = new Random().Next(1000) + 1, Order_people = OrderPeople, Telephone = ContactNumber, Address = Address, Create_by = SubjectUtils.GetAuthenticationId(), //操作人id Create_datetime = DateTime.Now, Status = 0, Deleted = 0 }; flag = _DataService.AddTakeoutClientInfo(info); } else { info.Order_people = OrderPeople; info.Telephone = ContactNumber; info.Address = Address; info.Status = 0; info.Deleted = 0; info.Update_by = 0; //操作人id info.Update_datetime = DateTime.Now; flag = _DataService.UpdateTakeoutClientInfo(info); } if (flag) { TakeoutOrder to = new TakeoutOrder(); to.OrderPeopleId = info.OrderPeopleId; to.OrderId = 1222; //订单号,去订单中查询获取 to.DeliveryManNum = DeliveryMan; //需要去员工数据库查找确定 to.Num = "Q000"; to.AdvanceAmount = 0; to.DeliverTime = DateTime.Now; //送出时指定 to.SendTime = DateTime.Now; to.Status = 0; //0表示未送出状态,1表示在送出状态,2表示送达未签收状态,3.送达已签收状态 to.Deleted = 0; to.CreateBy = SubjectUtils.GetAuthenticationId(); //操作人id to.CreateDatetime = DateTime.Now; //2.将订单信息插入到订单表中 flag = _DataService.AddTakeoutOrder(to); if (flag) { //关闭所有页面 //通知主线程执行关闭操作 DispatcherHelper.CheckBeginInvokeOnUI(()=>TakeoutOrderWindow.getInstance().Close()); //3.在厨房打印出厨打单 return; } } DispatcherHelper.CheckBeginInvokeOnUI(() => MessageBox.Show("外卖单录入失败")); }
//根据外卖客户id删除外卖客户信息,删除成功则返回true,删除失败则返回false public bool DeletedTakeoutClientInfoById(int id) { if (id < 0) { return false; } using (ChooseDishesEntities entities = new ChooseDishesEntities()) { try { TakeoutClientInfo booktype = new TakeoutClientInfo() { OrderPeopleId = id, }; DbEntityEntry<TakeoutClientInfo> entry = entities.Entry<TakeoutClientInfo>(booktype); entry.State = EntityState.Deleted; entities.SaveChanges(); return true; } catch (Exception e) { e.ToString(); return false; } } }