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.

109 lines
3.2 KiB
C#

using POSV.Entity;
using POSV.MessageEvent;
using POSV.ShoppingCart;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace POSV.Business
{
public partial class ProductCouponForm : BusinessForm
{
private ProductCouponPanelEx productCouponPanelEx;
/// <summary>
/// 当前选择的记录
/// </summary>
private readonly OrderItem _orderItem = null;
public ProductCouponForm(OrderItem orderItem)
{
InitializeComponent();
this._orderItem = orderItem;
this.bottomPanel.Text = this._orderItem.Name;
this.mainPanel.Controls.Clear();
this.productCouponPanelEx = new POSV.Business.ProductCouponPanelEx(orderItem);
this.productCouponPanelEx.Dock = System.Windows.Forms.DockStyle.Fill;
this.productCouponPanelEx.Location = new System.Drawing.Point(0, 0);
this.productCouponPanelEx.Name = "productCouponPanelEx";
this.productCouponPanelEx.Padding = new System.Windows.Forms.Padding(2);
this.mainPanel.Controls.Add(this.productCouponPanelEx);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (this.DesignMode) return;
this.SetStyle(ControlStyles.Selectable, true);
this.ActiveControl = this.productCouponPanelEx;
this.productCouponPanelEx.NotifyChanged += OnNotifyChanged;
this.productCouponPanelEx.CancelButtonClick += OnCancelButtonClick;
}
private void OnNotifyChanged(object sender, FlyoutEventArgs e)
{
this.OnAcceptButtonClick(new TransparentEventArgs(TransparentAction.Accept, e.KeyCode, e.Data));
OnControlBoxCloseClick(sender, EventArgs.Empty);
}
private void OnCancelButtonClick(object sender, FlyoutEventArgs e)
{
OnControlBoxCloseClick(sender, EventArgs.Empty);
}
private void OnControlBoxCloseClick(object sender, EventArgs e)
{
if (this.Owner != null)
{
this.Owner.Close();
}
this.Close();
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
switch (keyData)
{
case Keys.Escape:
{
OnControlBoxCloseClick(this, EventArgs.Empty);
}
break;
case Keys.Left:
{
MsgEvent.Send(Constant.SPEC_KEYBOARD_NOTIFY, KeyboardAction.Left);
}
break;
case Keys.Right:
{
MsgEvent.Send(Constant.SPEC_KEYBOARD_NOTIFY, KeyboardAction.Right);
}
break;
case Keys.Enter:
{
MsgEvent.Send(Constant.SPEC_KEYBOARD_NOTIFY, KeyboardAction.Enter);
}
break;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}
}