using System; using System.Configuration; using System.Collections.Generic; using System.Data; using System.Web.UI; 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 : Storage.UI.BasePage { protected string SERVERPART_IDS = "", SERVERPARTSHOP_IDS = ""; private DataTable _DataTable = null; #region 方法 -> 页面加载 protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; InitControls(); Business.CommonHelper.BindReportHeader(Label1, PassportInfo.ProvinceUnit, "门店销售流水汇总表", PassportInfo.CityAuthority, Transaction); //设置回车焦点按钮 SetControlClientAction(ButtonStatistics, false); SetControlClientAction(ButtonSearch); } #endregion #region 方法 -> 初始化页面控件 private void InitControls() { SERVERPART_ID.Items.Clear(); ListItemEx _ListItemEx = new ListItemEx(); foreach (Business.SERVERPART _SERVERPART in new Business.SERVERPART(Transaction).GetPassportServerPart( PassportInfo.CityAuthority, "1000,1001")) { _ListItemEx = new ListItemEx(); _ListItemEx.Value = _SERVERPART.KeyID; _ListItemEx.Text = _SERVERPART.SERVERPART_NAME; SERVERPART_ID.Items.Add(_ListItemEx); } SERVERPART_ID.SelectedIndex = 0; string StrSql = string.Empty; SERVERPARTSHOP_ID.Items.Clear(); _ListItemEx = new ListItemEx(); _ListItemEx.Text = "所有门店"; _ListItemEx.Value = "1=1"; SERVERPARTSHOP_ID.Items.Add(_ListItemEx); //绑定对应的商家统计 if (SERVERPART_ID.SelectedValue != "1=1") { foreach (Business.SERVERPARTSHOP _SERVERPARTSHOP in new Business.SERVERPARTSHOP(Transaction).FillCollection( "WHERE ISVALID = 1 AND SHOPTRADE NOT IN ('9032','9999') AND SERVERPART_ID = " + SERVERPART_ID.SelectedValue + " AND NVL(STATISTIC_TYPE,1000) IN (1000,2000) ORDER BY SHOPREGION,SHOPTRADE,SHOPCODE")) { _ListItemEx = new ListItemEx(); _ListItemEx.Text = _SERVERPARTSHOP.SHOPNAME; _ListItemEx.Value = _SERVERPARTSHOP.KeyID; _ListItemEx.Level = 1; SERVERPARTSHOP_ID.Items.Add(_ListItemEx); } } StatisticsDay.Text = DateTime.Now.Date.AddDays(-1).ToString(); } #endregion #region 方法 -> 绑定下拉框门店 protected void SERVERPART_ID_CallBackSetControl(object sender, ClientSetEventArgs e) { string StrSql = string.Empty; SERVERPARTSHOP_ID.Items.Clear(); ListItemEx _ListItemEx = new ListItemEx(); _ListItemEx.Text = "所有门店"; _ListItemEx.Value = "1=1"; SERVERPARTSHOP_ID.Items.Add(_ListItemEx); //绑定对应的商家统计 if (!string.IsNullOrEmpty(e.Argument) && e.Argument != "1=1") { foreach (Business.SERVERPARTSHOP _SERVERPARTSHOP in new Business.SERVERPARTSHOP(Transaction).FillCollection( "WHERE ISVALID = 1 AND SHOPTRADE NOT IN ('9032','9999') AND SERVERPART_ID = " + SERVERPART_ID.SelectedValue + " AND NVL(STATISTIC_TYPE,1000) IN (1000,2000) ORDER BY SHOPREGION,SHOPTRADE,SHOPCODE")) { _ListItemEx = new ListItemEx(); _ListItemEx.Text = _SERVERPARTSHOP.SHOPNAME; _ListItemEx.Value = _SERVERPARTSHOP.KeyID; _ListItemEx.Level = 1; SERVERPARTSHOP_ID.Items.Add(_ListItemEx); } } e.SetDropDownListEx(SERVERPARTSHOP_ID); } #endregion #region 方法 -> 查询 protected void ButtonStatistics_Click(object sender, EventArgs e) { ButtonSearch.Visible = true; //获取查询的门店集合 if (string.IsNullOrEmpty(SERVERPART_ID.SelectedValue)) { Alert("请选择服务区!"); return; } #region 表头隐藏选项 bool cashpayShow = true; //现金支付显示 bool mobilepayShow = true; //移动支付显示 bool couponpayShow = true; //消费(大巴)券显示 bool internalpayShow = true; //企业会员显示 bool memberpayShow = true; //会员卡支付显示 bool bankpayShow = true; //银联卡支付显示 foreach (Control _Control in LayoutButton_Visable.Controls) { if (_Control is CheckBoxEx && (_Control as CheckBoxEx).Checked) { if (_Control.ClientID == "B_L_LB_CASHPAY") { cashpayShow = false; } else if (_Control.ClientID == "B_L_LB_MOBILEPAY") { mobilepayShow = false; } else if (_Control.ClientID == "B_L_LB_COUPONPAY") { couponpayShow = false; } else if (_Control.ClientID == "B_L_LB_INTERNALPAY") { internalpayShow = false; } else if (_Control.ClientID == "B_L_LB_MEMBERPAY") { memberpayShow = false; } else if (_Control.ClientID == "B_L_LB_BANKPAY") { bankpayShow = false; } } } if (cashpayShow) { GridViewEx1.Columns[7].Visible = true; } else { GridViewEx1.Columns[7].Visible = false; } if (mobilepayShow) { GridViewEx1.Columns[8].Visible = true; } else { GridViewEx1.Columns[8].Visible = false; } if (couponpayShow) { GridViewEx1.Columns[9].Visible = true; } else { GridViewEx1.Columns[9].Visible = false; } if (internalpayShow) { GridViewEx1.Columns[10].Visible = true; } else { GridViewEx1.Columns[10].Visible = false; } if (memberpayShow) { GridViewEx1.Columns[11].Visible = true; } else { GridViewEx1.Columns[11].Visible = false; } if (bankpayShow) { GridViewEx1.Columns[12].Visible = true; } else { GridViewEx1.Columns[12].Visible = false; } #endregion Business.CommonHelper.BindReportHeader(Label1, PassportInfo.ProvinceUnit, SERVERPART_ID.SelectedItem.Text + "门店销售流水汇总表", PassportInfo.CityAuthority, Transaction); //查询数据 GridViewEx1.SelectingWithInit(ObjectDataSource1, GridPageEx1); //绑定统计日期、制单人、制单时间 ENDACCOUNT_DATE.Visible = true; ENDACCOUNT_DATE.Text = "统计时间:" + StatisticsDay.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(ObjectDataSource1, GridPageEx1); //设置UI变化 e.SetValue(GridViewEx1); e.SetValue(GridPageEx1); } //翻页事件 protected void GridPageEx1_CallBackPageChanged(object src, ClientSetEventArgs e) { GridViewEx1.Pagging(ObjectDataSource1, GridPageEx1); //设置UI变化 e.SetValue(GridViewEx1); } //查询SQL设置 protected void GridViewEx1_SelectMethodParameters(object sender, SelectMethodParametersArgs e) { if (!string.IsNullOrEmpty(SERVERPART_ID.SelectedValue)) { //搜索选项的搜索条件过滤 if (!string.IsNullOrEmpty(TextBox_Search.Text)) e.AddOrParams(GridViewSearch1, TextBox_Search.Text); e.AddAndParams("1", 1); e.AddAndParams("SERVERPART_ID", SERVERPART_ID.SelectedValue); if (!string.IsNullOrEmpty(SERVERPARTSHOP_ID.SelectedValue) && SERVERPARTSHOP_ID.SelectedValue != "1=1") { e.AddAndParams("SERVERPARTSHOP_ID", SERVERPARTSHOP_ID.SelectedValue); } if (!string.IsNullOrEmpty(StatisticsDay.Text.Trim())) { e.SetOtherUserCustomWhereSqlString += (e.SetOtherUserCustomWhereSqlString == "" ? "" : " AND ") + "SELLMASTER_DATE >= TO_DATE('" + StatisticsDay.Text.Trim() + "','YYYY/MM/DD') AND SELLMASTER_DATE < TO_DATE('" + StatisticsDay.Text.Trim() + "','YYYY/MM/DD') + 1"; } //排序 if (LayoutButton_OrderBy.Visible) { e.AddOrderByParams(GridViewOrderBy1); } else { e.AddOrderByParams("SELLMASTER_DATE", false); } } else { e.AddAndParams("1", 2); } } #endregion #region 方法 -> 行绑定事件 decimal _SELLMASTER_COUNT = 0, _SELLMASTER_AMOUNT = 0, _SELLMASTER_OFFPRICE = 0, _CASHPAY = 0, _MOBILEPAY = 0, _COUPONPAY = 0, _INTERNALPAY = 0, _MEMBERPAY = 0, _BANKPAY = 0; protected void GridViewEx1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { _SELLMASTER_COUNT = 0; _SELLMASTER_AMOUNT = 0; _SELLMASTER_OFFPRICE = 0; _CASHPAY = 0; _MOBILEPAY = 0; _COUPONPAY = 0; _INTERNALPAY = 0; _MEMBERPAY = 0; _BANKPAY = 0; } else if (e.Row.RowType == DataControlRowType.DataRow) { string _SELLMASTER_CODE = GridViewEx1.DataKeys[e.Row.RowIndex]["SELLMASTER_CODE"].ToString(); e.Row.Attributes["onclick"] = GridViewEx1.GetOpenPopDialogClientScript("SaleDataDetailList.aspx?SELLMASTER_CODE=" + _SELLMASTER_CODE.ToEncrypt() + "&SERVERPART_NAME=" + SERVERPART_ID.SelectedItem.Text.ToEncrypt() + "&SHOPNAME=" + e.Row.Cells[e.Row.Cells.Count - 2].Text.ToEncrypt()); for (int CellCount = 6; CellCount < e.Row.Cells.Count - 3; CellCount++) { if (e.Row.Cells[CellCount].Text == "0" || e.Row.Cells[CellCount].Text == "0.00") { e.Row.Cells[CellCount].Text = ""; } } _SELLMASTER_COUNT += e.Row.Cells[4].Text.TryParseToDecimal(); _SELLMASTER_AMOUNT += e.Row.Cells[5].Text.TryParseToDecimal(); _SELLMASTER_OFFPRICE += e.Row.Cells[6].Text.TryParseToDecimal(); _CASHPAY += e.Row.Cells[7].Text.TryParseToDecimal(); _MOBILEPAY += e.Row.Cells[8].Text.TryParseToDecimal(); _COUPONPAY += e.Row.Cells[9].Text.TryParseToDecimal(); _INTERNALPAY += e.Row.Cells[10].Text.TryParseToDecimal(); _MEMBERPAY += e.Row.Cells[11].Text.TryParseToDecimal(); _BANKPAY += e.Row.Cells[12].Text.TryParseToDecimal(); } else if (e.Row.RowType == DataControlRowType.Footer) { e.Row.Cells[0].Text = "合计"; e.Row.Cells[0].ColumnSpan = 3; e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Center; e.Row.Cells[1].Visible = false; e.Row.Cells[2].Visible = false; e.Row.Cells[4].Text = _SELLMASTER_COUNT.ToString(); e.Row.Cells[5].Text = _SELLMASTER_AMOUNT.ToString(); e.Row.Cells[6].Text = _SELLMASTER_OFFPRICE.ToString(); e.Row.Cells[7].Text = _CASHPAY.ToString(); e.Row.Cells[8].Text = _MOBILEPAY.ToString(); e.Row.Cells[9].Text = _COUPONPAY.ToString(); e.Row.Cells[10].Text = _INTERNALPAY.ToString(); e.Row.Cells[11].Text = _MEMBERPAY.ToString(); e.Row.Cells[12].Text = _BANKPAY.ToString(); } } #endregion #region 方法 -> 导出对应的Excel protected void ButtonExport_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(SERVERPART_ID.SelectedValue)) { Alert("请选择服务区!"); return; } string WhereSql = ""; string StrSql = @"SELECT A.SELLMASTER_DATE AS 销售时间,A.TICKET_CODE AS 小票编号, WM_CONCAT(B.COMMODITY_NAME || '[' || B.COMMODITY_BARCODE || ']' || '(' || B.SELLDETAILS_COUNT || '*' || B.SELLDETAILS_PRICE || ')') 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.SHOPNAME AS 门店名称,A.MACHINECODE AS 收银机号 FROM {0} A,HIGHWAY_SELLDATA.T_SELLDETAILS B WHERE A.SELLMASTER_CODE = B.SELLMASTER_CODE{1} GROUP BY A.SELLMASTER_DATE,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"; WhereSql += " AND SERVERPART_ID = " + SERVERPART_ID.SelectedValue; if (!string.IsNullOrEmpty(SERVERPARTSHOP_ID.SelectedValue) && SERVERPARTSHOP_ID.SelectedValue != "1=1") { WhereSql += " AND SERVERPARTSHOP_ID = " + SERVERPARTSHOP_ID.SelectedValue; } if (!string.IsNullOrEmpty(StatisticsDay.Text.Trim())) { WhereSql += " AND SELLMASTER_DATE >= TO_DATE('" + StatisticsDay.Text.Trim() + "','YYYY/MM/DD') AND SELLMASTER_DATE < TO_DATE('" + StatisticsDay.Text.Trim() + "','YYYY/MM/DD') + 1"; } _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 } }