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.

155 lines
7.1 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 JwKdsV.Core.Utils;
using JwKdsV.Core;
using JwKdsV.Core.DisplaySetting;
using JwKdsV.Component;
namespace JwKdsV.Business
{
public partial class LastProductPanel : AbstractFlyoutPanelEx
{
public LastProductPanel()
{
InitializeComponent();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
//加载最近划菜数据
InstallLastProduct();
}
private void InstallLastProduct()
{
string sql = @"select p.[itemId], p.[tradeNo], o.[tableNo], p.[productName], p.[quantity],p.[makeDesc],p.[saleDate], p.[huacaiTime], p.[isSuit],o.[orderType],o.[orderNo]
from [pos_order_item] p
inner join [pos_order] o on p.[serviceId] = o.[id]
where [huacaiTime] != '' order by p.[huacaiTime] desc limit 20;";
var set = SQLiteUtils.Query(sql, "data");
var table = set.Tables["data"];
var styleStr = Global.Instance.GlobalConfigStringValue(ConfigConstant.CONFIG_BUSINESS_CATEGORYSTYLE);
var itemStyleStr = Global.Instance.GlobalConfigStringValue(ConfigConstant.CONFIG_BUSINESS_ORDERITEMSTYLE);
var normalColor = Global.Instance.GlobalConfigStringValue(ConfigConstant.CONFIG_BUSINESS_ORDERNORMALCOLOR);
int width = 250, height = 100;
if (!string.IsNullOrEmpty(styleStr))
{
var itemStyle = JsonUtils.Deserialize<ProductShowStyle>(itemStyleStr);
foreach (DataRow tempRow in table.Rows)
{
string itemId = tempRow["itemId"] + "";
string tradeNo = tempRow["tradeNo"] + "";
string tableNo = tempRow["tableNo"] + "";
string productName = tempRow["productName"] + "";
string quantity = tempRow["quantity"] + "";
string makeDesc = tempRow["makeDesc"] + "";
string saleDate = tempRow["saleDate"] + "";
string huacaiTime = tempRow["huacaiTime"] + "";
string tmp_type = tempRow["OrderType"] + "";
string orderNo = tempRow["orderNo"] + "";
int isSuit = DecimalUtils.GetInt(tempRow["isSuit"]);
TilePanel tile = new TilePanel();
tile.Width = width;
tile.Height = height;
var title = itemStyle.Title;
if (title != null)
{
tile.TitleRatio = title.Ratio;
tile.TitleForeColor = ColorTranslator.FromHtml(title.FontColor);
tile.TitleFont = Global.Instance.GetFont(title.FontSize);
tile.TitleBackColor = ColorTranslator.FromHtml(normalColor);
}
var content = itemStyle.Content;
if (content != null)
{
tile.ContentRatio = content.Ratio;
tile.ContentForeColor = ColorTranslator.FromHtml(content.FontColor);
tile.ContentFont = Global.Instance.GetFont(content.FontSize);
tile.ContentBackColor = ColorTranslator.FromHtml(normalColor);
}
var bottom = itemStyle.Bottom;
if (bottom != null)
{
tile.BottomRatio = bottom.Ratio;
tile.BottomForeColor = ColorTranslator.FromHtml(bottom.FontColor);
tile.BottomFont = Global.Instance.GetFont(bottom.FontSize);
tile.BottomBackColor = ColorTranslator.FromHtml(normalColor);
}
//组装关键字信息
Dictionary<string, string> sourceDic = new Dictionary<string, string>();
//sourceDic.Add("@票号@", KdsBusiness.TicketNoDisplay(tradeNo));
sourceDic.Add("@票号@", "票号:" + KdsBusiness.TicketNoDisplay(orderNo));//2023/05/24 Yao
sourceDic.Add("@营业模式@", tmp_type);//OrderType"堂吃"
//sourceDic.Add("@桌号@", tableNo);
//Yao 2023-06-21 增加显示桌号为编写的A01--A18/B01-B18/C01-C18
//if (char.IsDigit(tableNo[0]))
//{
// int number = Convert.ToInt16(tableNo);
// if (number <= 54)
// sourceDic.Add("@桌号@", "桌号:" + HsPrinter.Desk_ChuPing_Number_Data[number]);//2023/05/24 Yao
// else
// sourceDic.Add("@桌号@", "桌号:" + "\r\n");//桌号
//}
//else if (char.IsLetter(tableNo[0]) && (tableNo[0] == 'A' || tableNo[0] == 'B' || tableNo[0] == 'C'))
//{
// sourceDic.Add("@桌号@", "桌号:" + tableNo);//2023/05/24 Yao
//}
sourceDic.Add("@桌号@", "桌号:"+ tableNo);
sourceDic.Add("@菜品数量@", quantity + "");
var name = productName;
if (isSuit == 3)
{
//套餐明细
name = "[套]" + name;
}
sourceDic.Add("@菜品名称@", name);
sourceDic.Add("@做法@", makeDesc);
//var saleDate = Convert.ToDateTime(saleDate);
//TimeSpan span = DateTime.Now - saleDate;
sourceDic.Add("@制作时长@", "");
sourceDic.Add("@桌号分配时间@", "");
//标题 桌号+单号
tile.TitleText = KdsBusiness.DisplayContentReplace(sourceDic, itemStyle.Title.Content);
tile.TitleTag = itemStyle.Title.Content;
tile.TitleAlignment = ContentAlignment.MiddleCenter;
tile.ContentText = KdsBusiness.DisplayContentReplace(sourceDic, itemStyle.Content.Content);
tile.ContentTag = itemStyle.Content.Content;
tile.BottomVisible = true;
tile.BottomAlignment = StringAlignment.Far;
tile.BottomText = KdsBusiness.DisplayContentReplace(sourceDic, itemStyle.Bottom.Content);
tile.BottomTag = itemStyle.Bottom.Content;
tile.Tag = sourceDic;
tile.Name = itemId;
this.itemPanel1.Items.Add(tile);
}
this.itemPanel1.RefreshView();
}
}
private void OnCloseClick(object sender, EventArgs e)
{
this.OnCancelButtonClick(new FlyoutEventArgs(FlyoutAction.Cancel, null));
}
}
}