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.ShoppingCart; using POSV.Entity.Pormotion; using POSV.Card; using POS.Language.Language; namespace POSV.Component { [ToolboxItem(false)] public partial class ElectronCouponItemControl : AbstractNotifyPanelEx { private ElectronCoupon _currentCoupon = null; public ElectronCouponItemControl() { InitializeComponent(); } public void RefreshView(ElectronCoupon coupon) { _currentCoupon = coupon; this.labelX1.Text = CardUtils.MemberCouponTypeTrans2Name(coupon.CardType); this.labelX2.Text = CardUtils.MemberCouponValidDateDesc(coupon.BeginTimestamp, coupon.EndTimestamp); this.labelX3.Text = CardUtils.MemberCouponDiscountDesc(coupon); this.labelX4.Text = CardUtils.MemberCouponLimitDesc(coupon); var type = (MemberCouponStatus)coupon.ErrorType; if(type == MemberCouponStatus.可用) { this.touchButtonX1.BackColor1 = Color.Teal; this.touchButtonX1.Enabled = true; this.touchButtonX1.Text = LangProxy.ToLang("使用"); this.touchButtonX1.Tag = "false"; } else if(type == MemberCouponStatus.使用中) { this.touchButtonX1.BackColor1 = Color.OrangeRed; this.touchButtonX1.Enabled = true; if (coupon.CardType == MemberCouponType.CASH || coupon.CardType == MemberCouponType.DISCOUNT) { this.touchButtonX1.Text = string.Format(LangProxy.ToLang("使用中\n优惠{0}元"), OrderUtils.ToRound(coupon.RealMoney)); } else { this.touchButtonX1.Text = LangProxy.ToLang("使用中"); } this.touchButtonX1.Tag = "true"; } else { this.touchButtonX1.BackColor1 = Color.DarkRed; this.touchButtonX1.Style.WordWrap = true; this.touchButtonX1.Enabled = false; this.touchButtonX1.Text = type.ToString(); this.touchButtonX1.Tag = "false"; } } private void OnTouchClick(object sender, TouchEventArgs e) { var isUse = this.touchButtonX1.Tag as string; if (isUse == "true") { //当前已使用,变更为取消使用 this.OnButtonClick(new NotifyEventArgs(NotifyAction.Cancel, _currentCoupon)); } else { //当前未使用,变更为使用 this.OnButtonClick(new NotifyEventArgs(NotifyAction.Accept, _currentCoupon)); } } } }