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.
160 lines
5.0 KiB
C#
160 lines
5.0 KiB
C#
using POSV.Entity;
|
|
using POSV.MessageEvent;
|
|
using POSV.ShoppingCart;
|
|
using POSV.Utils;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Windows.Forms;
|
|
|
|
namespace POSV.WaiMai
|
|
{
|
|
public partial class DeliverySendForm : BusinessForm
|
|
{
|
|
private OrderDelivery _order = null;
|
|
public DeliverySendForm(OrderDelivery order)
|
|
{
|
|
InitializeComponent();
|
|
|
|
_order = order;
|
|
}
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
base.OnLoad(e);
|
|
|
|
if (this.DesignMode) return;
|
|
|
|
this.controlBox1.Text = "外送单-送出";
|
|
|
|
this.lblAddress.Text = string.Format(this.lblAddress.Tag.ToString(), _order.Address);
|
|
this.lblVisitorName.Text = string.Format(this.lblVisitorName.Tag.ToString(), _order.VisitorName);
|
|
this.lblVisitorTelephone.Text = string.Format(this.lblVisitorTelephone.Tag.ToString(), _order.VisitorTelephone);
|
|
this.lblTitle.Text = string.Format(this.lblTitle.Tag.ToString(), _order.TradeNo);
|
|
this.txtMemo.Text = _order.Description;
|
|
}
|
|
|
|
private void OnCloseClick(object sender, EventArgs e)
|
|
{
|
|
if(this.Owner != null)
|
|
{
|
|
this.Owner.Close();
|
|
}
|
|
this.Close();
|
|
}
|
|
|
|
private void OnKeyboardClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
KeyboardType keyboardType = KeyboardType.中文;
|
|
Type type = this.ActiveControl.GetType();
|
|
PropertyInfo pinfo = type.GetProperty("Keyboard");
|
|
if (pinfo != null)
|
|
{
|
|
keyboardType = (KeyboardType)pinfo.GetValue(this.ActiveControl, null);
|
|
}
|
|
|
|
var keyboard = Application.OpenForms["VirtualKeyboard"];
|
|
if (keyboard == null)
|
|
{
|
|
keyboard = new VirtualKeyboard(keyboardType);
|
|
}
|
|
|
|
((VirtualKeyboard)keyboard).ShowVirtualKeyboard(this, keyboardType);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LOGGER.Error(ex, "打开屏幕键盘异常");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 送出
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnOrderSendClick(object sender, EventArgs e)
|
|
{
|
|
var workerNo = this.txtWorker.Text.Trim();
|
|
if (string.IsNullOrEmpty(workerNo))
|
|
{
|
|
this.ShowToastNotify(this, "送餐人不能为空!");
|
|
return;
|
|
}
|
|
var worker = this.txtWorker.Tag as Worker;
|
|
|
|
_order.Status = 1;
|
|
_order.SendDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
_order.ModifyDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
_order.AdvanceAmount = this.txtAmount.DecimalValue;
|
|
_order.Description = this.txtMemo.Text;
|
|
_order.WorkerId = worker.Id;
|
|
_order.WorkerName = worker.Name;
|
|
_order.WorkerNo = worker.No;
|
|
|
|
bool isSucc = false;
|
|
try
|
|
{
|
|
lock (Global.Instance.SyncLock)
|
|
{
|
|
using (var db = Global.Instance.OpenDataBase)
|
|
{
|
|
db.Save(_order);
|
|
}
|
|
Thread.Sleep(20);
|
|
}
|
|
isSucc = true;
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
LOGGER.Error(ex, "外送单送出异常");
|
|
}
|
|
|
|
if (isSucc)
|
|
{
|
|
DialogForm dialog = new DialogForm("送出提醒", "送出成功!", MessageBoxIcon.Information, MessageBoxButtons.OK);
|
|
dialog.ShowDialog();
|
|
|
|
this.OnAcceptButtonClick(new TransparentEventArgs(TransparentAction.Accept, null, null));
|
|
|
|
this.OnCloseClick(sender, e);
|
|
}
|
|
else
|
|
{
|
|
DialogForm dialog = new DialogForm("送出提醒", "送出失败!", MessageBoxIcon.Information, MessageBoxButtons.OK);
|
|
dialog.ShowDialog();
|
|
}
|
|
|
|
}
|
|
|
|
private void OnSelectWorkerClick(object sender, EventArgs e)
|
|
{
|
|
this.txtWorker.Text = string.Empty;
|
|
this.txtWorker.Tag = null;
|
|
WorkerSelectForm workerForm = new WorkerSelectForm();
|
|
workerForm.OnSelectedWorker -= OnSelectedWorker;
|
|
workerForm.OnSelectedWorker += OnSelectedWorker;
|
|
workerForm.ShowDialog();
|
|
}
|
|
|
|
|
|
private void OnSelectedWorker(Worker worker)
|
|
{
|
|
this.txtWorker.Text = worker.Name;
|
|
this.txtWorker.Tag = worker;
|
|
}
|
|
|
|
private void OnCancelClick(object sender, EventArgs e)
|
|
{
|
|
this.OnCloseClick(sender, null);
|
|
}
|
|
}
|
|
}
|