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.
139 lines
4.6 KiB
C#
139 lines
4.6 KiB
C#
using DevComponents.DotNetBar.Controls;
|
|
using POSV.ShoppingCart;
|
|
using POSV.StoreBusiness;
|
|
using POSV.Utils;
|
|
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.Component
|
|
{
|
|
public partial class CouponCheckDialogForm : BusinessForm
|
|
{
|
|
PromotionEntity _promotionEntity = null;
|
|
|
|
public CouponCheckDialogForm(PromotionEntity promotionEntity)
|
|
{
|
|
InitializeComponent();
|
|
this._promotionEntity = promotionEntity;
|
|
//券码焦点
|
|
this.txtCode.Multiline = false;
|
|
this.txtCode.Focus();
|
|
this.txtCode.Select();
|
|
}
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
base.OnLoad(e);
|
|
|
|
if (DesignMode) return;
|
|
|
|
}
|
|
private void OnCloseTouchClick(object sender, TouchEventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void OnCloseClick(object sender, EventArgs e)
|
|
{
|
|
if (this.Owner != null)
|
|
{
|
|
this.Owner.Close();
|
|
}
|
|
this.Close();
|
|
}
|
|
|
|
private bool ValidateInputValue()
|
|
{
|
|
if (string.IsNullOrEmpty(this.txtCode.Text.Trim()))
|
|
{
|
|
DialogForm.ShowAlert(this, "操作提示", "请输入券码...");
|
|
this.txtCode.Focus();
|
|
this.txtCode.SelectAll();
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private void OnEnterClick(object sender, EnterEventArg e)
|
|
{
|
|
var valid = ValidateInputValue();
|
|
if (valid)
|
|
{
|
|
StoreCouponCheckRequest request = new StoreCouponCheckRequest();
|
|
request.CouponCode = this.txtCode.Text;
|
|
var response = StoreBusinessUtils.StoreCouponCheckOut(request);
|
|
if (response != null && response.Item1)
|
|
{
|
|
//携带赠数量和赠原因返回
|
|
Tuple<string, PromotionEntity> result = new Tuple<string, PromotionEntity>(this.txtCode.Text, this._promotionEntity);
|
|
|
|
//通知界面刷新
|
|
this.OnAcceptButtonClick(new TransparentEventArgs(TransparentAction.Accept, e.Value, result));
|
|
|
|
//关闭当前窗口
|
|
this.OnCloseClick(this, EventArgs.Empty);
|
|
}
|
|
else
|
|
{
|
|
DialogForm.ShowAlert(this, "操作提示", response.Item2);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private void OnTouchClick(object sender, TouchEventArgs e)
|
|
{
|
|
switch (e.Value)
|
|
{
|
|
case "clear":
|
|
//如果当前焦点控件是输入框
|
|
if (this.ActiveControl is TextBoxX)
|
|
{
|
|
var activeControl = this.ActiveControl as TextBoxX;
|
|
activeControl.Text = string.Empty;
|
|
}
|
|
break;
|
|
case "accept":
|
|
//验证通过
|
|
{
|
|
var valid = ValidateInputValue();
|
|
if (valid)
|
|
{
|
|
StoreCouponCheckRequest request = new StoreCouponCheckRequest();
|
|
request.CouponCode = this.txtCode.Text;
|
|
var response = StoreBusinessUtils.StoreCouponCheckOut(request);
|
|
if (response != null && response.Item1)
|
|
{
|
|
//携带赠数量和赠原因返回
|
|
Tuple<string, PromotionEntity> result = new Tuple<string, PromotionEntity>(this.txtCode.Text, this._promotionEntity);
|
|
|
|
//通知界面刷新
|
|
this.OnAcceptButtonClick(new TransparentEventArgs(TransparentAction.Accept, e.Value, result));
|
|
|
|
//关闭当前窗口
|
|
this.OnCloseClick(this, EventArgs.Empty);
|
|
}
|
|
else
|
|
{
|
|
DialogForm.ShowAlert(this, "操作提示", response.Item2);
|
|
}
|
|
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
{
|
|
InputSimulatorUtils.SendKey(KeyCodes.Map[e.Value]);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|