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.

2460 lines
112 KiB
C#

using DevComponents.DotNetBar;
using DevComponents.DotNetBar.Controls;
using DevComponents.DotNetBar.SuperGrid;
using POS.Language.Language;
using POSV.Component;
using POSV.Entity;
using POSV.Entity.Report;
using POSV.Entity.ReportPrint;
using POSV.Helper;
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.Report
{
public partial class SaleSummary : BusinessForm
{
public SaleSummary()
{
InitializeComponent();
this.controlBox1.Text = LangProxy.ToLang("销售汇总查询");
this.controlBox1.ShowApplicationVersion = false;
}
/// <summary>
/// 单品汇总
/// </summary>
List<SalesSummaryDish> listDish = new List<SalesSummaryDish>();
/// <summary>
/// 单品汇总
/// </summary>
List<SalesSummaryDish> listDish1 = new List<SalesSummaryDish>();
/// <summary>
/// 分类汇总
/// </summary>
List<SalesSummaryCategory> listCategory = new List<SalesSummaryCategory>();
/// <summary>
/// 规格汇总
/// </summary>
List<SalesSummarySpec> listSpec = new List<SalesSummarySpec>();
/// <summary>
/// 做法列表
/// </summary>
List<SalesSummaryMake> listMake = new List<SalesSummaryMake>();
/// <summary>
/// 优惠明细
/// </summary>
List<OrderOromotionSummary> listOrderOromotion = new List<OrderOromotionSummary>();
/// <summary>
/// 营业分析
/// </summary>
List<BusinessSummary> listBusinessSummary = new List<BusinessSummary>();
/// <summary>
/// 获取勾选的菜品类别
/// </summary>
List<SelectProductType> selectProductType = new List<SelectProductType>();
/// <summary>
/// 云销售分析
/// </summary>
List<HandOverProduct> yunSummary = new List<HandOverProduct>();
/// <summary>
/// 云销售分析
/// </summary>
List<HandOverProduct> localSummary = new List<HandOverProduct>();
private int queryType = 0;//0日;1周;2月
public int PrintType = 1;//1单品汇总,2分类汇总,3规格分析,4做法分析,5优惠分析,6营业分析
public string workerNo = "";
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (this.DesignMode) return;
DefaultGridStyle.setDefaultGridStyle(this.productListTable);
DefaultGridStyle.setDefaultGridStyle(this.superGridControl1);
DefaultGridStyle.setDefaultGridStyle(this.typeListTable);
DefaultGridStyle.setDefaultGridStyle(this.specListTable);
DefaultGridStyle.setDefaultGridStyle(this.makeListTable);
DefaultGridStyle.setDefaultGridStyle(this.OrderOromotionListTable);
DefaultGridStyle.setDefaultGridStyle(this.BusinessSummaryListTable);
DefaultGridStyle.setDefaultGridStyle(this.summaryListTable);
DefaultGridStyle.setDefaultGridStyle(this.summaryListTypeTable);
DefaultGridStyle.setDefaultGridStyle(this.summaryListTypeYunTable);
DefaultGridStyle.setDefaultGridStyle(this.yunSummaryListTable);
this.startPicker.Value = DateTime.Parse(Global.Instance.BusinessPlan.StartTimeSimple);
this.endPicker.Value = DateTime.Parse(Global.Instance.BusinessPlan.EndTimeSimple);
this.TypeLabelX.Visible = false;
this.checkBoxX1.Visible = false;
this.checkBoxX2.Visible = false;
this.checkBoxX3.Visible = false;
QueyTicket();
}
public List<BusinessSummary> getBusinessSummaryList(string workerNo, string startTime, string endTime)
{
List<BusinessSummary> newList = new List<BusinessSummary>();
try
{
using (var db = Global.Instance.OpenDataBase)
{
StringBuilder sqlBuld = new StringBuilder();
if (queryType == 0)
{
sqlBuld.Append(" select strftime('%Y-%m-%d',a.finishDate) as name, ");
}
else if (queryType == 1)
{
sqlBuld.Append(" select strftime('第%W周',a.finishDate) as name, ");
}
else if (queryType == 2)
{
sqlBuld.Append(" select strftime('%m月',a.finishDate) as name, ");
}
sqlBuld.Append(" sum(a.people) as people,count(a.id) as count,sum(a.amount) as amount,sum(a.receivableAmount) as receivableAmount , ");
sqlBuld.Append(" sum(a.discountAmount) as discountAmount, ");
sqlBuld.Append(" sum(b.discountAmount) AS zsAmount ");
sqlBuld.Append(" from pos_order a left join (select tradeNo ,sum(discountAmount) as discountAmount from pos_order_item_promotion where promotionType = 0 GROUP BY tradeNo) b on a.tradeNo = b.tradeNo ");
sqlBuld.Append(" where a.finishDate >= '{0}' and a.finishDate <= '{1}' ");
sqlBuld.Append(" and a.storeId = '{2}' ");
if (!"".Equals(workerNo))
{
sqlBuld.Append(" and a.workerNo = '" + workerNo + "' ");
}
sqlBuld.Append(" and a.orderStatus in(2,4) ");
sqlBuld.Append(" group by 1 ");
sqlBuld.Append(" order by a.finishDate asc ");
string sql = string.Format(sqlBuld.ToString(), startTime, endTime, Global.Instance.Authc.StoreId);
newList = db.Query<BusinessSummary>(sql).ToList();
if (newList == null)
{
newList = new List<BusinessSummary>();
}
int sumPeople = 0;
int sumCount = 0;
decimal sumAmount = 0.0M;
decimal sumReceivableAmount = 0.0M;
decimal sumDiscountAmount = 0.0M;
decimal sumZsAmount = 0.0M;
foreach (BusinessSummary businessSummary in newList)
{
sumPeople += businessSummary.People;
sumCount += businessSummary.Count;
sumAmount += businessSummary.Amount;
sumReceivableAmount += businessSummary.ReceivableAmount;
sumDiscountAmount += businessSummary.DiscountAmount;
sumZsAmount += businessSummary.ZsAmount;
}
BusinessSummary summary = new BusinessSummary();
summary.Name = "合计";
summary.People = sumPeople;
summary.Count = sumCount;
summary.Amount = sumAmount;
summary.ReceivableAmount = sumReceivableAmount;
summary.DiscountAmount = sumDiscountAmount;
summary.ZsAmount = sumZsAmount;
newList.Add(summary);
}
}
catch (Exception ex)
{
LOGGER.Error(ex);
}
return newList;
}
public List<OrderOromotionSummary> getOrderOromotionList(string workerNo, string startTime, string endTime)
{
List<OrderOromotionSummary> newList = new List<OrderOromotionSummary>();
try
{
using (var db = Global.Instance.OpenDataBase)
{
StringBuilder sqlBuld = new StringBuilder();
sqlBuld.Append(" select c.tradeNo,c.finishDate,c.workerNo,c.workerName,a.promotionType,(b.quantity-b.rquantity) as count,b.typeName,b.productName,b.productNo, ");
sqlBuld.Append(" b.specName,b.salePrice,b.amount,b.flavorAmount,b.totalAmount,a.discountAmount ");
sqlBuld.Append(" from pos_order_item_promotion a ");
sqlBuld.Append(" left join pos_order_item b on a.itemId = b.id ");
sqlBuld.Append(" left join pos_order c on b.orderId = c.id ");
sqlBuld.Append(" where c.storeId = '{0}' ");
if (!"".Equals(workerNo))
{
sqlBuld.Append(" and c.workerNo = '" + workerNo + "' ");
}
sqlBuld.Append(" and c.finishDate >= '{1}' ");
sqlBuld.Append(" and c.finishDate <= '{2}' ");
sqlBuld.Append(" and a.promotionType <> 50 ");
sqlBuld.Append(" and c.orderStatus in(2,4) ");
sqlBuld.Append(" order by a.promotionType ");
string sql = string.Format(sqlBuld.ToString(), Global.Instance.Authc.StoreId, startTime, endTime);
var list = db.Query<OrderOromotionSummary>(sql).ToList();
if (list == null)
{
list = new List<OrderOromotionSummary>();
}
decimal sumCount = 0;
decimal sumMoney = 0.0M;
decimal sumDiscountMoney = 0.0M;
foreach (OrderOromotionSummary salesSummaryDish in list)
{
sumCount += StringUtils.GetDecimal(salesSummaryDish.Count);
sumMoney += StringUtils.GetDecimal(salesSummaryDish.TotalAmount);
sumDiscountMoney += StringUtils.GetDecimal(salesSummaryDish.DiscountAmount);
}
string tempTypeId = null;
decimal typeSumCount = 0;
decimal typeSumMoney = 0.0M;
decimal typeSumDiscountMoney = 0.0M;
foreach (OrderOromotionSummary salesSummaryDish in list)
{
if (tempTypeId == null)
{
newList.Add(new OrderOromotionSummary() { ProductName = "★★" + salesSummaryDish.PromotionType, PromotionType = PromotionTypeE.None, Count = string.Empty, TotalAmount = string.Empty, DiscountAmount = string.Empty });
}
if (tempTypeId == null || tempTypeId == salesSummaryDish.PromotionType.ToString())
{
tempTypeId = salesSummaryDish.PromotionType.ToString();
typeSumCount += StringUtils.GetDecimal(salesSummaryDish.Count);
typeSumMoney += StringUtils.GetDecimal(salesSummaryDish.TotalAmount);
typeSumDiscountMoney += StringUtils.GetDecimal(salesSummaryDish.DiscountAmount);
}
else
{
var tempTypeSum = new OrderOromotionSummary();
tempTypeSum.ProductName = "小计";
tempTypeSum.Count = StringUtils.FormatDataTwoDigit(typeSumCount);
tempTypeSum.TotalAmount = StringUtils.FormatDataTwoDigit(typeSumMoney);
tempTypeSum.DiscountAmount = StringUtils.FormatDataTwoDigit(typeSumDiscountMoney);
newList.Add(tempTypeSum);
newList.Add(new OrderOromotionSummary() { ProductName = "★★" + salesSummaryDish.PromotionType, PromotionType = PromotionTypeE.None, Count = string.Empty, TotalAmount = string.Empty, DiscountAmount = string.Empty });
tempTypeId = salesSummaryDish.PromotionType.ToString();
typeSumCount = StringUtils.GetDecimal(salesSummaryDish.Count);
typeSumMoney = StringUtils.GetDecimal(salesSummaryDish.TotalAmount);
typeSumDiscountMoney = StringUtils.GetDecimal(salesSummaryDish.DiscountAmount);
}
newList.Add(salesSummaryDish);
}
//尾行小计
OrderOromotionSummary typeSum = new OrderOromotionSummary();
typeSum.ProductName = LangProxy.ToLang("小计");
typeSum.PromotionType = PromotionTypeE.None;
typeSum.Count = StringUtils.FormatDataTwoDigit(typeSumCount);
typeSum.TotalAmount = StringUtils.FormatDataTwoDigit(typeSumMoney);
typeSum.DiscountAmount = StringUtils.FormatDataTwoDigit(typeSumDiscountMoney);
newList.Add(typeSum);
OrderOromotionSummary dish = new OrderOromotionSummary();
dish.ProductName = LangProxy.ToLang("合计");
dish.PromotionType = PromotionTypeE.None;
dish.Count = StringUtils.FormatDataTwoDigit(sumCount);
dish.TotalAmount = StringUtils.FormatDataTwoDigit(sumMoney);
dish.DiscountAmount = StringUtils.FormatDataTwoDigit(sumDiscountMoney);
newList.Add(dish);
}
}
catch (Exception ex)
{
LOGGER.Error(ex);
}
return newList;
}
/// <summary>
/// 单品汇总报表
/// zhangy 2019-11-26 添加注释
/// </summary>
/// <param name="workerNo"></param>
/// <param name="startTime"></param>
/// <param name="endTime"></param>
/// <returns></returns>
public List<SalesSummaryDish> getDishList(string workerNo, string startTime, string endTime)
{
List<SalesSummaryDish> newList = new List<SalesSummaryDish>(); ;
try
{
using (var db = Global.Instance.OpenDataBase)
{
StringBuilder sqlBuld = new StringBuilder();
sqlBuld.Append(" select t.typeId, t.typeName, t.productName, t.productNo,t.specName, t.productUnitName, sum(t.quantity-t.rquantity) as sumCount, ");
sqlBuld.Append(" sum(t.totalAmount) as sumMoney , sum(t.totalReceivableAmount) as sumRealMoney ");
sqlBuld.Append(" from pos_order_item t ");
sqlBuld.Append(" left join pos_order p on t.orderId= p.id ");
sqlBuld.Append(" where p.finishDate >= '{0}' and p.finishDate <= '{1}' ");
sqlBuld.Append(" and p.orderStatus in(2,4) ");
sqlBuld.Append(" and t.isSuit in (1,2) ");
if (!"".Equals(workerNo))
{
sqlBuld.Append(" and p.workerNo = '" + workerNo + "' ");
}
sqlBuld.Append(" group by t.productId,t.specId ");
sqlBuld.Append("order by t.typeId, t.productNo;");
string sql = string.Format(sqlBuld.ToString(), startTime, endTime);
var list = db.Query<SalesSummaryDish>(sql).ToList();
if (list == null)
{
list = new List<SalesSummaryDish>();
}
decimal sumCount = 0;
decimal sumMoney = 0.0M;
decimal sumRealMoney = 0.0M;
foreach (SalesSummaryDish salesSummaryDish in list)
{
sumCount += salesSummaryDish.SumCount;
sumMoney += salesSummaryDish.SumMoney;
sumRealMoney += salesSummaryDish.SumRealMoney;
}
string tempTypeId = null;
decimal typeSumCount = 0;
decimal typeSumMoney = 0.0M;
decimal typeSumRealMoney = 0.0M;
foreach (SalesSummaryDish salesSummaryDish in list)
{
if (tempTypeId == null)
{
newList.Add(new SalesSummaryDish() { ProductName = "★★" + salesSummaryDish.TypeName, SumCountStr = string.Empty, SumMoneyStr = string.Empty, SumRealMoneyStr = string.Empty });
}
if (tempTypeId == null || tempTypeId == salesSummaryDish.TypeId)
{
tempTypeId = salesSummaryDish.TypeId;
typeSumCount += salesSummaryDish.SumCount;
typeSumMoney += salesSummaryDish.SumMoney;
typeSumRealMoney += salesSummaryDish.SumRealMoney;
}
else
{
var tempTypeSum = new SalesSummaryDish();
tempTypeSum.ProductName = LangProxy.ToLang("小计");
tempTypeSum.SumCount = typeSumCount;
tempTypeSum.SumMoney = typeSumMoney;
tempTypeSum.SumRealMoney = typeSumRealMoney;
if (typeSumCount > 0)
{
tempTypeSum.CountScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(typeSumCount / sumCount * 100));
}
else
{
tempTypeSum.CountScale = "0%";
}
if (typeSumMoney > 0)
{
tempTypeSum.MoneyScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(typeSumMoney / sumMoney * 100));
}
else
{
tempTypeSum.MoneyScale = "0%";
}
if (typeSumRealMoney > 0)
{
tempTypeSum.SumRealMoneyScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(typeSumRealMoney / sumRealMoney * 100));
}
else
{
tempTypeSum.SumRealMoneyScale = "0%";
}
newList.Add(tempTypeSum);
newList.Add(new SalesSummaryDish() { ProductName = "★★" + salesSummaryDish.TypeName, SumCountStr = string.Empty, SumMoneyStr = string.Empty, SumRealMoneyStr = string.Empty });
tempTypeId = salesSummaryDish.TypeId;
typeSumCount = salesSummaryDish.SumCount;
typeSumMoney = salesSummaryDish.SumMoney;
typeSumRealMoney = salesSummaryDish.SumRealMoney;
}
newList.Add(salesSummaryDish);
if (sumCount > 0)
{
salesSummaryDish.CountScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(salesSummaryDish.SumCount / sumCount * 100));
}
else
{
salesSummaryDish.CountScale = "0%";
}
if (sumMoney > 0)
{
salesSummaryDish.MoneyScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(salesSummaryDish.SumMoney / sumMoney * 100));
}
else
{
salesSummaryDish.MoneyScale = "0%";
}
if (sumRealMoney > 0)
{
salesSummaryDish.SumRealMoneyScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(salesSummaryDish.SumRealMoney / sumRealMoney * 100));
}
else
{
salesSummaryDish.SumRealMoneyScale = "0%";
}
}
//尾行小计
SalesSummaryDish typeSum = new SalesSummaryDish();
typeSum.ProductName = LangProxy.ToLang("小计");
typeSum.SumCount = typeSumCount;
typeSum.SumMoney = typeSumMoney;
typeSum.SumRealMoney = typeSumRealMoney;
if (typeSumCount > 0)
{
typeSum.CountScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(typeSumCount / sumCount * 100));
}
else
{
typeSum.CountScale = "0%";
}
if (typeSumMoney > 0)
{
typeSum.MoneyScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(typeSumMoney / sumMoney * 100));
}
else
{
typeSum.MoneyScale = "0%";
}
if (typeSumRealMoney > 0)
{
typeSum.SumRealMoneyScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(typeSumRealMoney / sumRealMoney * 100));
}
else
{
typeSum.SumRealMoneyScale = "0%";
}
newList.Add(typeSum);
SalesSummaryDish dish = new SalesSummaryDish();
dish.ProductName = LangProxy.ToLang("合计");
dish.SumCount = sumCount;
dish.SumMoney = sumMoney;
dish.SumRealMoney = decimal.Parse( sumRealMoney.ToString("0.00"));
newList.Add(dish);
}
}
catch (Exception ex)
{
LOGGER.Error(ex);
}
return newList;
}
public List<SalesSummaryDish> getDishList1(string workerNo, string startTime, string endTime)
{
List<SalesSummaryDish> newList = new List<SalesSummaryDish>(); ;
try
{
using (var db = Global.Instance.OpenDataBase)
{
StringBuilder sqlBuld = new StringBuilder();
sqlBuld.Append(" select t.typeId, t.typeName, t.productName, t.productNo,t.specName, t.productUnitName, sum(t.quantity-t.rquantity) as sumCount, ");
sqlBuld.Append(" sum(t.totalAmount) as sumMoney , sum(t.totalReceivableAmount) as sumRealMoney ");
sqlBuld.Append(" from pos_order_item t ");
sqlBuld.Append(" left join pos_order p on t.orderId= p.id ");
sqlBuld.Append(" where p.finishDate >= '{0}' and p.finishDate <= '{1}' ");
sqlBuld.Append(" and p.orderStatus in(2,4) ");
sqlBuld.Append(" and t.isSuit in (1,2) ");
if (!"".Equals(workerNo))
{
sqlBuld.Append(" and p.workerNo = '" + workerNo + "' ");
}
sqlBuld.Append(" group by t.productId,t.specId ");
sqlBuld.Append("order by t.typeId, t.productNo;");
string sql = string.Format(sqlBuld.ToString(), startTime, endTime);
var list = db.Query<SalesSummaryDish>(sql).ToList();
if (list == null)
{
list = new List<SalesSummaryDish>();
}
decimal sumCount = 0;
decimal sumMoney = 0.0M;
decimal sumRealMoney = 0.0M;
foreach (SalesSummaryDish salesSummaryDish in list)
{
sumCount += salesSummaryDish.SumCount;
sumMoney += salesSummaryDish.SumMoney;
sumRealMoney += salesSummaryDish.SumRealMoney;
}
string tempTypeId = null;
decimal typeSumCount = 0;
decimal typeSumMoney = 0.0M;
decimal typeSumRealMoney = 0.0M;
foreach (SalesSummaryDish salesSummaryDish in list)
{
if (tempTypeId == null)
{
// newList.Add(new SalesSummaryDish() { ProductName = "★★" + salesSummaryDish.TypeName, SumCountStr = string.Empty, SumMoneyStr = string.Empty, SumRealMoneyStr = string.Empty });
}
if (tempTypeId == null || tempTypeId == salesSummaryDish.TypeId)
{
tempTypeId = salesSummaryDish.TypeId;
typeSumCount += salesSummaryDish.SumCount;
typeSumMoney += salesSummaryDish.SumMoney;
typeSumRealMoney += salesSummaryDish.SumRealMoney;
}
else
{
//var tempTypeSum = new SalesSummaryDish();
//tempTypeSum.ProductName = "小计";
//tempTypeSum.SumCount = typeSumCount;
//tempTypeSum.SumMoney = typeSumMoney;
//tempTypeSum.SumRealMoney = typeSumRealMoney;
//if (typeSumCount > 0)
//{
// tempTypeSum.CountScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(typeSumCount / sumCount * 100));
//}
//else
//{
// tempTypeSum.CountScale = "0%";
//}
//if (typeSumMoney > 0)
//{
// tempTypeSum.MoneyScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(typeSumMoney / sumMoney * 100));
//}
//else
//{
// tempTypeSum.MoneyScale = "0%";
//}
//if (typeSumRealMoney > 0)
//{
// tempTypeSum.SumRealMoneyScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(typeSumRealMoney / sumRealMoney * 100));
//}
//else
//{
// tempTypeSum.SumRealMoneyScale = "0%";
//}
//newList.Add(tempTypeSum);
//newList.Add(new SalesSummaryDish() { ProductName = "★★" + salesSummaryDish.TypeName, SumCountStr = string.Empty, SumMoneyStr = string.Empty, SumRealMoneyStr = string.Empty });
tempTypeId = salesSummaryDish.TypeId;
typeSumCount = salesSummaryDish.SumCount;
typeSumMoney = salesSummaryDish.SumMoney;
typeSumRealMoney = salesSummaryDish.SumRealMoney;
}
newList.Add(salesSummaryDish);
if (sumCount > 0)
{
salesSummaryDish.CountScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(salesSummaryDish.SumCount / sumCount * 100));
}
else
{
salesSummaryDish.CountScale = "0%";
}
if (sumMoney > 0)
{
salesSummaryDish.MoneyScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(salesSummaryDish.SumMoney / sumMoney * 100));
}
else
{
salesSummaryDish.MoneyScale = "0%";
}
if (sumRealMoney > 0)
{
salesSummaryDish.SumRealMoneyScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(salesSummaryDish.SumRealMoney / sumRealMoney * 100));
}
else
{
salesSummaryDish.SumRealMoneyScale = "0%";
}
}
////尾行小计
//SalesSummaryDish typeSum = new SalesSummaryDish();
//typeSum.ProductName = "小计";
//typeSum.SumCount = typeSumCount;
//typeSum.SumMoney = typeSumMoney;
//typeSum.SumRealMoney = typeSumRealMoney;
//if (typeSumCount > 0)
//{
// typeSum.CountScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(typeSumCount / sumCount * 100));
//}
//else
//{
// typeSum.CountScale = "0%";
//}
//if (typeSumMoney > 0)
//{
// typeSum.MoneyScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(typeSumMoney / sumMoney * 100));
//}
//else
//{
// typeSum.MoneyScale = "0%";
//}
//if (typeSumRealMoney > 0)
//{
// typeSum.SumRealMoneyScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(typeSumRealMoney / sumRealMoney * 100));
//}
//else
//{
// typeSum.SumRealMoneyScale = "0%";
//}
//newList.Add(typeSum);
listDish1 = newList;
newList = newList.OrderByDescending(f => f.SumCount).ToList();
SalesSummaryDish dish = new SalesSummaryDish();
dish.ProductName = LangProxy.ToLang("合计");
dish.SumCount = sumCount;
dish.SumMoney = sumMoney;
dish.SumRealMoney = sumRealMoney;
newList.Add(dish);
var _dtSpiderSummary = new DataTable();
_dtSpiderSummary.Columns.Add("日志文件");
_dtSpiderSummary.Columns.Add("大小(M)");
}
}
catch (Exception ex)
{
LOGGER.Error(ex);
}
return newList;
}
public List<SalesSummaryCategory> getCategoryList(string workerNo, string startTime, string endTime)
{
try
{
using (var db = Global.Instance.OpenDataBase)
{
StringBuilder sqlBuld = new StringBuilder();
sqlBuld.Append(" select typeName as typeName, sum(quantity-rquantity) as sumCount, sum(totalAmount) as sumMoney, sum(totalReceivableAmount) as sumRealMoney ");
sqlBuld.Append(" from pos_order_item ");
sqlBuld.Append(" left join pos_order on pos_order_item.orderId= pos_order.id ");
sqlBuld.Append(" where pos_order.finishDate >= '{0}' and pos_order.finishDate <= '{1}' ");
sqlBuld.Append(" and pos_order.orderStatus in(2,4) ");
sqlBuld.Append(" and pos_order_item.isSuit in (1,2) ");
if (!"".Equals(workerNo))
{
sqlBuld.Append(" and pos_order.workerNo = '" + workerNo + "' ");
}
sqlBuld.Append(" group by pos_order_item.typeId");
sqlBuld.Append(" order by sumCount desc");
string sql = string.Format(sqlBuld.ToString(), startTime, endTime);
listCategory = db.Query<SalesSummaryCategory>(sql).ToList();
if (listCategory == null)
{
listCategory = new List<SalesSummaryCategory>();
}
decimal sumCount = 0;
decimal sumMoney = 0.0M;
decimal sumRealMoney = 0.0M;
foreach (SalesSummaryCategory salesSummaryCategory in listCategory)
{
sumCount = sumCount + salesSummaryCategory.SumCount;
sumMoney = sumMoney + salesSummaryCategory.SumMoney;
sumRealMoney = sumRealMoney + salesSummaryCategory.SumRealMoney;
}
foreach (SalesSummaryCategory salesSummaryCategory in listCategory)
{
if (sumCount > 0)
{
salesSummaryCategory.CountScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(salesSummaryCategory.SumCount / sumCount * 100));
}
else
{
salesSummaryCategory.CountScale = "0%";
}
if (sumMoney > 0)
{
salesSummaryCategory.MoneyScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(salesSummaryCategory.SumMoney / sumMoney * 100));
}
else
{
salesSummaryCategory.MoneyScale = "0%";
}
if (sumRealMoney > 0)
{
salesSummaryCategory.SumRealMoneyScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(salesSummaryCategory.SumRealMoney / sumRealMoney * 100));
}
else
{
salesSummaryCategory.SumRealMoneyScale = "0%";
}
}
SalesSummaryCategory category = new SalesSummaryCategory();
category.TypeName = LangProxy.ToLang("合计");
category.SumCount = (int)sumCount;
category.SumMoney = sumMoney;
category.SumRealMoney = sumRealMoney;
listCategory.Add(category);
}
}
catch (Exception ex)
{
LOGGER.Error(ex);
}
return listCategory;
}
public List<SalesSummarySpec> getSpecList(string workerNo, string startTime, string endTime)
{
try
{
using (var db = Global.Instance.OpenDataBase)
{
StringBuilder sqlBuld = new StringBuilder();
sqlBuld.Append(" select specName as specName, sum(quantity-rquantity) as sumCount, sum(totalAmount) as sumMoney, sum(totalReceivableAmount) as sumRealMoney ");
sqlBuld.Append(" from pos_order_item ");
sqlBuld.Append(" left join pos_order on pos_order_item.orderId= pos_order.id ");
sqlBuld.Append(" where pos_order.finishDate >= '{0}' and pos_order.finishDate <= '{1}' ");
sqlBuld.Append(" and pos_order.orderStatus in(2,4) ");
sqlBuld.Append(" and pos_order_item.isSuit in (1,2) ");
if (!"".Equals(workerNo))
{
sqlBuld.Append(" and pos_order.workerNo = '" + workerNo + "' ");
}
sqlBuld.Append(" group by pos_order_item.specName");
sqlBuld.Append(" order by sumCount desc");
string sql = string.Format(sqlBuld.ToString(), startTime, endTime);
listSpec = db.Query<SalesSummarySpec>(sql).ToList();
if (listSpec == null)
{
listSpec = new List<SalesSummarySpec>();
}
decimal sumCount = 0;
decimal sumMoney = 0.0M;
decimal sumRealMoney = 0.0M;
foreach (SalesSummarySpec salesSummarySpec in listSpec)
{
sumCount = sumCount + salesSummarySpec.SumCount;
sumMoney = sumMoney + salesSummarySpec.SumMoney;
sumRealMoney = sumRealMoney + salesSummarySpec.SumRealMoney;
}
foreach (SalesSummarySpec salesSummarySpec in listSpec)
{
if (sumCount > 0)
{
salesSummarySpec.CountScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(salesSummarySpec.SumCount / sumCount * 100));
}
else
{
salesSummarySpec.CountScale = "0%";
}
if (sumMoney > 0)
{
salesSummarySpec.MoneyScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(salesSummarySpec.SumMoney / sumMoney * 100));
}
else
{
salesSummarySpec.MoneyScale = "0%";
}
if (sumRealMoney > 0)
{
salesSummarySpec.SumRealMoneyScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(salesSummarySpec.SumRealMoney / sumRealMoney * 100));
}
else
{
salesSummarySpec.SumRealMoneyScale = "0%";
}
}
SalesSummarySpec spec = new SalesSummarySpec();
spec.SpecName = LangProxy.ToLang("合计");
spec.SumCount = (int)sumCount;
spec.SumMoney = sumMoney;
spec.SumRealMoney = sumRealMoney;
listSpec.Add(spec);
}
}
catch (Exception ex)
{
LOGGER.Error(ex);
}
return listSpec;
}
public List<SalesSummaryMake> getMakeList(string workerNo, string startTime, string endTime)
{
try
{
using (var db = Global.Instance.OpenDataBase)
{
StringBuilder sqlBuld = new StringBuilder();
sqlBuld.Append(" select name as makeName, sum(pos_order_item_make.quantity - pos_order_item_make.refund) as sumCount , ");
sqlBuld.Append(" sum(pos_order_item_make.amount) as sumMoney ,sum(pos_order_item_make.receivableAmount) as sumRealMoney ");
sqlBuld.Append(" from pos_order_item_make ");
sqlBuld.Append(" left join pos_order on pos_order_item_make.orderId= pos_order.id ");
sqlBuld.Append(" where pos_order.finishDate >= '{0}' and pos_order.finishDate <= '{1}' ");
sqlBuld.Append(" and pos_order.orderStatus in(2,4) ");
if (!"".Equals(workerNo))
{
sqlBuld.Append(" and pos_order.workerNo = '" + workerNo + "' ");
}
sqlBuld.Append(" group by pos_order_item_make.makeId ");
sqlBuld.Append(" order by sumCount desc");
string sql = string.Format(sqlBuld.ToString(), startTime, endTime);
listMake = db.Query<SalesSummaryMake>(sql).ToList();
if (listMake == null)
{
listMake = new List<SalesSummaryMake>();
}
decimal sumCount = 0;
decimal sumMoney = 0.0M;
decimal sumRealMoney = 0.0M;
foreach (SalesSummaryMake salesSummaryMake in listMake)
{
sumCount = sumCount + salesSummaryMake.SumCount;
sumMoney = sumMoney + salesSummaryMake.SumMoney;
sumRealMoney = sumRealMoney + salesSummaryMake.SumRealMoney;
}
foreach (SalesSummaryMake salesSummaryMake in listMake)
{
if (sumCount > 0)
{
salesSummaryMake.CountScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(salesSummaryMake.SumCount / sumCount * 100));
}
else
{
salesSummaryMake.CountScale = "0%";
}
if (sumMoney > 0)
{
salesSummaryMake.MoneyScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(salesSummaryMake.SumMoney / sumMoney * 100));
}
else
{
salesSummaryMake.MoneyScale = "0%";
}
if (sumRealMoney > 0)
{
salesSummaryMake.SumRealMoneyScale = string.Format("{0}%", StringUtils.FormatDataTwoDigit(salesSummaryMake.SumRealMoney / sumRealMoney * 100));
}
else
{
salesSummaryMake.SumRealMoneyScale = "0%";
}
}
SalesSummaryMake make = new SalesSummaryMake();
make.MakeName = LangProxy.ToLang("合计");
make.SumCount = (int)sumCount;
make.SumMoney = sumMoney;
make.SumRealMoney = sumRealMoney;
listMake.Add(make);
}
}
catch (Exception ex)
{
LOGGER.Error(ex);
}
return listMake;
}
/// <summary>
/// 云端销售分析
/// zhangy
/// </summary>
/// <param name="workerNo"></param>
/// <param name="typeIds"></param>
/// <param name="startTime"></param>
/// <param name="endTime"></param>
/// <returns></returns>
public List<HandOverProduct> LoadHandOverProduct(string workerNo, string typeIds, string startTime, string endTime)
{
List<HandOverProduct> handOverProductList = new List<HandOverProduct>();
List<HandOverProduct> list = new List<HandOverProduct>();
try
{
//去服务器连接查询
SalesOrderSummaryRequest request = new SalesOrderSummaryRequest();
request.StoreId = Global.Instance.BusinessPlanLog.StoreId;
request.WorkerNo = workerNo;
request.StartDate = startTime;
request.EndDate = endTime;
request.TypeIds = typeIds;
var response = StoreBusinessUtils.SalesOrderSummary(request);
if (response != null && response.Item1)
{
List<SalesOrderSummaryResponse> responseList = response.Item3.List;
if (responseList != null)
{
foreach (SalesOrderSummaryResponse salesOrderSummaryResponse in responseList)
{
HandOverProduct handOverProduct = new HandOverProduct();
handOverProduct.TypeId = salesOrderSummaryResponse.TypeId;
handOverProduct.TypeName = salesOrderSummaryResponse.TypeName;
handOverProduct.ProductName = salesOrderSummaryResponse.ProductName;
handOverProduct.ProductNo = salesOrderSummaryResponse.ProductNo;
handOverProduct.SpecName = salesOrderSummaryResponse.SpecName;
handOverProduct.Count = salesOrderSummaryResponse.Count;
handOverProduct.SuitQuantity = salesOrderSummaryResponse.SuitQuantity;
handOverProduct.Amount = salesOrderSummaryResponse.Amount;
handOverProductList.Add(handOverProduct);
}
}
else
{
return list;
}
}
//zhangy 2019-11-26 重写汇总方法
decimal sumCount = 0.00M;
decimal sumSuitQuantity = 0.00M;
decimal sumAmount = 0.00M;
List<Dictionary<string, object>> result = new List<Dictionary<string, object>>();
handOverProductList = handOverProductList.OrderBy(x => x.TypeId).ToList();
///分类集合
var typeMap = handOverProductList.GroupBy(g => new { g.TypeId }).Select(group =>
{
var map = new Dictionary<string, object>();
map.Add("type", 3);
//zhangy 添加typeId,为单品遍历提供条件数据
map.Add("typeId", group.Select(o => o.TypeId).First());
map.Add("name", group.Select(o => (o.TypeName == null ? "" : o.TypeName)).First());
map.Add("count", group.Sum(o => o.Count));
map.Add("suitQuantity", group.Sum(o => o.SuitQuantity));
map.Add("amount", group.Sum(o => o.Amount));
return map;
}).ToList();
//通过分类遍历菜品
foreach (var item in typeMap)
{
result.Add(item);
var typeId = item["typeId"];
decimal count = 0.00M;
decimal suitQuantity = 0.00M;
decimal amount = 0.00M;
//查询指定分类ID的全部菜品
var dishs = handOverProductList.FindAll(x => x.TypeId.Equals(typeId)).OrderBy(x => x.ProductNo).ToList();
///符合条件的菜品按照品名聚合,品名相同的菜品合并为一行数据
///2019-11-24 zhangy Edit 按照品名+规格名的方式聚合,确保相同品名,不同规格名,显示为独立一行菜品
var dishMap = dishs.GroupBy(g => new { g.ProductName,g.SpecName }).Select(group =>
{
var map = new Dictionary<string, object>();
map.Add("type", 0);
string sepcName = group.Select(o => (o.SpecName == null ? "" : o.SpecName)).First();
string productName = group.Select(o => (o.ProductName == null ? "" : o.ProductName)).First();
if (string.IsNullOrEmpty(sepcName))
{
map.Add("name", productName);
}
else
{
map.Add("name", productName + "(" + sepcName + ")");
}
map.Add("count", group.Sum(o => o.Count));
map.Add("suitQuantity", group.Sum(o => o.SuitQuantity));
map.Add("amount", group.Sum(o => o.Amount));
return map;
}).ToList();
foreach (var dish in dishMap)
{
result.Add(dish);
count += Convert.ToDecimal(dish["count"].ToString());
suitQuantity += Convert.ToDecimal(dish["suitQuantity"].ToString());
amount += Convert.ToDecimal(dish["amount"].ToString());
sumCount += Convert.ToDecimal(dish["count"].ToString());
sumSuitQuantity += Convert.ToDecimal(dish["suitQuantity"].ToString());
sumAmount += Convert.ToDecimal(dish["amount"].ToString());
}
//zhangy 以下注释代码解决不按照菜品名称合并
//foreach (var dish in dishs)
//{
// Dictionary<string, Object> dishMap = new Dictionary<string, Object>();
// dishMap.Add("type", 0);
// if (dish.SpecName != null && !"".Equals(dish.SpecName))
// {
// dishMap.Add("name", dish.ProductName + "(" + dish.SpecName + ")");
// }
// else
// {
// dishMap.Add("name", dish.ProductName);
// }
// dishMap.Add("count", dish.Count);
// dishMap.Add("suitQuantity", dish.SuitQuantity);
// dishMap.Add("amount", dish.Amount);
// result.Add(dishMap);
// count += dish.Count;
// suitQuantity += dish.SuitQuantity;
// amount += dish.Amount;
// sumCount += dish.Count;
// sumSuitQuantity += dish.SuitQuantity;
// sumAmount += dish.Amount;
//}
var seriesMap = new Dictionary<string, Object>();
seriesMap.Add("type", 1);
seriesMap.Add("name", "小计");
seriesMap.Add("count", count);
seriesMap.Add("suitQuantity", suitQuantity);
seriesMap.Add("amount", amount);
result.Add(seriesMap);
}
Dictionary<string, Object> sumMap = new Dictionary<string, Object>();
sumMap.Add("name", LangProxy.ToLang("销售"));
sumMap.Add("type", 2);
sumMap.Add("count", sumCount);
sumMap.Add("suitQuantity", sumSuitQuantity);
sumMap.Add("amount", sumAmount);
result.Add(sumMap);
foreach (Dictionary<string, Object> map in result)
{
HandOverProduct entity = new HandOverProduct();
entity.Type = StringUtils.GetInt(map["type"]);
entity.Name = StringUtils.GetString(map["name"]);
entity.Count = StringUtils.GetDecimal(map["count"]);
entity.SuitQuantity = StringUtils.GetDecimal(map["suitQuantity"]);
entity.Amount = StringUtils.GetDecimal(map["amount"]);
list.Add(entity);
}
}
catch (Exception ex)
{
LOGGER.Error(ex);
}
foreach (var item in list)
{
if (item.Type == 0)
{
item.ItemCount = StringUtils.FormatDataNoDigit(item.Count);
item.ItemSuitQuantity = StringUtils.FormatDataNoDigit(item.SuitQuantity);
item.ItemAmount = StringUtils.FormatDataNoDigit(item.Amount);
}
else if (item.Type == 1)
{
item.Name = LangProxy.ToLang("小计");
item.ItemCount = StringUtils.FormatDataNoDigit(item.Count);
item.ItemSuitQuantity = StringUtils.FormatDataNoDigit(item.SuitQuantity);
item.ItemAmount = StringUtils.FormatDataNoDigit(item.Amount);
}
else if (item.Type == 2)
{
item.Name = LangProxy.ToLang("∑合计");
item.ItemCount = StringUtils.FormatDataNoDigit(item.Count);
item.ItemSuitQuantity = StringUtils.FormatDataNoDigit(item.SuitQuantity);
item.ItemAmount = StringUtils.FormatDataNoDigit(item.Amount);
}
else if (item.Type == 3)
{
item.Name = "★★" + item.Name;
item.ItemCount = "";
item.ItemSuitQuantity = "";
item.ItemAmount = "";
}
}
return list;
}
public string LoadSeriesIds(string selectIds)
{
string typeIds = "";
List<string> listAll = new List<string>();
try
{
using (var db = Global.Instance.OpenDataBase)
{
string[] ids = selectIds.Split(',');
foreach (string id in ids)
{
List<string> source = new List<string>();
StringBuilder sqlBuld = new StringBuilder();
sqlBuld.Append(" select id from pos_product_type where path like'{0}%' and products> 0 ");
string sql = string.Format(sqlBuld.ToString(), id);
source = db.Query<string>(sql).ToList();
if (source != null && source.Count > 0)
{
listAll.AddRange(source);
}
if ("4".Equals(id) || "5".Equals(id))
{
listAll.Add(id);
}
}
}
}
catch (Exception ex)
{
LOGGER.Error(ex);
}
foreach (string id in listAll)
{
typeIds = typeIds + id + ",";
}
if (typeIds != null && !"".Equals(typeIds))
{
typeIds = typeIds.Substring(0, typeIds.Length - 1);
}
return typeIds;
}
public List<SelectProductType> LoadSelectProductType(string selectIds)
{
List<SelectProductType> list = new List<SelectProductType>();
try
{
using (var db = Global.Instance.OpenDataBase)
{
StringBuilder sqlBuld = new StringBuilder();
sqlBuld.Append(" select id, name from pos_product_type where (parentId ISNULL or parentId = '') and products> 0 ");
string sql = string.Format(sqlBuld.ToString());
list = db.Query<SelectProductType>(sql).ToList();
if (list == null)
{
list = new List<SelectProductType>();
}
SelectProductType meituanType = new SelectProductType();
meituanType.Id = "4";
meituanType.Name = LangProxy.ToLang("美团外卖菜品");
list.Add(meituanType);
SelectProductType elemeType = new SelectProductType();
elemeType.Id = "5";
elemeType.Name = LangProxy.ToLang("饿了么菜品");
list.Add(elemeType);
foreach (SelectProductType selectProductType in list)
{
if (selectIds == null || "".Equals(selectIds) || selectIds.Contains(selectProductType.Id))
{
selectProductType.IsChecked = true;
}
else
{
selectProductType.IsChecked = false;
}
}
}
}
catch (Exception ex)
{
LOGGER.Error(ex);
}
return list;
}
/// <summary>
/// 本地销售分析
///
/// 张莹 2019-11-26 17:19 添加注释
/// </summary>
/// <param name="workerNo"></param>
/// <param name="typeIds"></param>
/// <param name="startTime"></param>
/// <param name="endTime"></param>
/// <returns></returns>
public List<HandOverProduct> LoadLocalHandOverProduct(string workerNo, string typeIds, string startTime, string endTime)
{
List<HandOverProduct> handOverProductList = new List<HandOverProduct>();
List<HandOverProduct> list = new List<HandOverProduct>();
try
{
using (var db = Global.Instance.OpenDataBase)
{
StringBuilder sqlBuld = new StringBuilder();
sqlBuld.Append(" SELECT a.typeId AS typeId, ");
sqlBuld.Append(" a.typeName AS typeName, a.productName AS productName,a.specName as specName, ");
sqlBuld.Append(" a.productNo AS productNo,round(SUM(a.quantity - a.rquantity),2) AS count,");
sqlBuld.Append(" round(sum(case when a.isSuit = 3 then a.quantity else 0 end), 2) as suitQuantity,");
sqlBuld.Append(" round(sum(case when a.isSuit != 3 then a.totalReceivableAmount else 0 end),2) as amount ");
sqlBuld.Append(" FROM pos_order_item a ");
sqlBuld.Append(" left join pos_order b on a.orderId = b.id ");
sqlBuld.Append(" WHERE b.storeId = '{0}' ");
if (!string.IsNullOrEmpty(workerNo))
{
sqlBuld.Append(" and b.workerNo = '" + workerNo + "'");
}
if (!string.IsNullOrEmpty(typeIds))
{
sqlBuld.Append(" and a.typeId in (" + typeIds + ")");
}
sqlBuld.Append(" and b.finishDate >= '{1}' ");
sqlBuld.Append(" and b.finishDate <= '{2}' ");
sqlBuld.Append(" and b.orderStatus in (0, 2, 4) ");
sqlBuld.Append(" GROUP BY a.productId , a.specId");
sqlBuld.Append(" ORDER BY a.typeId,a.productNo ");
string sql = string.Format(sqlBuld.ToString(), Global.Instance.BusinessPlanLog.StoreId, startTime, endTime);
handOverProductList = db.Query<HandOverProduct>(sql).ToList();
//handOverProductList = handOverProductList.OrderBy(x => x.TypeId).OrderBy(x => x.ProductNo).ToList();
}
//zhangy 2019-11-26 重写汇总方法
decimal sumCount = 0.00M;
decimal sumSuitQuantity = 0.00M;
decimal sumAmount = 0.00M;
List<Dictionary<string, object>> result = new List<Dictionary<string, object>>();
handOverProductList = handOverProductList.OrderBy(x => x.TypeId).ToList();
///分类集合
var typeMap = handOverProductList.GroupBy(g => new { g.TypeId }).Select(group =>
{
var map = new Dictionary<string, object>();
map.Add("type", 3);
map.Add("typeId", group.Select(o => o.TypeId).First());
map.Add("name", group.Select(o => (o.TypeName == null ? "" : o.TypeName)).First());
map.Add("count", group.Sum(o => o.Count));
map.Add("suitQuantity", group.Sum(o => o.SuitQuantity));
map.Add("amount", group.Sum(o => o.Amount));
return map;
}).ToList();
//通过分类遍历菜品
foreach (var item in typeMap)
{
result.Add(item);
var typeId = item["typeId"];
decimal count = 0.00M;
decimal suitQuantity = 0.00M;
decimal amount = 0.00M;
var dishs = handOverProductList.FindAll(x => x.TypeId.Equals(typeId)).OrderBy(x => x.ProductNo).ToList();
///符合条件的菜品按照品名聚合,品名相同的菜品合并为一行数据
var dishMap = dishs.GroupBy(g => new { g.ProductName }).Select(group =>
{
var map = new Dictionary<string, object>();
map.Add("type", 0);
string sepcName = group.Select(o => (o.SpecName == null ? "" : o.SpecName)).First();
string productName = group.Select(o => (o.ProductName == null ? "" : o.ProductName)).First();
if (string.IsNullOrEmpty(sepcName))
{
map.Add("name", productName);
}
else
{
map.Add("name", productName + "(" + sepcName + ")");
}
map.Add("count", group.Sum(o => o.Count));
map.Add("suitQuantity", group.Sum(o => o.SuitQuantity));
map.Add("amount", group.Sum(o => o.Amount));
return map;
}).ToList();
foreach (var dish in dishMap)
{
result.Add(dish);
count += Convert.ToDecimal(dish["count"].ToString());
suitQuantity += Convert.ToDecimal(dish["suitQuantity"].ToString());
amount += Convert.ToDecimal(dish["amount"].ToString());
sumCount += Convert.ToDecimal(dish["count"].ToString());
sumSuitQuantity += Convert.ToDecimal(dish["suitQuantity"].ToString());
sumAmount += Convert.ToDecimal(dish["amount"].ToString());
}
//zhangy 以下注释代码解决不按照菜品名称合并
//foreach (var dish in dishs)
//{
// Dictionary<string, Object> dishMap = new Dictionary<string, Object>();
// dishMap.Add("type", 0);
// if (dish.SpecName != null && !"".Equals(dish.SpecName))
// {
// dishMap.Add("name", dish.ProductName + "(" + dish.SpecName + ")");
// }
// else
// {
// dishMap.Add("name", dish.ProductName);
// }
// dishMap.Add("count", dish.Count);
// dishMap.Add("suitQuantity", dish.SuitQuantity);
// dishMap.Add("amount", dish.Amount);
// result.Add(dishMap);
// count += dish.Count;
// suitQuantity += dish.SuitQuantity;
// amount += dish.Amount;
// sumCount += dish.Count;
// sumSuitQuantity += dish.SuitQuantity;
// sumAmount += dish.Amount;
//}
var seriesMap = new Dictionary<string, Object>();
seriesMap.Add("type", 1);
seriesMap.Add("name", "小计");
seriesMap.Add("count", count);
seriesMap.Add("suitQuantity", suitQuantity);
seriesMap.Add("amount", amount);
result.Add(seriesMap);
}
Dictionary<string, Object> sumMap = new Dictionary<string, Object>();
sumMap.Add("name", LangProxy.ToLang("销售"));
sumMap.Add("type", 2);
sumMap.Add("count", sumCount);
sumMap.Add("suitQuantity", sumSuitQuantity);
sumMap.Add("amount", sumAmount);
result.Add(sumMap);
foreach (Dictionary<string, Object> map in result)
{
HandOverProduct entity = new HandOverProduct();
entity.Type = StringUtils.GetInt(map["type"]);
entity.Name = StringUtils.GetString(map["name"]);
entity.Count = StringUtils.GetDecimal(map["count"]);
entity.SuitQuantity = StringUtils.GetDecimal(map["suitQuantity"]);
entity.Amount = StringUtils.GetDecimal(map["amount"]);
list.Add(entity);
}
////zhangy add 2019-11-26
//handOverProductList = handOverProductList.OrderBy(x => x.TypeId)/**.OrderBy(x => x.ProductNo)**/.ToList();
//string seriesId = "";
//string seriesName = "";
//Dictionary<string, Object> seriesMap = new Dictionary<string, Object>();
//Dictionary<string, Object> typeMap = new Dictionary<string, Object>();
//decimal count = 0.00M;
//decimal suitQuantity = 0.00M;
//decimal amount = 0.00M;
//decimal sumCount = 0.00M;
//decimal sumSuitQuantity = 0.00M;
//decimal sumAmount = 0.00M;
//int i = 0;
//List<Dictionary<string, Object>> result = new List<Dictionary<string, Object>>();
//int listLength = handOverProductList.Count;
//foreach (HandOverProduct product in handOverProductList)
//{
// string typeId = product.TypeId;
// if (!seriesId.Equals(typeId))
// {
// // 分类改变的时候把分类加入列表
// if (i != 0)
// {
// seriesMap.Add("type", 1);
// seriesMap.Add("name", seriesName);
// seriesMap.Add("count", count);
// seriesMap.Add("suitQuantity", suitQuantity);
// seriesMap.Add("amount", amount);
// result.Add(seriesMap);
// //分类改变时,清除缓存
// typeMap = new Dictionary<string, Object>();
// }
// seriesMap = new Dictionary<string, Object>();
// count = 0.00M;
// suitQuantity = 0.00M;
// amount = 0.00M;
// seriesId = typeId;
// seriesName = product.TypeName;
// }
// count += product.Count;
// suitQuantity += product.SuitQuantity;
// amount += product.Amount;
// sumCount += product.Count;
// sumSuitQuantity += product.SuitQuantity;
// sumAmount += product.Amount;
// //开始先加入分类名称
// if (!typeMap.ContainsKey("name") || !typeMap["name"].Equals(product.TypeName))
// {
// typeMap.Add("type", 3);
// typeMap.Add("name", product.TypeName == null ? "" : product.TypeName);
// typeMap.Add("count", "");
// typeMap.Add("suitQuantity", "");
// typeMap.Add("amount", "");
// result.Add(typeMap);
// }
// // 菜品加入列表
// Dictionary<string, Object> dishMap = new Dictionary<string, Object>();
// dishMap.Add("type", 0);
// if (product.SpecName != null && !"".Equals(product.SpecName))
// {
// dishMap.Add("name", product.ProductName + "(" + product.SpecName + ")");
// }
// else
// {
// dishMap.Add("name", product.ProductName);
// }
// dishMap.Add("count", product.Count);
// dishMap.Add("suitQuantity", product.SuitQuantity);
// dishMap.Add("amount", product.Amount);
// result.Add(dishMap);
// i = i + 1;
// if (i == listLength)
// {
// seriesMap.Add("type", 1);
// seriesMap.Add("name", seriesName);
// seriesMap.Add("count", count);
// seriesMap.Add("suitQuantity", suitQuantity);
// seriesMap.Add("amount", amount);
// result.Add(seriesMap);
// //分类改变时,清除缓存
// typeMap = new Dictionary<string, Object>();
// }
//}
//Dictionary<string, Object> sumMap = new Dictionary<string, Object>();
//sumMap.Add("name", LangProxy.ToLang("销售"));
//sumMap.Add("type", 2);
//sumMap.Add("count", sumCount);
//sumMap.Add("suitQuantity", sumSuitQuantity);
//sumMap.Add("amount", sumAmount);
//result.Add(sumMap);
//list = new List<HandOverProduct>();
//foreach (Dictionary<string, Object> map in result)
//{
// HandOverProduct entity = new HandOverProduct();
// entity.Type = StringUtils.GetInt(map["type"]);
// entity.Name = StringUtils.GetString(map["name"]);
// entity.Count = StringUtils.GetDecimal(map["count"]);
// entity.SuitQuantity = StringUtils.GetDecimal(map["suitQuantity"]);
// entity.Amount = StringUtils.GetDecimal(map["amount"]);
// list.Add(entity);
//}
}
catch (Exception ex)
{
LOGGER.Error(ex);
}
foreach (var item in list)
{
if (item.Type == 0)
{
item.ItemCount = StringUtils.FormatDataNoDigit(item.Count);
item.ItemSuitQuantity = StringUtils.FormatDataNoDigit(item.SuitQuantity);
item.ItemAmount = StringUtils.FormatDataNoDigit(item.Amount);
}
else if (item.Type == 1)
{
item.Name = LangProxy.ToLang("小计");
item.ItemCount = StringUtils.FormatDataNoDigit(item.Count);
item.ItemSuitQuantity = StringUtils.FormatDataNoDigit(item.SuitQuantity);
item.ItemAmount = StringUtils.FormatDataNoDigit(item.Amount);
}
else if (item.Type == 2)
{
item.Name = LangProxy.ToLang("∑合计");
item.ItemCount = StringUtils.FormatDataNoDigit(item.Count);
item.ItemSuitQuantity = StringUtils.FormatDataNoDigit(item.SuitQuantity);
item.ItemAmount = StringUtils.FormatDataNoDigit(item.Amount);
}
else if (item.Type == 3)
{
item.Name = "★★" + item.Name;
item.ItemCount = "";
item.ItemSuitQuantity = "";
item.ItemAmount = "";
}
}
return list;
}
private void OnControlBoxCloseClick(object sender, EventArgs e)
{
OnCloseTouchClick(sender, e);
}
private void OnCloseTouchClick(object sender, EventArgs e)
{
//先关闭父窗体
if (this.Owner != null)
{
this.Owner.Close();
}
//再关闭当前窗体
this.Close();
}
private void btn_exit_Click(object sender, EventArgs e)
{
OnCloseTouchClick(sender, e);
}
private void btn_time_Click(object sender, EventArgs e)
{
var obj = sender as ButtonX;
var typeStr = obj.Tag as string;
var type = (ReportQuickDate)Enum.Parse(typeof(ReportQuickDate), typeStr);
var res = DateTimeUtils.CalculateBusinessPlanDate(type, this.startPicker.Value, this.endPicker.Value);
this.startPicker.Value = res.Item1;
this.endPicker.Value = res.Item2;
QueyTicket();
}
private void btn_query_Click(object sender, EventArgs e)
{
QueyTicket();
}
private void tab_onclick(object sender, EventArgs e)
{
try
{
var obj = sender as SuperTabItem;
var name = obj.Tag as string;
this.TypeLabelX.Visible = false;
this.checkBoxX1.Visible = false;
this.checkBoxX2.Visible = false;
this.checkBoxX3.Visible = false;
switch (name)
{
case "superTabItem1"://单品汇总
PrintType = 1;
break;
case "superTabItem2"://类别汇总
PrintType = 2;
break;
case "superTabItem3"://规格分析
PrintType = 3;
break;
case "superTabItem4"://做法汇总
PrintType = 4;
break;
case "superTabItem5"://优惠明细
PrintType = 5;
break;
case "superTabItem6"://营业分析
PrintType = 6;
this.TypeLabelX.Visible = true;
this.checkBoxX1.Visible = true;
this.checkBoxX2.Visible = true;
this.checkBoxX3.Visible = true;
break;
case "superTabItem7"://云销售分析
PrintType = 7;
break;
case "superTabItem8"://本地销售分析
PrintType = 8;
break;
case "superTabItem9"://单品汇总
PrintType = 9;
break;
}
QueyTicket();
}
catch (Exception ex)
{
LOGGER.Error(ex);
}
}
public void QueyTicket()
{
workerNo = StringUtils.GetString(txtWorkNo.Text);
if (!"".Equals(workerNo) && workerNo.Length < 5)
{
int length = 5 - workerNo.Length;
for (int i = 0; i < length; i++)
{
workerNo = "0" + workerNo;
}
}
switch (PrintType)
{
case 1:
listDish = getDishList(workerNo, this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"), this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"));
productListTable.PrimaryGrid.DataSource = listDish;
break;
case 2:
listCategory = getCategoryList(workerNo, this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"), this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"));
typeListTable.PrimaryGrid.DataSource = listCategory;
break;
case 3:
listSpec = getSpecList(workerNo, this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"), this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"));
specListTable.PrimaryGrid.DataSource = listSpec;
break;
case 4:
listMake = getMakeList(workerNo, this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"), this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"));
makeListTable.PrimaryGrid.DataSource = listMake;
break;
case 5:
listOrderOromotion = getOrderOromotionList(workerNo, this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"), this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"));
OrderOromotionListTable.PrimaryGrid.DataSource = listOrderOromotion;
break;
case 6:
listBusinessSummary = getBusinessSummaryList(workerNo, this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"), this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"));
BusinessSummaryListTable.PrimaryGrid.DataSource = listBusinessSummary;
break;
case 7:
{
//默认分类
string selectIds = Global.Instance.GlobalConfigStringValue(ConfigConstant.TYPE_PATH_PARAMETER);
//加载商品分类
selectProductType = LoadSelectProductType(selectIds);
summaryListTypeYunTable.PrimaryGrid.DataSource = selectProductType;
//加载商品分析
string typeIds = LoadSeriesIds(selectIds);
yunSummary = LoadHandOverProduct(workerNo, typeIds, this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"), this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"));
yunSummaryListTable.PrimaryGrid.DataSource = yunSummary;
}
break;
case 8:
{
//默认分类
string selectIds = Global.Instance.GlobalConfigStringValue(ConfigConstant.TYPE_PATH_PARAMETER);
//加载商品分类
selectProductType = LoadSelectProductType(selectIds);
summaryListTypeTable.PrimaryGrid.DataSource = selectProductType;
//加载商品分析
string typeIds = LoadSeriesIds(selectIds);
localSummary = LoadLocalHandOverProduct(workerNo, typeIds, this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"), this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"));
summaryListTable.PrimaryGrid.DataSource = localSummary;
}
break;
case 9:
superGridControl1.PrimaryGrid.DataSource = getDishList1(workerNo, this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"), this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"));
break;
}
workerNo = string.Empty;
}
private void OnBind_dish(object sender, DevComponents.DotNetBar.SuperGrid.GridDataBindingCompleteEventArgs e)
{
var panel = e.GridPanel;
foreach (var r in panel.Rows)
{
var row = r as GridRow;
var productName = row.Cells["productName"].Value.ToString();
if (LangProxy.ToLang("合计").Equals(productName) || LangProxy.ToLang("小计").Equals(productName) || (productName.Length > 2 && productName.Substring(0, 2).Equals("★★")))
{
row.CellStyles.Default.Background.Color1 = Color.AliceBlue;
row.CellStyles.Default.Font = new Font("宋体", 14.00f, FontStyle.Bold, GraphicsUnit.Pixel);
}
}
}
private void OnBind_category(object sender, DevComponents.DotNetBar.SuperGrid.GridDataBindingCompleteEventArgs e)
{
var panel = e.GridPanel;
foreach (var r in panel.Rows)
{
var row = r as GridRow;
var typeName = row.Cells["typeName"].Value == null ? "" : row.Cells["typeName"].Value.ToString();
if (LangProxy.ToLang("合计").Equals(typeName))
{
row.CellStyles.Default.Background.Color1 = Color.AliceBlue;
row.CellStyles.Default.Font = new Font("宋体", 14.00f, FontStyle.Bold, GraphicsUnit.Pixel);
}
}
}
private void OnBind_spec(object sender, GridDataBindingCompleteEventArgs e)
{
var panel = e.GridPanel;
foreach (var r in panel.Rows)
{
var row = r as GridRow;
var typeName = row.Cells["specName"].Value;
if (LangProxy.ToLang("合计").Equals(typeName))
{
row.CellStyles.Default.Background.Color1 = Color.AliceBlue;
row.CellStyles.Default.Font = new Font("宋体", 14.00f, FontStyle.Bold, GraphicsUnit.Pixel);
}
}
}
private void OnBind_make(object sender, GridDataBindingCompleteEventArgs e)
{
var panel = e.GridPanel;
foreach (var r in panel.Rows)
{
var row = r as GridRow;
var typeName = row.Cells["makeName"].Value.ToString();
if (LangProxy.ToLang("合计").Equals(typeName))
{
row.CellStyles.Default.Background.Color1 = Color.AliceBlue;
row.CellStyles.Default.Font = new Font("宋体", 14.00f, FontStyle.Bold, GraphicsUnit.Pixel);
}
}
}
private void OnBindBusiness(object sender, GridDataBindingCompleteEventArgs e)
{
var panel = e.GridPanel;
foreach (var r in panel.Rows)
{
var row = r as GridRow;
var typeName = row.Cells["name"].Value.ToString();
if (LangProxy.ToLang("合计").Equals(typeName))
{
row.CellStyles.Default.Background.Color1 = Color.AliceBlue;
row.CellStyles.Default.Font = new Font("宋体", 14.00f, FontStyle.Bold, GraphicsUnit.Pixel);
}
}
}
/// <summary>
/// 打印事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_print_Click(object sender, EventArgs e)
{
string workerName = "";
//获取本地员工
if (workerNo != null && !"".Equals(workerNo))
{
Worker worker = StoreBusinessUtils.LocalWorker(workerNo);
if (worker != null)
{
workerName = worker.Name;
}
else
{
workerNo = "";
}
}
switch (PrintType)
{
case 1:
{
PrintSalesSummaryDish printSalesSummaryDish = new PrintSalesSummaryDish();
printSalesSummaryDish.StoreNo = Global.Instance.Worker.StoreInfo.No;
printSalesSummaryDish.StoreName = Global.Instance.Worker.StoreInfo.PrintName;
printSalesSummaryDish.WorkerNo = workerNo;
printSalesSummaryDish.WorkerName = workerName;
printSalesSummaryDish.PrintTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummaryDish.StartTime = this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummaryDish.EndTime = this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummaryDish.TotalCount = string.Format("{0}", 0);
printSalesSummaryDish.TotalMoney = string.Format("{0}", 0.00M);
List<SalesSummaryDish> imtes = new List<SalesSummaryDish>();
foreach (SalesSummaryDish dish in listDish)
{
if (!LangProxy.ToLang("合计").Equals(dish.ProductName))
{
imtes.Add(dish);
}
else
{
printSalesSummaryDish.TotalCount = string.Format("{0}", dish.SumCount);
printSalesSummaryDish.TotalMoney = string.Format("{0}", dish.SumRealMoney);
}
}
printSalesSummaryDish.Items = imtes;
this.ShowToastNotify(this, LangProxy.ToLang("开始打印"));
//构建收银小票模版参数
var vars = ReportHelper.BuilderDishVariable(printSalesSummaryDish);
Tuple<bool, string> result = ReportHelper.PrinterTicket("单品汇总", vars, true, false);
this.ShowToastNotify(this, string.Format("{0}", result.Item2));
}
break;
case 2:
{
PrintSalesSummaryCategory printSalesSummaryCategory = new PrintSalesSummaryCategory();
printSalesSummaryCategory.StoreNo = Global.Instance.Worker.StoreInfo.No;
printSalesSummaryCategory.StoreName = Global.Instance.Worker.StoreInfo.PrintName;
printSalesSummaryCategory.WorkerNo = workerNo;
printSalesSummaryCategory.WorkerName = workerName;
printSalesSummaryCategory.PrintTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummaryCategory.StartTime = this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummaryCategory.EndTime = this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummaryCategory.TotalCount = string.Format("{0}", 0);
printSalesSummaryCategory.TotalMoney = string.Format("{0}", 0.00M);
List<SalesSummaryCategory> imtes = new List<SalesSummaryCategory>();
foreach (SalesSummaryCategory category in listCategory)
{
if (!LangProxy.ToLang("合计").Equals(category.TypeName))
{
imtes.Add(category);
}
else
{
printSalesSummaryCategory.TotalCount = string.Format("{0}", category.SumCount);
printSalesSummaryCategory.TotalMoney = string.Format("{0}", category.SumRealMoney);
}
}
printSalesSummaryCategory.Items = imtes;
this.ShowToastNotify(this, LangProxy.ToLang("开始打印"));
//构建收银小票模版参数
var vars = ReportHelper.BuilderCategoryVariable(printSalesSummaryCategory);
Tuple<bool, string> result = ReportHelper.PrinterTicket("分类汇总", vars, true, false);
this.ShowToastNotify(this, string.Format("{0}", result.Item2));
}
break;
case 3:
{
PrintSalesSummarySpec printSalesSummarySpec = new PrintSalesSummarySpec();
printSalesSummarySpec.StoreNo = Global.Instance.Worker.StoreInfo.No;
printSalesSummarySpec.StoreName = Global.Instance.Worker.StoreInfo.PrintName;
printSalesSummarySpec.WorkerNo = workerNo;
printSalesSummarySpec.WorkerName = workerName;
printSalesSummarySpec.PrintTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummarySpec.StartTime = this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummarySpec.EndTime = this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummarySpec.TotalCount = string.Format("{0}", 0);
printSalesSummarySpec.TotalMoney = string.Format("{0}", 0.00M);
List<SalesSummarySpec> imtes = new List<SalesSummarySpec>();
foreach (SalesSummarySpec spec in listSpec)
{
if (!LangProxy.ToLang("合计").Equals(spec.SpecName))
{
imtes.Add(spec);
}
else
{
printSalesSummarySpec.TotalCount = string.Format("{0}", spec.SumCount);
printSalesSummarySpec.TotalMoney = string.Format("{0}", spec.SumRealMoney);
}
}
printSalesSummarySpec.Items = imtes;
this.ShowToastNotify(this, LangProxy.ToLang("开始打印"));
//构建收银小票模版参数
var vars = ReportHelper.BuilderSpecVariable(printSalesSummarySpec);
Tuple<bool, string> result = ReportHelper.PrinterTicket("规格分析", vars, true, false);
this.ShowToastNotify(this, string.Format("{0}", result.Item2));
}
break;
case 4:
{
PrintSalesSummaryMake printSalesSummaryMake = new PrintSalesSummaryMake();
printSalesSummaryMake.StoreNo = Global.Instance.Worker.StoreInfo.No;
printSalesSummaryMake.StoreName = Global.Instance.Worker.StoreInfo.PrintName;
printSalesSummaryMake.WorkerNo = workerNo;
printSalesSummaryMake.WorkerName = workerName;
printSalesSummaryMake.PrintTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummaryMake.StartTime = this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummaryMake.EndTime = this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummaryMake.TotalCount = string.Format("{0}", 0);
printSalesSummaryMake.TotalMoney = string.Format("{0}", 0.00M);
List<SalesSummaryMake> imtes = new List<SalesSummaryMake>();
foreach (SalesSummaryMake make in listMake)
{
if (!LangProxy.ToLang("合计").Equals(make.MakeName))
{
imtes.Add(make);
}
else
{
printSalesSummaryMake.TotalCount = string.Format("{0}", make.SumCount);
printSalesSummaryMake.TotalMoney = string.Format("{0}", make.SumRealMoney);
}
}
printSalesSummaryMake.Items = imtes;
this.ShowToastNotify(this, LangProxy.ToLang("开始打印"));
//构建收银小票模版参数
var vars = ReportHelper.BuilderMakeVariable(printSalesSummaryMake);
Tuple<bool, string> result = ReportHelper.PrinterTicket("做法分析", vars, true, false);
this.ShowToastNotify(this, string.Format("{0}", result.Item2));
}
break;
case 5:
{
PrintSalesSummaryDiscount printSalesSummaryDiscount = new PrintSalesSummaryDiscount();
printSalesSummaryDiscount.StoreNo = Global.Instance.Worker.StoreInfo.No;
printSalesSummaryDiscount.StoreName = Global.Instance.Worker.StoreInfo.PrintName;
printSalesSummaryDiscount.WorkerNo = workerNo;
printSalesSummaryDiscount.WorkerName = workerName;
printSalesSummaryDiscount.PrintTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummaryDiscount.StartTime = this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummaryDiscount.EndTime = this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummaryDiscount.TotalCount = string.Format("{0}", 0);
printSalesSummaryDiscount.TotalMoney = string.Format("{0}", 0.00M);
List<OrderOromotionSummary> imtes = new List<OrderOromotionSummary>();
foreach (OrderOromotionSummary discount in listOrderOromotion)
{
if (!"合计".Equals(discount.ProductName))
{
imtes.Add(discount);
}
else
{
printSalesSummaryDiscount.TotalCount = string.Format("{0}", discount.Count);
printSalesSummaryDiscount.TotalMoney = string.Format("{0}", discount.DiscountAmount);
}
}
printSalesSummaryDiscount.Items = imtes;
this.ShowToastNotify(this, LangProxy.ToLang("开始打印"));
//构建收银小票模版参数
var vars = ReportHelper.BuilderDiscountVariable(printSalesSummaryDiscount);
Tuple<bool, string> result = ReportHelper.PrinterTicket("优惠明细", vars, true, false);
this.ShowToastNotify(this, string.Format("{0}", result.Item2));
}
break;
case 6:
{
PrintBusinessSummary printBusinessSummary = new PrintBusinessSummary();
printBusinessSummary.StoreNo = Global.Instance.Worker.StoreInfo.No;
printBusinessSummary.StoreName = Global.Instance.Worker.StoreInfo.PrintName;
printBusinessSummary.WorkerNo = workerNo;
printBusinessSummary.WorkerName = workerName;
printBusinessSummary.PrintTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
printBusinessSummary.StartTime = this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
printBusinessSummary.EndTime = this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
printBusinessSummary.TotalPeople = string.Format("{0}", 0);
printBusinessSummary.TotalCount = string.Format("{0}", 0);
printBusinessSummary.TotalAmount = string.Format("{0}", 0.00M);
printBusinessSummary.TotalDiscount = string.Format("{0}", 0.00M);
printBusinessSummary.TotalMoney = string.Format("{0}", 0.00M);
printBusinessSummary.Dj = string.Format("{0}", 0.00M);
printBusinessSummary.Rj = string.Format("{0}", 0.00M);
List<BusinessSummary> imtes = new List<BusinessSummary>();
foreach (BusinessSummary summary in listBusinessSummary)
{
if (!LangProxy.ToLang("合计").Equals(summary.Name))
{
imtes.Add(summary);
}
else
{
printBusinessSummary.TotalPeople = string.Format("{0}", summary.People);
printBusinessSummary.TotalCount = string.Format("{0}", summary.Count);
printBusinessSummary.TotalAmount = string.Format("{0}", DecimalUtils.ToRound(summary.Amount, 2));
printBusinessSummary.TotalDiscount = string.Format("{0}", DecimalUtils.ToRound(summary.DiscountAmount, 2));
printBusinessSummary.TotalMoney = string.Format("{0}", DecimalUtils.ToRound(summary.ReceivableAmount, 2));
printBusinessSummary.Dj = string.Format("{0}", DecimalUtils.ToRound(summary.TicketPrice, 2));
printBusinessSummary.Rj = string.Format("{0}", DecimalUtils.ToRound(summary.PeoplePrice, 2));
}
}
printBusinessSummary.Items = imtes;
this.ShowToastNotify(this, LangProxy.ToLang("开始打印"));
//构建收银小票模版参数
var vars = ReportHelper.BuilderBusinessSummaryVariable(printBusinessSummary);
Tuple<bool, string> result = ReportHelper.PrinterTicket("营业分析", vars, true, false);
this.ShowToastNotify(this, string.Format("{0}", result.Item2));
}
break;
case 7:
{
PrintSalesSummary printSalesSummary = new PrintSalesSummary();
printSalesSummary.StoreNo = Global.Instance.Worker.StoreInfo.No;
printSalesSummary.StoreName = Global.Instance.Worker.StoreInfo.PrintName;
printSalesSummary.WorkerNo = workerNo;
printSalesSummary.WorkerName = workerName;
printSalesSummary.PrintTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummary.StartTime = this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummary.EndTime = this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummary.Items = yunSummary;
this.ShowToastNotify(this, LangProxy.ToLang("开始打印"));
//构建收银小票模版参数
var vars = ReportHelper.BuilderPrintSalesSummaryVariable(printSalesSummary);
Tuple<bool, string> result = ReportHelper.PrinterTicket("销售分析", vars, true, false);
this.ShowToastNotify(this, string.Format("{0}", result.Item2));
}
break;
case 8:
{
PrintSalesSummary printSalesSummary = new PrintSalesSummary();
printSalesSummary.StoreNo = Global.Instance.Worker.StoreInfo.No;
printSalesSummary.StoreName = Global.Instance.Worker.StoreInfo.PrintName;
printSalesSummary.WorkerNo = workerNo;
printSalesSummary.WorkerName = workerName;
printSalesSummary.PrintTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummary.StartTime = this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummary.EndTime = this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummary.Items = localSummary;
this.ShowToastNotify(this, LangProxy.ToLang("开始打印"));
//构建收银小票模版参数
var vars = ReportHelper.BuilderPrintSalesSummaryVariable(printSalesSummary);
Tuple<bool, string> result = ReportHelper.PrinterTicket("销售分析", vars, true, false);
this.ShowToastNotify(this, string.Format("{0}", result.Item2));
}
break;
case 9:
{
PrintSalesSummaryDish printSalesSummaryDish = new PrintSalesSummaryDish();
printSalesSummaryDish.StoreNo = Global.Instance.Worker.StoreInfo.No;
printSalesSummaryDish.StoreName = Global.Instance.Worker.StoreInfo.PrintName;
printSalesSummaryDish.WorkerNo = workerNo;
printSalesSummaryDish.WorkerName = workerName;
printSalesSummaryDish.PrintTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummaryDish.StartTime = this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummaryDish.EndTime = this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
printSalesSummaryDish.TotalCount = string.Format("{0}", 0);
printSalesSummaryDish.TotalMoney = string.Format("{0}", 0.00M);
List<SalesSummaryDish> imtes = new List<SalesSummaryDish>();
foreach (SalesSummaryDish dish in listDish1)
{
if (!LangProxy.ToLang("合计").Equals(dish.ProductName))
{
imtes.Add(dish);
}
else
{
printSalesSummaryDish.TotalCount = string.Format("{0}", dish.SumCount);
printSalesSummaryDish.TotalMoney = string.Format("{0}", dish.SumRealMoney);
}
}
printSalesSummaryDish.Items = imtes;
this.ShowToastNotify(this, LangProxy.ToLang("开始打印"));
//构建收银小票模版参数
var vars = ReportHelper.BuilderDishVariable1(printSalesSummaryDish);
Tuple<bool, string> result = ReportHelper.PrinterTicket("单品汇总", vars, true, false);
this.ShowToastNotify(this, string.Format("{0}", result.Item2));
}
break;
}
}
private void OnControlBoxMinClick(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
/// <summary>
/// 日期值改变的时候查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void onDateChange(object sender, EventArgs e)
{
//QueyTicket();
}
private void OnBind_Discount(object sender, GridDataBindingCompleteEventArgs e)
{
var panel = e.GridPanel;
foreach (var r in panel.Rows)
{
var row = r as GridRow;
var productName = row.Cells["productName"].Value.ToString();
if (LangProxy.ToLang("合计").Equals(productName) || LangProxy.ToLang("小计").Equals(productName) || (productName.Length > 2 && productName.Substring(0, 2).Equals("★★")))
{
row.CellStyles.Default.Background.Color1 = Color.AliceBlue;
row.CellStyles.Default.Font = new Font("宋体", 14.00f, FontStyle.Bold, GraphicsUnit.Pixel);
}
}
}
/// <summary>
/// 日、周、月选择
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CbChangeClick(object sender, EventArgs e)
{
var obj = sender as CheckBoxX;
var indexT = obj.Tag as string;
if (LangProxy.ToLang("日").Equals(LangProxy.ToLang(indexT)))
{
queryType = 0;
}
if (LangProxy.ToLang("周").Equals(LangProxy.ToLang(indexT)))
{
queryType = 1;
}
if (LangProxy.ToLang("月").Equals(LangProxy.ToLang(indexT)))
{
queryType = 2;
}
QueyTicket();
}
private void OnBind_yunSummary(object sender, GridDataBindingCompleteEventArgs e)
{
var panel = e.GridPanel;
foreach (var r in panel.Rows)
{
var row = r as GridRow;
var typeName = row.Cells["name"].Value;
if (LangProxy.ToLang("小计").Equals(typeName))
{
row.CellStyles.Default.Background.Color1 = Color.AliceBlue;
row.CellStyles.Default.Font = new Font("宋体", 14.00f, FontStyle.Bold, GraphicsUnit.Pixel);
}
else if (LangProxy.ToLang("∑合计").Equals(typeName))
{
row.CellStyles.Default.Background.Color1 = Color.AliceBlue;
row.CellStyles.Default.Font = new Font("宋体", 14.00f, FontStyle.Bold, GraphicsUnit.Pixel);
}
else if (typeName.ToString().Contains("★★"))
{
row.CellStyles.Default.Background.Color1 = Color.AliceBlue;
row.CellStyles.Default.Font = new Font("宋体", 14.00f, FontStyle.Bold, GraphicsUnit.Pixel);
}
}
}
/// <summary>
/// 全选功能
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnCheckedAllChanged(object sender, EventArgs e)
{
var obj = sender as CheckBoxX;
GridPanel panel = null;
if (PrintType == 7)
{
panel = this.summaryListTypeYunTable.PrimaryGrid;
}
else if (PrintType == 8)
{
panel = this.summaryListTypeTable.PrimaryGrid;
}
if (obj.Checked)
{
//全选
foreach (var tempRow in panel.Rows)
{
var row = tempRow as GridRow;
row.Checked = true;
}
//string ids = "";
//foreach (SelectProductType type in selectProductType) {
// ids = ids + type.Id + ",";
//}
//if (ids!=null && !"".Equals(ids)) {
// ids = ids.Substring(0, ids.Length-1);
//}
//SaveTypePath(ids);
}
else
{
//全取消
foreach (var tempRow in panel.Rows)
{
var row = tempRow as GridRow;
row.Checked = false;
}
//SaveTypePath("");
}
}
public void LoadDefalut()
{
GridPanel panel = null;
if (PrintType == 7)
{
panel = this.summaryListTypeYunTable.PrimaryGrid;
}
else if (PrintType == 8)
{
panel = this.summaryListTypeTable.PrimaryGrid;
}
foreach (var tempRow in panel.Rows)
{
var row = tempRow as GridRow;
if ("false".Equals(row.Cells["isChecked"].Value.ToString()) || "False".Equals(row.Cells["isChecked"].Value.ToString()))
{
row.Checked = false;
}
else
{
row.Checked = true;
}
}
}
public void SaveTypePath(string ids)
{
var config = new Config();
config.Id = IdWorkerUtils.Instance.NextId();
config.Group = ConfigConstant.DEVICE_GROUP;
config.TenantId = Global.Instance.Authc.TenantId;
config.Keys = ConfigConstant.TYPE_PATH_PARAMETER;
config.Values = string.Format("{0}", ids);
LOGGER.Info("保存的订单IDS==>{0}......", ids);
try
{
using (var db = Global.Instance.OpenDataBase)
{
using (var trans = db.GetTransaction())
{
db.Save(config);
trans.Complete();
}
}
Global.Instance.ReloadConfig(ConfigConstant.DEVICE_GROUP);
}
catch (Exception ex)
{
string message = "类别汇总设置";
LOGGER.Error(ex, message);
}
}
private void OnBindProductType(object sender, GridDataBindingCompleteEventArgs e)
{
LoadDefalut();
}
private void OnOrderCellClick(object sender, GridCellClickEventArgs e)
{
var grid = e.GridPanel;
if (grid.ActiveRow != null)
{
GridRow row = grid.ActiveRow as GridRow;
if (row.Checked)
{
row.Checked = false;
}
else
{
row.Checked = true;
}
}
}
private void OnAfterCheck(object sender, GridAfterCheckEventArgs e)
{
LOGGER.Info("OnAfterCheck");
GridPanel panel = null;
if (PrintType == 7)
{
panel = this.summaryListTypeYunTable.PrimaryGrid;
}
else if (PrintType == 8)
{
panel = this.summaryListTypeTable.PrimaryGrid;
}
string ids = "";
foreach (var tempRow in panel.Rows)
{
var row = tempRow as GridRow;
if (row.Checked)
{
var id = row.Cells["id"].Value.ToString();
ids = ids + id + ",";
}
}
if (ids != null && !"".Equals(ids))
{
ids = ids.Substring(0, ids.Length - 1);
}
SaveTypePath(ids);
}
private void DataGridView1_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
{
//// 如果是学号或成绩列,则按浮点数处理
//if (e.Column.Name == "学号" || e.Column.Name == "成绩")
//{
// e.SortResult = (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) > 0) ? 1 : (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) < 0) ? -1 : 0;
//}
////否则,按字符串比较
//else
//{
// e.SortResult = System.String.Compare(Convert.ToString(e.CellValue1), Convert.ToString(e.CellValue2));
//}
//// 如果发现两行相同,则按学号排序
//if (e.SortResult == 0 && e.Column.Name != "学号")
//{
// e.SortResult = Convert.ToInt32(DataGridView1.Rows[e.RowIndex1].Cells["学号"].Value.ToString()) -
// Convert.ToInt32(DataGridView1.Rows[e.RowIndex2].Cells["学号"].Value.ToString());
//}
//e.Handled = true;//不能省掉,不然没效果
}
private void productListTable_CellClick(object sender, GridCellClickEventArgs e)
{
}
bool _descending = false;
private void productListTable_ColumnHeaderClick(object sender, GridColumnHeaderClickEventArgs e)
{
switch (e.GridColumn.Name)
{
case "sumCount":
{
e.GridColumn.ColumnSortMode = ColumnSortMode.None;
superGridControl1_SortChanged(null, null);
}
break;
default:
break;
}
}
private void superGridControl1_SortChanged(object sender, GridEventArgs e)
{
if (_descending)
{
var _list = listDish1.OrderBy(f => f.SumCount).ToList();
SalesSummaryDish dish = new SalesSummaryDish();
dish.ProductName = LangProxy.ToLang("合计");
dish.SumCount = listDish1.Sum(f => f.SumCount);
dish.SumMoney = listDish1.Sum(f => f.SumMoney);
dish.SumRealMoney = listDish1.Sum(f => f.SumRealMoney);
_list.Add(dish);
superGridControl1.PrimaryGrid.DataSource = _list;
_descending = false;
}
else
{
var _list = listDish1.OrderByDescending(f => f.SumCount).ToList();
SalesSummaryDish dish = new SalesSummaryDish();
dish.ProductName = LangProxy.ToLang("合计");
dish.SumCount = listDish1.Sum(f => f.SumCount);
dish.SumMoney = listDish1.Sum(f => f.SumMoney);
dish.SumRealMoney = listDish1.Sum(f => f.SumRealMoney);
_list.Add(dish);
superGridControl1.PrimaryGrid.DataSource = _list;
_descending = true;
}
}
private void superGridControl1_StoreVirtualRow(object sender, GridVirtualRowEventArgs e)
{
}
}
}