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.
89 lines
2.9 KiB
C#
89 lines
2.9 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.MessageEvent;
|
|
using POSV.ShoppingCart;
|
|
|
|
namespace POSV.Component
|
|
{
|
|
[ToolboxItem(false)]
|
|
public partial class PromotionNotifyPanel : AbstractNotifyPanelEx
|
|
{
|
|
public PromotionNotifyPanel()
|
|
{
|
|
InitializeComponent();
|
|
|
|
//订购优惠变更通知事件
|
|
//MsgEvent.RemoveListener(Constant.ORDERPROMOTION_CHANGED_NOTIFY, this.OrderPromotionChangedEventNotify);
|
|
MsgEvent.Receive(Constant.ORDERPROMOTION_CHANGED_NOTIFY, this.OrderPromotionChangedEventNotify);
|
|
}
|
|
|
|
protected void OrderPromotionChangedEventNotify(object sender, MsgEventArgs args)
|
|
{
|
|
if(args.Data != null)
|
|
{
|
|
if(args.Data is Tuple<PromotionEntity, bool>)
|
|
{
|
|
var data = args.Data as Tuple<PromotionEntity, bool>;
|
|
foreach(Control con in this.Controls)
|
|
{
|
|
if (con is PromotionItemControl)
|
|
{
|
|
var tempCon = con as PromotionItemControl;
|
|
var prom = tempCon.Tag as PromotionEntity;
|
|
if(prom != null && prom.PromotionId == data.Item1.PromotionId)
|
|
{
|
|
tempCon.RefreshView(prom, data.Item2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void RefreshProms(List<PromotionEntity> proms)
|
|
{
|
|
//this.Controls.Clear();
|
|
proms = proms.OrderByDescending(x => x.DiscountAmount).ToList();
|
|
//减少闪烁的处理
|
|
var addNum = proms.Count - this.Controls.Count;
|
|
while(addNum > 0)
|
|
{
|
|
PromotionItemControl item = new PromotionItemControl();
|
|
item.Dock = DockStyle.Top;
|
|
item.ButtonClick += (o, args) =>
|
|
{
|
|
this.OnButtonClick(args);
|
|
};
|
|
this.Controls.Add(item);
|
|
addNum--;
|
|
}
|
|
|
|
while(addNum < 0)
|
|
{
|
|
this.Controls.RemoveAt(0);
|
|
addNum++;
|
|
}
|
|
|
|
//控件排序
|
|
for(int i =0; i < proms.Count; i++)
|
|
{
|
|
var prom = proms[i];
|
|
var con = this.Controls[(this.Controls.Count -1 - i)];
|
|
if(con is PromotionItemControl)
|
|
{
|
|
var tempCon = con as PromotionItemControl;
|
|
tempCon.RefreshView(prom, false);
|
|
tempCon.Tag = prom;
|
|
}
|
|
}
|
|
this.Invalidate();
|
|
}
|
|
}
|
|
}
|