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.
385 lines
12 KiB
C#
385 lines
12 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using POSV.WaiMai;
|
|
using POSV.MessageEvent;
|
|
using System.Threading.Tasks;
|
|
using POSV.ShoppingCart;
|
|
using POSV.Utils;
|
|
using POS.Language.Language;
|
|
|
|
namespace POSV.Component
|
|
{
|
|
[ToolboxItem(true)]
|
|
public partial class HistoryControl : BaseUserControl
|
|
{
|
|
|
|
private List<AbstractNotifyPanelEx> _PanelList = new List<AbstractNotifyPanelEx>();
|
|
|
|
private TelephoneNotifyPanelEx _waimai = null;
|
|
|
|
private PromotionNotifyPanel _proms = null;
|
|
|
|
private MemberCouponTips _memberPromTips = null;
|
|
|
|
public HistoryControl()
|
|
{
|
|
InitializeComponent();
|
|
|
|
touchLabelX3.Text = LangProxy.ToLang(touchLabelX3.Text);
|
|
|
|
|
|
|
|
//订购界面变更通知事件
|
|
MsgEvent.RemoveListener(Constant.HISTORY_CHANGED_NOTIFY , this.HistoryChangedEventNotify);
|
|
MsgEvent.Receive(Constant.HISTORY_CHANGED_NOTIFY , this.HistoryChangedEventNotify);
|
|
|
|
this.BackColor = Color.Transparent;
|
|
}
|
|
|
|
protected void HistoryChangedEventNotify(object sender , MsgEventArgs args)
|
|
{
|
|
if(args.Data != null && args.Data is Tuple<HistoryMsgType, object>)
|
|
{
|
|
var msg = args.Data as Tuple<HistoryMsgType, object>;
|
|
switch (msg.Item1)
|
|
{
|
|
case HistoryMsgType.电话外卖来电:
|
|
{
|
|
this.Invoke(new Action(() => {
|
|
var tel = msg.Item2.ToString();
|
|
if (_waimai != null)
|
|
{
|
|
DialogForm dialog = new DialogForm(LangProxy.ToLang("新来电提醒"),LangProxy.ToLang( "上一个订单还没有处理完成,是否使用新号码订餐?"), MessageBoxIcon.Question, MessageBoxButtons.OKCancel);
|
|
if (dialog.ShowDialog(this) == DialogResult.OK)
|
|
{
|
|
CloseWaimaiNotify();
|
|
ShowWaimaiNotify(tel);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ShowWaimaiNotify(tel);
|
|
}
|
|
}));
|
|
}
|
|
break;
|
|
case HistoryMsgType.优惠列表:
|
|
{
|
|
Task.Factory.StartNew(() =>
|
|
{
|
|
if (this.IsDisposed || !this.IsHandleCreated) return;
|
|
this.Invoke(new Action(() =>
|
|
{
|
|
var promList = msg.Item2 as List<PromotionEntity>;
|
|
|
|
if(promList != null && promList.Count > 0)
|
|
{
|
|
ShowPromsNotify(promList);
|
|
}
|
|
else
|
|
{
|
|
if (_proms != null)
|
|
{
|
|
ClosePromsNotify();
|
|
}
|
|
}
|
|
|
|
}));
|
|
});
|
|
}
|
|
break;
|
|
case HistoryMsgType.会员优惠:
|
|
{
|
|
Task.Factory.StartNew(() =>
|
|
{
|
|
if (this.IsDisposed || !this.IsHandleCreated) return;
|
|
this.Invoke(new Action(() =>
|
|
{
|
|
var count = StringUtils.GetInt(msg.Item2);
|
|
|
|
if (count > 0)
|
|
{
|
|
ShowMemberPromTips(count);
|
|
}
|
|
else
|
|
{
|
|
if (_memberPromTips != null)
|
|
{
|
|
CloseMemberPromTips();
|
|
}
|
|
}
|
|
|
|
}));
|
|
});
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
#region 会员优惠提醒
|
|
|
|
private void ShowMemberPromTips(int count)
|
|
{
|
|
if(_memberPromTips == null)
|
|
{
|
|
_memberPromTips = new MemberCouponTips();
|
|
}
|
|
_memberPromTips.PromCount = count;
|
|
_memberPromTips.Name = "memberCouponTips";
|
|
_memberPromTips.Size = new Size(this.Width - 3, 50);
|
|
|
|
_memberPromTips.ButtonClick -= OnMemberPromButtonClick;
|
|
_memberPromTips.ButtonClick += OnMemberPromButtonClick;
|
|
|
|
if (_memberPromTips != null)
|
|
{
|
|
if (!this.mainPanel.Controls.Contains(_memberPromTips))
|
|
{
|
|
this.mainPanel.Controls.Add(_memberPromTips);
|
|
|
|
_PanelList.Insert(0, _memberPromTips);
|
|
|
|
RefreshUI();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnMemberPromButtonClick(object sender, NotifyEventArgs e)
|
|
{
|
|
switch (e.Action)
|
|
{
|
|
case NotifyAction.Accept:
|
|
{
|
|
this.OnNotifyChanged(new NotifyEventArgs(NotifyAction.Accept, "memberProm", e.Data));
|
|
}
|
|
break;
|
|
case NotifyAction.Cancel:
|
|
{
|
|
this.OnNotifyChanged(new NotifyEventArgs(NotifyAction.Cancel, "memberProm", e.Data));
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void CloseMemberPromTips()
|
|
{
|
|
if (_memberPromTips != null)
|
|
{
|
|
this.mainPanel.Controls.Remove(_memberPromTips);
|
|
|
|
_PanelList.Remove(_memberPromTips);
|
|
|
|
RefreshUI();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region 优惠列表
|
|
private void ShowPromsNotify(List<PromotionEntity> proms)
|
|
{
|
|
if(_proms == null)
|
|
{
|
|
_proms = new PromotionNotifyPanel();
|
|
}
|
|
_proms.RefreshProms(proms);
|
|
_proms.Name = "promotions";
|
|
_proms.Tag = proms;
|
|
_proms.Size = new Size(this.Width - 3, 110);
|
|
_proms.ButtonClick -= OnPromsButtonClick;
|
|
_proms.ButtonClick += OnPromsButtonClick;
|
|
|
|
this.ShowPromsNotify();
|
|
}
|
|
|
|
private void ShowPromsNotify()
|
|
{
|
|
if(_proms != null)
|
|
{
|
|
if (!this.mainPanel.Controls.Contains(_proms))
|
|
{
|
|
this.mainPanel.Controls.Add(_proms);
|
|
|
|
_PanelList.Add(_proms);
|
|
|
|
RefreshUI();
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private void ClosePromsNotify()
|
|
{
|
|
if (_proms != null)
|
|
{
|
|
this.mainPanel.Controls.Remove(_proms);
|
|
|
|
_PanelList.Remove(_proms);
|
|
|
|
RefreshUI();
|
|
|
|
}
|
|
}
|
|
|
|
private void OnPromsButtonClick(object sender, NotifyEventArgs e)
|
|
{
|
|
switch (e.Action)
|
|
{
|
|
case NotifyAction.Accept:
|
|
{
|
|
this.OnNotifyChanged(new NotifyEventArgs(NotifyAction.Accept, "orderPromotion", e.Data));
|
|
}
|
|
break;
|
|
case NotifyAction.Cancel:
|
|
{
|
|
this.OnNotifyChanged(new NotifyEventArgs(NotifyAction.Cancel, "orderPromotion", e.Data));
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 电话外卖
|
|
|
|
private void ShowWaimaiNotify(string telephone)
|
|
{
|
|
var notify = new TelephoneNotifyPanelEx(telephone);
|
|
|
|
notify.Name = "phoneCat".ToString();
|
|
|
|
notify.Tag = telephone;
|
|
|
|
notify.ButtonClick += OnWaimaiButtonClick;
|
|
|
|
notify.Size = new Size(this.Width - 3, 142);
|
|
_waimai = notify;
|
|
|
|
ShowWaimaiNotify();
|
|
}
|
|
|
|
public void ShowWaimaiNotify()
|
|
{
|
|
if(_waimai != null)
|
|
{
|
|
if (!this.mainPanel.Controls.Contains(_waimai))
|
|
{
|
|
this.mainPanel.Controls.Add(_waimai);
|
|
_waimai.BringToFront();
|
|
_PanelList.Insert(0, _waimai);
|
|
|
|
RefreshUI();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public void CloseWaimaiNotify()
|
|
{
|
|
if (_waimai != null)
|
|
{
|
|
this.mainPanel.Controls.Remove(_waimai);
|
|
_PanelList.Remove(_waimai);
|
|
_waimai = null;
|
|
|
|
RefreshUI();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取来电电话号码
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string GetPhoneNo()
|
|
{
|
|
string result = string.Empty;
|
|
if(_waimai != null)
|
|
{
|
|
result = _waimai.GetPhoneNo();
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
private void OnWaimaiButtonClick(object sender , NotifyEventArgs e)
|
|
{
|
|
var notify = sender as TelephoneNotifyPanelEx;
|
|
|
|
switch (e.Action)
|
|
{
|
|
case NotifyAction.Cancel:
|
|
{
|
|
CloseWaimaiNotify();
|
|
}
|
|
break;
|
|
case NotifyAction.Accept:
|
|
{
|
|
this.OnNotifyChanged(new NotifyEventArgs(NotifyAction.Accept, "waimai", e.Data));
|
|
}
|
|
break;
|
|
case NotifyAction.OK:
|
|
{
|
|
this.OnNotifyChanged(new NotifyEventArgs(NotifyAction.OK, "waimai", e.Data));
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
private void RefreshUI()
|
|
{
|
|
for(int i = 0; i < _PanelList.Count; i++)
|
|
{
|
|
var control = _PanelList[i];
|
|
if(i == 0)
|
|
{
|
|
control.Location = new Point(0, 0);
|
|
}
|
|
else
|
|
{
|
|
var lastControl = _PanelList[i - 1];
|
|
control.Location = new Point(0, lastControl.Location.Y + lastControl.Height + 2);
|
|
}
|
|
}
|
|
this.Invalidate();
|
|
}
|
|
|
|
public event NofityEventHandler NotifyChanged;
|
|
public virtual void OnNotifyChanged(NotifyEventArgs e)
|
|
{
|
|
NotifyChanged?.Invoke(this , e);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 上一页
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnPageUpClick(object sender, EventArgs e)
|
|
{
|
|
this.OnNotifyChanged(new NotifyEventArgs(NotifyAction.Notify, "pageChange", "up"));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 下一页
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnNextPageClick(object sender, EventArgs e)
|
|
{
|
|
this.OnNotifyChanged(new NotifyEventArgs(NotifyAction.Notify, "pageChange", "down"));
|
|
}
|
|
}
|
|
}
|