You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1025 lines
36 KiB
C#

9 months ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using DevComponents.DotNetBar.Controls;
using DevComponents.DotNetBar.Keyboard;
using DevComponents.DotNetBar.Metro;
using DevComponents.DotNetBar.SuperGrid;
using POSV.Entity;
using POSV.ShoppingCart;
using POSV.Utils;
namespace POSV.WaiMai
{
public partial class DeliveryForm : BusinessForm
{
/// <summary>
/// 当前操作
/// </summary>
private DeliveryOperator _currentOperator = DeliveryOperator.;
//当前订单对象
private OrderObject _orderObject;
//当前传入的来电号码
private string _telphone = string.Empty;
//当前选择的熟客对象
private Visitor _currentVisitor = null;
//当前熟客的选择的地址
private VisitorAddress _currentAddress = null;
//当前送餐员工
private Worker _currentWorker = null;
private bool _useOtherPrice = false;
//当前熟客的可用地址列表
private List<VisitorAddress> _address = null;
public DeliveryForm(OrderObject orderObject, string telphone)
{
InitializeComponent();
this._orderObject = orderObject;
this._telphone = telphone;
this.txtTelphone.Multiline = false;
this.txtCustomer.Multiline = false;
this.txtAddress.Multiline = false;
this.txtWorker.Multiline = false;
this.txtAmount.Multiline = false;
this.txtMemo.Multiline = false;
this.txtLinker.Multiline = false;
this.txtPhone.Multiline = false;
this.superTabControl.TabsVisible = false;
this.Height = this.Height - 30;
this.txtTelphone.GotFocus += OnGotFocus;
this.txtCustomer.GotFocus += OnGotFocus;
this.txtAddress.GotFocus += OnGotFocus;
this.txtWorker.GotFocus += OnGotFocus;
this.txtAmount.GotFocus += OnGotFocus;
this.txtMemo.GotFocus += OnGotFocus;
this.txtLinker.GotFocus += OnGotFocus;
this.txtPhone.GotFocus += OnGotFocus;
}
private void OnGotFocus(object sender, EventArgs e)
{
KeyboardType keyboardType = KeyboardType.;
Type type = sender.GetType();
PropertyInfo pinfo = type.GetProperty("Keyboard");
if (pinfo != null)
{
keyboardType = (KeyboardType)pinfo.GetValue(sender, null);
}
switch (keyboardType)
{
case KeyboardType.:
{
this.chkEnglish.Checked = true;
}
break;
case KeyboardType.:
{
this.chkChinese.Checked = true;
}
break;
case KeyboardType.:
{
this.chkNumber.Checked = true;
}
break;
}
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
this.controlBox.ForeColor = Color.White;
this.controlBox.Text = "外送登记单";
this.RefreshUi();
//开关设置使用外送价
var useOtherPriceSet = Global.Instance.GlobalConfigBoolValue(ConfigConstant.CONFIG_CASHIER_WSORDERUSEOTHERPRICE, false);
if (useOtherPriceSet)
{
bool promotionExist = false;
foreach (var item in this._orderObject.Items.Where(f => f.RowState != OrderRowState.))
{
if (item.Promotions != null && item.Promotions.Count > 0)
{
//存在优惠
promotionExist = true;
this.ShowToastNotify(this, "存在优惠,当前使用正常销售价格");
break;
}
}
//不存在优惠,使用外送价
var tempOrderObject = ObjectUtils.Copy(this._orderObject);
foreach (var item in tempOrderObject.Items)
{
item.Promotions.Clear();
item.Discount = 0;
item.DiscountPrice = item.OtherPrice;
item.Price = item.OtherPrice;
if (item.RowState == OrderRowState.)
{
List<OrderItem> itemDetail = _orderObject.Items.FindAll(x => x.RowState == OrderRowState. && x.ParentId == item.Id);
foreach (OrderItem items in itemDetail)
{
item.Price += items.SuitAddPrice;
}
}
}
//总金额
this.lblTotalAmount.Text = string.Format(this.lblTotalAmount.Tag.ToString(), tempOrderObject.Amount);
//优惠金额
this.lblConcessionaryAmount.Text = string.Format(this.lblConcessionaryAmount.Tag.ToString(), tempOrderObject.DiscountAmount);
//应收金额
this.lblReceivableAmount.Text = string.Format(this.lblReceivableAmount.Tag.ToString(), tempOrderObject.ReceivableAmount);
_useOtherPrice = true;
}
//不适用外送价,填充普通售价
//if (!_useOtherPrice)
//{
// //总金额
// this.lblTotalAmount.Text = string.Format(this.lblTotalAmount.Tag.ToString(), this._orderObject.Amount);
// //优惠金额
// this.lblConcessionaryAmount.Text = string.Format(this.lblConcessionaryAmount.Tag.ToString(), this._orderObject.DiscountAmount);
// //应收金额
// this.lblReceivableAmount.Text = string.Format(this.lblReceivableAmount.Tag.ToString(), this._orderObject.ReceivableAmount);
//}
this.keyboardControl.Renderer = new ThreeDRenderer();
//如果没有电话号码
if (string.IsNullOrEmpty(this._telphone))
{
this.txtTelphone.Text = string.Empty;
this.chkNumber.Checked = true;
this.txtCustomer.Text = string.Empty;
this.txtAddress.Text = string.Empty;
this.txtLinker.Text = string.Empty;
this.txtPhone.Text = string.Empty;
}
else
{
this.txtTelphone.Text = this._telphone;
var result = GetVisitor(this._telphone);
//当前熟客信息
this._currentVisitor = result.Item1;
//熟客的地址列表
this._address = result.Item2;
//熟客默认选择的地址
if (this._address != null && this._address.Count > 0)
{
this._currentAddress = this._address[0];
}
}
//配送员是否设置默认收银员自己
var deliveryOrderSelf = Global.Instance.GlobalConfigBoolValue(ConfigConstant.CONFIG_CASHIER_DELIVERY_ORDER_SELF, true);
if (deliveryOrderSelf)
{
//默认自己为配送员
this._currentWorker = Global.Instance.Worker;
string worker = string.Empty;
if (this._currentWorker != null)
{
worker = this._currentWorker.Name;
}
this.txtWorker.Text = worker;
}
this.superTabControl.SelectedTab = null;
this.superTabControl.SelectedTab = this.tabNew;
this.txtTelphone.Focus();
}
/// <summary>
/// 调整操作Tab项
/// </summary>
private void RefreshUi()
{
switch (this._currentOperator)
{
case DeliveryOperator.:
{
this.tabNew.Visible = true;
this.tabDelivery.Visible = false;
this.tabAddress.Visible = false;
this.tabWorker.Visible = false;
this.superTabControl.SelectedTab = null;
this.superTabControl.SelectedTab = this.tabNew;
}
break;
case DeliveryOperator.:
{
this.tabNew.Visible = false;
this.tabDelivery.Visible = true;
this.tabAddress.Visible = false;
this.tabWorker.Visible = false;
this.superTabControl.SelectedTab = null;
this.superTabControl.SelectedTab = this.tabDelivery;
}
break;
case DeliveryOperator.:
{
this.tabNew.Visible = false;
this.tabDelivery.Visible = false;
this.tabAddress.Visible = true;
this.tabWorker.Visible = false;
this.superTabControl.SelectedTab = null;
this.superTabControl.SelectedTab = this.tabAddress;
}
break;
case DeliveryOperator.:
{
this.tabNew.Visible = false;
this.tabDelivery.Visible = false;
this.tabAddress.Visible = false;
this.tabWorker.Visible = true;
this.superTabControl.SelectedTab = null;
this.superTabControl.SelectedTab = this.tabWorker;
}
break;
}
}
private void KeyboardChanged(object sender, EventArgs e)
{
var item = sender as CheckBoxX;
if (item.Checked)
{
KeyboardType type = KeyboardType.;
Enum.TryParse<KeyboardType>(item.Tag.ToString(), out type);
switch (type)
{
case KeyboardType.:
{
this.lblInputLanguage.Visible = true;
var lang = InputLanguage.FromCulture(CultureInfo.GetCultureInfo("zh-CN"));
InputLanguage.CurrentInputLanguage = lang;
this.keyboardControl.Keyboard = Keyboard.CreateDefaultKeyboard();
}
break;
case KeyboardType.:
{
this.lblInputLanguage.Visible = false;
var lang = InputLanguage.FromCulture(CultureInfo.GetCultureInfo("en-US"));
InputLanguage.CurrentInputLanguage = lang;
this.keyboardControl.Keyboard = Keyboard.CreateDefaultKeyboard();
}
break;
case KeyboardType.:
{
this.lblInputLanguage.Visible = false;
this.keyboardControl.Keyboard = CreateNumericKeyboard();
}
break;
}
}
this.keyboardControl.Invalidate();
}
private Keyboard CreateNumericKeyboard()
{
Keyboard keyboard = new Keyboard();
LinearKeyboardLayout layout = new LinearKeyboardLayout();
layout.AddKey("7");
layout.AddKey("8");
layout.AddKey("9");
//layout.AddKey("+" , "{ADD}" , height: 21);
layout.AddKey("Backspace", "{BACKSPACE}", height: 21);
layout.AddLine();
layout.AddKey("4");
layout.AddKey("5");
layout.AddKey("6");
layout.AddLine();
layout.AddKey("1");
layout.AddKey("2");
layout.AddKey("3");
layout.AddKey("Enter", "{ENTER}", height: 21);
layout.AddLine();
layout.AddKey("0", width: 21);
layout.AddKey(".");
keyboard.Layouts.Add(layout);
return keyboard;
}
private void OnChangedLanguage(object sender, EventArgs e)
{
InputSimulatorUtils.SendCtrlShift();
}
private void OnControlBoxCloseClick(object sender, EventArgs e)
{
if (this.Owner != null)
{
this.Owner.Close();
}
this.Close();
}
private void OnTelphoneEnterClick(object sender, Component.EnterEventArg e)
{
OnTelphoneSearchClick(sender, e);
}
private void OnTelphoneSearchClick(object sender, EventArgs e)
{
List<VisitorAddress> visitorAddressList = new List<VisitorAddress>();
using (var db = Global.Instance.OpenDataBase)
{
if (string.IsNullOrEmpty(this.txtTelphone.Text.Trim()))
{
visitorAddressList = db.Query<VisitorAddress>().Include<Visitor>(x => x.Visitor).OrderByDescending(x => x.CreateDate).ToList();
}
else
{
//var sql = @"select v.*, a.address as LastAddress from pos_visitor v
// left join pos_visitor_address a on v.id = a.visitorId
// where tel like '%{0}%';";
//visitors = db.Query<Visitor>("where tel like '%"+ this.txtTelphone.Text.Trim() + "%'").ToList();
//visitors = db.Query<Visitor>().Include(x => x.Address).Where("tel like '%" + this.txtTelphone.Text.Trim() + "%'").ToList();
visitorAddressList = db.Query<VisitorAddress>().Include<Visitor>(x => x.Visitor, "vi").Where("vi.tel like '%" + this.txtTelphone.Text.Trim() + "%'").OrderByDescending(x => x.CreateDate).ToList();
}
}
var list = visitorAddressList.Where(x => x.Visitor != null).Select(x => new { x.VisitorId, x.Visitor.Name, x.Visitor.Tel, x.Address, x.Id }).ToArray();
this.deliveryGrid.PrimaryGrid.DataSource = list;
if (visitorAddressList.Count > 0)
{
//只查到一个熟客,直接加载,不经过熟客选择
if (visitorAddressList.Count == 1)
{
this._currentVisitor = visitorAddressList[0].Visitor;
if (this._currentVisitor != null)
{
//using (var db = Global.Instance.OpenDataBase)
//{
// this._address = db.Query<VisitorAddress>("where visitorId = @0 order by createDate desc" , this._currentVisitor.Id).ToList();
//}
this._currentAddress = visitorAddressList[0];
}
this.superTabControl.SelectedTab = null;
this._currentOperator = DeliveryOperator.;
this.RefreshUi();
}
else
{
this.superTabControl.SelectedTab = null;
this._currentOperator = DeliveryOperator.;
this.RefreshUi();
}
}
else
{
this._currentVisitor = null;
this._currentAddress = null;
this.superTabControl.SelectedTab = null;
this._currentOperator = DeliveryOperator.;
this.RefreshUi();
}
}
private void OnTabChanged(object sender, DevComponents.DotNetBar.SuperTabStripSelectedTabChangedEventArgs e)
{
var tab = this.superTabControl.SelectedTab;
var opt = DeliveryOperator.;
Enum.TryParse(tab.Tag.ToString(), out opt);
switch (opt)
{
case DeliveryOperator.:
{
if (this._currentVisitor != null)
{
this.txtTelphone.Text = this._currentVisitor.Tel;
this.txtCustomer.Text = this._currentVisitor.Name;
string address = string.Empty;
string linker = string.Empty;
string phone = string.Empty;
if (this._currentAddress != null)
{
address = this._currentAddress.Address;
linker = this._currentAddress.Name;
phone = this._currentAddress.Telephone;
}
this.txtAddress.Text = address;
this.txtLinker.Text = linker;
this.txtPhone.Text = phone;
}
string worker = string.Empty;
if (this._currentWorker != null)
{
worker = this._currentWorker.Name;
}
this.txtWorker.Text = worker;
}
break;
case DeliveryOperator.:
{
}
break;
case DeliveryOperator.:
{
if (this._address == null)
{
this._address = new List<VisitorAddress>();
}
this.addressGrid.PrimaryGrid.DataSource = this._address;
}
break;
case DeliveryOperator.:
{
List<Worker> lists = new List<Worker>();
using (var db = Global.Instance.OpenDataBase)
{
lists = db.Query<Worker>().ToList();
}
this.itemPanel.Items.Clear();
ItemContainer ic = new ItemContainer();
ic.MultiLine = true;
ic.ItemSpacing = 2;
ic.TitleStyle.Class = "MetroTileGroupTitle";
foreach (var entity in lists)
{
MetroTileItem item = new MetroTileItem();
item.TileStyle.PaddingLeft = item.TileStyle.PaddingRight = -2;
item.CheckBehavior = eMetroTileCheckBehavior.LeftMouseButtonClick;
item.Checked = false;
item.OptionGroup = "WORKER";
item.TileStyle.Font = Constant.BIG_FONT;
item.TileStyle.TextAlignment = eStyleTextAlignment.Center;
item.Text = entity.Name;
item.TileSize = new Size(100, 60);
item.TileColor = eMetroTileColor.Coffee;
item.TileStyle.TextColor = Color.White;
item.TileStyle.BorderColor = Color.Transparent;
item.TileStyle.BorderColor2 = Color.Transparent;
item.Tag = entity;
item.MouseDown += OnWorkerMouseDown;
ic.SubItems.Add(item);
}
this.itemPanel.Items.Add(ic);
this.itemPanel.Invalidate();
}
break;
}
}
private void OnWorkerMouseDown(object sender, MouseEventArgs e)
{
MetroTileItem item = (MetroTileItem)sender;
item.Checked = false;
var worker = item.Tag as Worker;
this._currentWorker = worker;
this.superTabControl.SelectedTab = null;
this._currentOperator = DeliveryOperator.;
this.RefreshUi();
}
private void OnButtonBackClick(object sender, EventArgs e)
{
this.superTabControl.SelectedTab = null;
this._currentOperator = DeliveryOperator.;
this.RefreshUi();
}
private void OnAddressSearchClick(object sender, EventArgs e)
{
this.superTabControl.SelectedTab = null;
this._currentOperator = DeliveryOperator.;
this.RefreshUi();
}
private void OnDeliveryGridRowActivated(object sender, DevComponents.DotNetBar.SuperGrid.GridRowActivatedEventArgs e)
{
if (e.NewActiveRow != null && e.NewActiveRow is GridRow)
{
var gridRow = e.NewActiveRow as GridRow;
var visitorId = gridRow.Cells["id"].Value.ToString();
var addressId = gridRow.Cells["addressId"].Value.ToString();
if (!string.IsNullOrEmpty(visitorId))
{
using (var db = Global.Instance.OpenDataBase)
{
this._currentVisitor = db.FirstOrDefault<Visitor>("where id = @0", visitorId);
}
if (this._currentVisitor != null)
{
using (var db = Global.Instance.OpenDataBase)
{
this._address = db.Query<VisitorAddress>("where visitorId = @0 order by createDate desc", this._currentVisitor.Id).ToList();
this._currentAddress = db.FirstOrDefault<VisitorAddress>("where id = @0", addressId);
}
}
}
}
}
private void GridControlCellDoubleClick(object sender, GridCellDoubleClickEventArgs e)
{
if (e.MouseEventArgs.Button == MouseButtons.Left)
{
this.superTabControl.SelectedTab = null;
this._currentOperator = DeliveryOperator.;
this.RefreshUi();
}
}
private void AddressGridCellDoubleClick(object sender, GridCellDoubleClickEventArgs e)
{
if (e.MouseEventArgs.Button == MouseButtons.Left)
{
if (e.GridCell.GridRow.DataItem != null && e.GridCell.GridRow.DataItem is VisitorAddress)
{
this._currentAddress = e.GridCell.GridRow.DataItem as VisitorAddress;
}
this.superTabControl.SelectedTab = null;
this._currentOperator = DeliveryOperator.;
this.RefreshUi();
}
}
private void OnWorkerSearchClick(object sender, EventArgs e)
{
this.superTabControl.SelectedTab = null;
this._currentOperator = DeliveryOperator.;
this.RefreshUi();
}
private Tuple<Visitor, VisitorAddress, VisitorTag> AddNewCustomer()
{
string visitorId = IdWorkerUtils.Instance.NextId();
//新熟客
var visitor = new Visitor();
visitor.Id = visitorId;
visitor.TenantId = Global.Instance.Authc.TenantId;
visitor.StoreId = Global.Instance.Authc.StoreId;
visitor.Tel = this.txtTelphone.Text.Trim();
visitor.Name = this.txtCustomer.Text.Trim();
visitor.CreateUser = Global.Instance.Worker.No;
visitor.CreateDate = DateTimeUtils.GetNowFormat();
//熟客地址
var address = new VisitorAddress();
address.Id = IdWorkerUtils.Instance.NextId();
address.TenantId = Global.Instance.Authc.TenantId;
address.VisitorId = visitorId;
address.Address = this.txtAddress.Text.Trim();
address.Name = string.IsNullOrEmpty(this.txtLinker.Text.Trim()) ? this.txtCustomer.Text.Trim() : this.txtLinker.Text.Trim();
address.Telephone = string.IsNullOrEmpty(this.txtPhone.Text.Trim()) ? this.txtTelphone.Text.Trim() : this.txtPhone.Text.Trim();
return new Tuple<Visitor, VisitorAddress, VisitorTag>(visitor, address, null);
}
private Tuple<Visitor, List<VisitorAddress>, List<VisitorTag>> GetVisitor(string telephone)
{
Visitor visitor = null;
List<VisitorAddress> address = null;
List<VisitorTag> tags = null;
using (var db = Global.Instance.OpenDataBase)
{
visitor = db.FirstOrDefault<Visitor>("where tel = @0", telephone);
if (visitor != null)
{
address = db.Query<VisitorAddress>("where visitorId = @0 order by createDate desc", visitor.Id).ToList();
tags = db.Query<VisitorTag>("where visitorId = @0 order by createDate desc", visitor.Id).ToList();
}
else
{
address = new List<VisitorAddress>();
tags = new List<VisitorTag>();
}
}
return new Tuple<Visitor, List<VisitorAddress>, List<VisitorTag>>(visitor, address, tags);
}
private void OnSubmitOrderClick(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.txtTelphone.Text.Trim()))
{
var dialogForm = new DialogForm("错误提醒", "请输入订餐电话!!", MessageBoxIcon.Error, MessageBoxButtons.OK);
dialogForm.ShowDialog();
this.txtTelphone.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtAddress.Text.Trim()))
{
var dialogForm = new DialogForm("错误提醒", "请输入订餐地址!!", MessageBoxIcon.Error, MessageBoxButtons.OK);
dialogForm.ShowDialog();
this.txtAddress.Focus();
return;
}
if (string.IsNullOrEmpty(this.txtCustomer.Text.Trim()))
{
this.txtCustomer.Text = "默认";
}
//新地址信息
if (this._address == null)
{
this._address = new List<VisitorAddress>();
}
bool isModify = false;
if (this._currentVisitor != null && this._currentVisitor.Tel.Equals(this.txtTelphone.Text.Trim()))
{
this._currentVisitor.TenantId = Global.Instance.Authc.TenantId;
this._currentVisitor.StoreId = Global.Instance.Authc.StoreId;
//判断是否有变更
if (this._currentVisitor.Tel != this.txtTelphone.Text.Trim() || this._currentVisitor.Name != this.txtCustomer.Text.Trim() || !this._address.Exists(x => x.Address.Equals(this.txtAddress.Text.Trim())))
{
isModify = true;
}
this._currentVisitor.Tel = this.txtTelphone.Text.Trim();
this._currentVisitor.Name = this.txtCustomer.Text.Trim();
}
else
{
//生成新顾客数据
var visitor = this.AddNewCustomer();
this._currentVisitor = visitor.Item1;
this._currentAddress = visitor.Item2;
this._address.Add(this._currentAddress);
}
if (!this._address.Exists(x => x.Address.Equals(this.txtAddress.Text.Trim())))
{
var address = new VisitorAddress();
address.Id = IdWorkerUtils.Instance.NextId();
address.TenantId = Global.Instance.Authc.TenantId;
address.VisitorId = this._currentVisitor.Id;
address.Address = this.txtAddress.Text.Trim();
address.Name = string.IsNullOrEmpty(this.txtLinker.Text.Trim()) ? this.txtCustomer.Text.Trim() : this.txtLinker.Text.Trim();
address.Telephone = string.IsNullOrEmpty(this.txtPhone.Text.Trim()) ? this.txtTelphone.Text.Trim() : this.txtPhone.Text.Trim();
this._address.Add(address);
this._currentAddress = address;
}
else
{
this._currentAddress.Name = string.IsNullOrEmpty(this.txtLinker.Text.Trim()) ? this.txtCustomer.Text.Trim() : this.txtLinker.Text.Trim();
this._currentAddress.Telephone = string.IsNullOrEmpty(this.txtPhone.Text.Trim()) ? this.txtTelphone.Text.Trim() : this.txtPhone.Text.Trim();
this._address.Add(this._currentAddress);
}
if (isModify)
{
//有修改,重新上传
this._currentVisitor.Upload = 0;
this._currentVisitor.ModifyUser = Global.Instance.Worker.No;
this._currentVisitor.ModifyDate = DateTimeUtils.GetNowFormat();
}
using (var db = Global.Instance.OpenDataBase)
{
using (var trans = db.GetTransaction())
{
db.Save(this._currentVisitor);
foreach (var address in this._address)
{
db.Save(address);
}
trans.Complete();
}
}
//有要上传的熟客信息
Global.isHaveUpLoadVisitor = true;
LOGGER.Info("有需要上传的熟客数据,isHaveUpLoadVisitor=true");
//if (_useOtherPrice)
//{
//这里在提交时修改订单对象外送价是为了不改变原订单对象内容。使用外送价
foreach (var item in this._orderObject.Items.Where(f => f.RowState != OrderRowState.))
{
item.Discount = 0;
item.DiscountPrice = item.OtherPrice;
item.Price = item.OtherPrice;
List<PromotionItem> Promotion = item.Promotions.Where(f => f.PromotionType == PromotionType.).ToList();
item.Promotions.Clear();
if (Promotion.Sum(f=>f.DiscountAmount) > item.ReceivableAmount)
{
//单品定额优惠
var promotion = new PromotionItem();
//标识
promotion.Id = IdWorkerUtils.Instance.NextId();
//租户ID
promotion.TenantId = item.TenantId;
//订单ID
promotion.OrderId = item.OrderId;
//订单编号
promotion.TradeNo = item.TradeNo;
//单品编号
promotion.ItemId = item.Id;
//类型
promotion.PromotionType = PromotionType.;
//方案名称
promotion.PlanName = "立减";
//优惠额
promotion.DiscountAmount = item.ReceivableAmount;
//优惠生效
promotion.Enabled = true;
//折扣,影响折扣后的单价 = 折扣的总金额 / 购买的数量
promotion.DiscountPrice = item.OtherPrice;
promotion.DiscountRate = 100;
item.Promotions.Add( promotion);
}
else
{
item.Promotions = Promotion;
}
if (item.RowState == OrderRowState.)
{
List<OrderItem> itemDetail = _orderObject.Items.FindAll(x => x.RowState == OrderRowState. && x.ParentId == item.Id);
foreach (OrderItem items in itemDetail)
{
item.Price += items.SuitAddPrice;
}
}
}
//}
this._orderObject.OrderType = OrderType.;
var orderDelivery = BuilderOrderDelivery(this._currentVisitor, this._currentAddress, this._currentWorker);
this.OnAcceptButtonClick(new TransparentEventArgs(TransparentAction.Accept, "accept", orderDelivery));
this.OnControlBoxCloseClick(sender, EventArgs.Empty);
}
private OrderDelivery BuilderOrderDelivery(Visitor visitor, VisitorAddress address, Worker worker)
{
var orderDelivery = new OrderDelivery();
//系统主键
orderDelivery.Id = IdWorkerUtils.Instance.NextId();
//租户编码
orderDelivery.TenantId = Global.Instance.Authc.TenantId;
//订单ID
orderDelivery.OrderId = this._orderObject.Id;
//订单编号
orderDelivery.TradeNo = this._orderObject.TradeNo;
//班次编码
orderDelivery.ShiftNo = this._orderObject.ShiftNo;
//班次名称
orderDelivery.ShiftName = this._orderObject.ShiftName;
//熟客ID
orderDelivery.VisitorId = visitor.Id;
//熟客名称
orderDelivery.VisitorName = visitor.Name;
//熟客
orderDelivery.VisitorTelephone = visitor.Tel;
//就餐人数
orderDelivery.Peoples = 1;
//取餐地址ID
orderDelivery.AddressId = address.Id;
//取餐人名称
orderDelivery.Customer = address.Name;
//取餐人地址
orderDelivery.Address = address.Address;
//取餐人电话
orderDelivery.Telephone = address.Telephone;
//期望送达时间
orderDelivery.ExpectDate = string.Empty;
if (worker != null)
{
//送餐员ID
orderDelivery.WorkerId = worker.Id;
//送餐员编号
orderDelivery.WorkerNo = worker.No;
//送餐员名称
orderDelivery.WorkerName = worker.Name;
//预支金额
orderDelivery.AdvanceAmount = this.txtAmount.DecimalValue;
//服务费用
orderDelivery.DistributionFee = 0;
//送餐时间
orderDelivery.SendDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//外送单状态
orderDelivery.Status = 1;
}
else
{
//外送单状态
orderDelivery.Status = 0;
}
//结算日期
orderDelivery.SettlementDate = string.Empty;
//单注
orderDelivery.Description = this.txtMemo.Text.Trim();
return orderDelivery;
}
/// <summary>
/// 熟客确认选择
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnVisitorSelectClick(object sender, EventArgs e)
{
this.superTabControl.SelectedTab = null;
this._currentOperator = DeliveryOperator.;
this.RefreshUi();
}
private void txtCustomer_TextChanged(object sender, EventArgs e)
{
var _txt = sender as Component.NormalTextBox;
if (_txt == null)
{
return;
}
if (_txt.Text.Contains(';'))
{
_txt.Text = System.Text.RegularExpressions.Regex.Replace(_txt.Text, ";", "");
_txt.Select(_txt.Text.Length, _txt.Text.Length);
}
if (_txt.Text.Contains('\''))
{
_txt.Text = System.Text.RegularExpressions.Regex.Replace(_txt.Text, "\'", "");
_txt.Select(_txt.Text.Length, _txt.Text.Length);
}
if (_txt.Text.Contains(','))
{
_txt.Text = System.Text.RegularExpressions.Regex.Replace(_txt.Text, ",", "");
_txt.Select(_txt.Text.Length, _txt.Text.Length);
}
}
}
public enum DeliveryOperator
{
= 1,
= 2,
= 3,
= 4
}
}