286 lines
13 KiB
C#
286 lines
13 KiB
C#
using System;
|
|
using System.Configuration;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Web.UI.WebControls;
|
|
using SuperMap.RealEstate.Web.UI.WebControls;
|
|
using Business = SuperMap.RealEstate.HighWay.Storage.Business;
|
|
using HZQR.Common;
|
|
|
|
namespace SuperMap.RealEstate.HighWay.Modules.SellData
|
|
{
|
|
public partial class Default : BasePage
|
|
{
|
|
protected string SERVERPART_IDS = "", SERVERPARTSHOP_IDS = "";
|
|
private DataTable _DataTable = null;
|
|
protected string _bCompanyName = ConfigurationManager.AppSettings["bCompanyName"].ToString().Split('|')[0];
|
|
protected string _bReportTitle = ConfigurationManager.AppSettings["bReportTiTle"].ToString();
|
|
|
|
#region 方法 -> 页面加载
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (IsPostBack) return;
|
|
|
|
//Label1.Text = _bCompanyName + "<br/>门店销售流水汇总表";
|
|
InitWebControls();
|
|
Business.CommonHelper.BindReportHeader(Label1, _bReportTitle, "门店销售流水汇总表", PassportInfo.CityAuthority, Transaction);
|
|
//初始化并加载列表
|
|
//GridViewEx1.SelectingWithInit<HWSDB.SELLDATA>(ObjectDataSource1, GridPageEx1);
|
|
//设置回车焦点按钮
|
|
SetControlClientAction(ButtonStatistics, false);
|
|
SetControlClientAction(ButtonSearch);
|
|
}
|
|
|
|
private void InitWebControls()
|
|
{
|
|
START_DATE.Text = DateTime.Now.Date.ToString("yyyy/MM/dd HH:mm:ss");
|
|
END_DATE.Text = DateTime.Now.Date.AddDays(1).AddSeconds(-1).ToString("yyyy/MM/dd HH:mm:ss");
|
|
|
|
BindServerPartData();
|
|
}
|
|
#endregion
|
|
|
|
#region 方法 -> 获取查询的门店集合
|
|
private List<string> GetSERVERPARTSHOP_ID()
|
|
{
|
|
List<string> list = new List<string>();
|
|
foreach (TreeNode _FormatTreeNode in MyTreeView.Nodes)
|
|
{
|
|
foreach (TreeNode _FirstTreeNode in _FormatTreeNode.ChildNodes)
|
|
{
|
|
foreach (TreeNode _TwoTreeNode in _FirstTreeNode.ChildNodes)
|
|
{
|
|
|
|
foreach (TreeNode _TreeNode in _TwoTreeNode.ChildNodes)
|
|
{
|
|
if (_TreeNode.Checked)
|
|
list.Add(_TreeNode.Value);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
return list;
|
|
}
|
|
#endregion
|
|
|
|
#region 方法 -> 绑定树信息
|
|
private void BindServerPartData()
|
|
{
|
|
string _SERVERPART_IDS = new Storage.Business.SERVERPART(Transaction).GetPassportServerPartID(PassportInfo.CityAuthority, "1000,1001,2000");
|
|
Storage.Business.CommonHelper.BindServerPartTreeView(MyTreeView, _SERVERPART_IDS, Transaction, true, false, false);
|
|
}
|
|
|
|
protected void MyTreeView_TreeNodeCheckChanged(object sender, TreeNodeEventArgs e)
|
|
{
|
|
treeView_Checked(e.Node.ChildNodes, e.Node.Checked);
|
|
}
|
|
|
|
private void treeView_Checked(TreeNodeCollection nodes, bool Checked)
|
|
{
|
|
foreach (TreeNode treeNode in nodes)
|
|
{
|
|
treeNode.Checked = Checked;
|
|
treeView_Checked(treeNode.ChildNodes, Checked);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 方法 -> 获取服务区
|
|
private void GetServerpart()
|
|
{
|
|
SERVERPART_IDS = ""; SERVERPARTSHOP_IDS = "";
|
|
foreach (TreeNode _TreeNode in MyTreeView.CheckedNodes)
|
|
{
|
|
if (_TreeNode.Target == "SERVERPARTSHOP")
|
|
{
|
|
SERVERPARTSHOP_IDS += SERVERPARTSHOP_IDS == "" ? _TreeNode.Value : "," + _TreeNode.Value;
|
|
}
|
|
else if (_TreeNode.Target == "SERVERPART")
|
|
{
|
|
SERVERPART_IDS += SERVERPART_IDS == "" ? _TreeNode.Value : "," + _TreeNode.Value;
|
|
}
|
|
}
|
|
//MyTreeView.ExpandAll();
|
|
}
|
|
#endregion
|
|
|
|
#region 方法 -> 查询
|
|
protected void ButtonStatistics_Click(object sender, EventArgs e)
|
|
{
|
|
ButtonSearch.Visible = true;
|
|
//获取查询的门店集合
|
|
GetServerpart();
|
|
//查询数据
|
|
GridViewEx1.SelectingWithInit<ExchangeData.Business.SELLDATA>(ObjectDataSource1, GridPageEx1);
|
|
ENDACCOUNT_DATE.Visible = true;
|
|
//绑定统计日期、制单人、制单时间
|
|
ENDACCOUNT_DATE.Text = "统计时间:" + START_DATE.Text + "至" + END_DATE.Text;
|
|
div_sign.Attributes["style"] = "display:block";
|
|
lblStaffName.Visible = true;
|
|
lblStaffName.Text = "制单人:" + PassportInfo.Name;
|
|
lblDate.Visible = true;
|
|
lblDate.Text = "制单时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
}
|
|
#endregion
|
|
|
|
#region 方法 -> 列表事件
|
|
//查询
|
|
protected void ButtonSearch_CallBackClick(object sender, ClientSetEventArgs e)
|
|
{
|
|
GridViewEx1.Selecting<ExchangeData.Business.SELLDATA>(ObjectDataSource1, GridPageEx1);
|
|
//设置UI变化
|
|
e.SetValue(GridViewEx1);
|
|
e.SetValue(GridPageEx1);
|
|
}
|
|
|
|
//翻页事件
|
|
protected void GridPageEx1_CallBackPageChanged(object src, ClientSetEventArgs e)
|
|
{
|
|
GridViewEx1.Pagging<ExchangeData.Business.SELLDATA>(ObjectDataSource1, GridPageEx1);
|
|
//设置UI变化
|
|
e.SetValue(GridViewEx1);
|
|
}
|
|
|
|
//查询SQL设置
|
|
protected void GridViewEx1_SelectMethodParameters(object sender, SelectMethodParametersArgs e)
|
|
{
|
|
//搜索选项的搜索条件过滤
|
|
if (!string.IsNullOrEmpty(TextBox_Search.Text))
|
|
e.AddOrParams(GridViewSearch1, TextBox_Search.Text);
|
|
|
|
e.AddAndParams("1", 1);
|
|
List<string> list = GetSERVERPARTSHOP_ID();
|
|
//if (BusinessType.SelectedIndex > 0 && !string.IsNullOrEmpty(BusinessType.SelectedValue))
|
|
//{
|
|
// e.AddAndParams("SHOPTRADE", BusinessType.SelectedValue);
|
|
//}
|
|
if (!string.IsNullOrEmpty(SERVERPART_IDS))
|
|
{
|
|
e.SetOtherUserCustomWhereSqlString += (e.SetOtherUserCustomWhereSqlString == "" ? "" : " AND ") +
|
|
"SERVERPART_ID IN (" + SERVERPART_IDS + ")";
|
|
}
|
|
else
|
|
{
|
|
e.SetOtherUserCustomWhereSqlString += (e.SetOtherUserCustomWhereSqlString == "" ? "" : " AND ") +
|
|
"SERVERPART_ID IN (" + new Business.SERVERPART(Transaction).GetPassportServerPartID(PassportInfo.CityAuthority) + ")";
|
|
}
|
|
if (!string.IsNullOrEmpty(SERVERPARTSHOP_IDS))
|
|
{
|
|
SERVERPARTSHOP_IDS = HZQR.Common.Common.Common.GetInString("SERVERPARTSHOP_ID", list);
|
|
|
|
//WhereSql += " AND SHOPCODE IN (SELECT SHOPCODE FROM HIGHWAY_STORAGE.T_SERVERPARTSHOP WHERE ISVALID = 1 AND (" + SERVERPARTSHOP_IDS + "))";
|
|
e.SetOtherUserCustomWhereSqlString += (e.SetOtherUserCustomWhereSqlString == "" ? "" : " AND ") + SERVERPARTSHOP_IDS;
|
|
}
|
|
if (!string.IsNullOrEmpty(START_DATE.Text.Trim()))
|
|
{
|
|
e.SetOtherUserCustomWhereSqlString += (e.SetOtherUserCustomWhereSqlString == "" ? "" : " AND ") +
|
|
"SELLMASTER_DATE >= TO_DATE('" + START_DATE.Text.Trim() + "','YYYY/MM/DD HH24:MI:SS')";
|
|
}
|
|
if (!string.IsNullOrEmpty(END_DATE.Text.Trim()))
|
|
{
|
|
e.SetOtherUserCustomWhereSqlString += (e.SetOtherUserCustomWhereSqlString == "" ? "" : " AND ") +
|
|
"SELLMASTER_DATE <= TO_DATE('" + END_DATE.Text.Trim() + "','YYYY/MM/DD HH24:MI:SS')";
|
|
}
|
|
//且搜索条件
|
|
//e.AddAndParams(字段名, 值);
|
|
//或搜索条件
|
|
//e.AddOrParams(字段名, 值);
|
|
//排序
|
|
e.AddOrderByParams(GridViewOrderBy1);
|
|
}
|
|
#endregion
|
|
|
|
#region 方法 -> 行绑定事件
|
|
protected void GridViewEx1_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
string _SELLMASTER_CODE = GridViewEx1.DataKeys[e.Row.RowIndex]["SELLMASTER_CODE"].ToString();
|
|
|
|
DataTable _DataTable = new ExchangeData.Business.SELLDATA(Transaction).ExecuteDataTable(
|
|
"SELECT * FROM T_SELLDETAILS WHERE SELLMASTER_CODE = '" + _SELLMASTER_CODE + "'");
|
|
string _CommodityInfo = "";
|
|
foreach (DataRow _DataRow in _DataTable.Rows)
|
|
{
|
|
_CommodityInfo += _DataRow["COMMODITY_NAME"].ToString() + "(" + _DataRow["SELLDETAILS_COUNT"].ToString() +
|
|
"*" + _DataRow["SELLDETAILS_PRICE"].ToString() + "),";
|
|
}
|
|
if (_CommodityInfo != "")
|
|
{
|
|
if (_CommodityInfo.Trim(',').Length > 20)
|
|
{
|
|
e.Row.ToolTip = _CommodityInfo.Trim(',');
|
|
e.Row.Cells[3].Text = _CommodityInfo.Trim(',').Substring(0, 20) + "...";
|
|
}
|
|
else
|
|
{
|
|
e.Row.Cells[3].Text = _CommodityInfo.Trim(',');
|
|
}
|
|
}
|
|
|
|
for (int CellCount = 7; CellCount < e.Row.Cells.Count - 3; CellCount++)
|
|
{
|
|
if (decimal.Parse(e.Row.Cells[CellCount].Text.Replace(" ", "0")) == 0)
|
|
{
|
|
e.Row.Cells[CellCount].Text = "";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 方法 -> 导出对应的Excel
|
|
protected void ButtonExport_Click(object sender, EventArgs e)
|
|
{
|
|
GetServerpart();
|
|
List<string> list = GetSERVERPARTSHOP_ID();
|
|
string WhereSql = "";
|
|
string StrSql = @"SELECT A.SELLMASTER_DATE AS 销售时间,A.TICKET_CODE AS 小票编号,
|
|
WM_CONCAT(B.COMMODITY_NAME || '(' || B.SELLCOUNT || '*' || B.SELLPRICE || ')') AS 流水详情,
|
|
A.SELLMASTER_COUNT AS 销售数量,A.SELLMASTER_AMOUNT AS 实收金额,A.SELLMASTER_OFFPRICE AS 优惠金额,
|
|
A.CASHPAY AS 现金支付,A.MOBILEPAY AS 移动支付,A.COUPONPAY AS 消费券,A.INTERNALPAY AS 企业会员,
|
|
A.MEMBERPAY AS 会员卡支付,A.BANKPAY AS 银联支付,A.SERVERPART_NAME AS 服务区名称,
|
|
A.SHOPNAME AS 门店名称,A.MACHINECODE AS 收银机号
|
|
FROM {0} A,T_SELLDETAILS B
|
|
WHERE A.SELLMASTER_CODE = B.SELLMASTER_CODE {1}
|
|
GROUP BY A.SELLMASTER_DATE,A.SERVERPART_NAME,A.SHOPNAME,A.SELLMASTER_COUNT,A.SELLMASTER_AMOUNT,A.SELLMASTER_OFFPRICE,
|
|
A.CASHPAY,A.MOBILEPAY,A.COUPONPAY,A.INTERNALPAY,A.MEMBERPAY,A.BANKPAY,A.MACHINECODE,A.TICKET_CODE";
|
|
//if (BusinessType.SelectedIndex > 0 && !string.IsNullOrEmpty(BusinessType.SelectedValue))
|
|
//{
|
|
// WhereSql += " AND A.SHOPTRADE IN (" + BusinessType.SelectedValue + ")";
|
|
//}
|
|
if (!string.IsNullOrEmpty(SERVERPART_IDS))
|
|
{
|
|
WhereSql += " AND A.SERVERPART_ID IN (" + SERVERPART_IDS + ")";
|
|
}
|
|
else
|
|
{
|
|
WhereSql += " AND A.SERVERPART_ID IN (" + new Business.SERVERPART(
|
|
Transaction).GetPassportServerPartID(PassportInfo.CityAuthority) + ")";
|
|
}
|
|
if (!string.IsNullOrEmpty(SERVERPARTSHOP_IDS))
|
|
{
|
|
SERVERPARTSHOP_IDS = HZQR.Common.Common.Common.GetInString("A.SERVERPARTSHOP_ID", list);
|
|
WhereSql += " AND " + SERVERPARTSHOP_IDS;
|
|
}
|
|
if (!string.IsNullOrEmpty(START_DATE.Text.Trim()))
|
|
{
|
|
WhereSql += " AND A.SELLMASTER_DATE >= TO_DATE('" + START_DATE.Text.Trim() + "','YYYY/MM/DD HH24:MI:SS')";
|
|
}
|
|
if (!string.IsNullOrEmpty(END_DATE.Text.Trim()))
|
|
{
|
|
WhereSql += " AND A.SELLMASTER_DATE <= TO_DATE('" + END_DATE.Text.Trim() + "','YYYY/MM/DD HH24:MI:SS')";
|
|
}
|
|
|
|
_DataTable = new ExchangeData.Business.SELLDATA(Transaction).ExecuteDataTable(
|
|
string.Format(StrSql, GridViewEx1.DataTableName, WhereSql));
|
|
ExcelHelper _ExcelHelper = new ExcelHelper();
|
|
_ExcelHelper.DataTableToExcel(Label1.Text, ENDACCOUNT_DATE.Text, lblStaffName.Text, lblDate.Text,
|
|
null, Label1.Text + "导出", _DataTable, "门店销售流水汇总表", true);
|
|
}
|
|
#endregion
|
|
}
|
|
}
|