2025-03-27 15:05:14 +08:00

387 lines
19 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
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.MapShow
{
public partial class CurRevenue : BasePage
{
protected string Serverpart_ID = System.Configuration.ConfigurationManager.AppSettings["UmiformCommodity"].ToString().Split('|')[0];
protected string _bReportTitle = System.Configuration.ConfigurationManager.AppSettings["bReportTiTle"].ToString();
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
Title = Label2.Text;
return;
}
GridViewEx1.SelectingWithInit<Business.SERVERPART>(ObjectDataSource1, GridPageEx1);
Business.CommonHelper.BindReportHeader(Label2, _bReportTitle, "", PassportInfo.CityAuthority, Transaction);
Title = Label2.Text;
//InitWebControlsState();
//if (Request["SERVERPART_ID"] != null)
//{
// SERVERPART_ID.SelectedValue = Request["SERVERPART_ID"];
// SERVERPART_ID.Enabled = false;
// ButtonSearch.Visible = false;
// ButtonStatistics_Click(ButtonStatistics, null);
//}
}
#region
private void InitWebControlsState()
{
//ListItemEx _ListItemEx = null;
//SERVERPART_ID.Clear();
//SERVERPART_ID.Items.Add(new Web.UI.WebControls.ListItemEx() { Text = "全部", Value = "1=1" });
//List<Business.SERVERPART> _ListSERVERPART =
// (new Business.SERVERPART(this.Transaction)).GetPassportServerPart(this.PassportInfo.CityAuthority);
//foreach (Business.SERVERPART _s in _ListSERVERPART)
//{
// if (_s.SERVERPART_NAME.Contains("区域中心"))
// continue;
// _ListItemEx = new ListItemEx();
// _ListItemEx.Text = _s.SERVERPART_NAME;
// _ListItemEx.Value = _s.SERVERPART_ID_Encrypt;
// SERVERPART_ID.Items.Add(_ListItemEx);
//}
//SERVERPART_ID.SelectedIndex = 1;
}
#endregion
#region ->
protected void ButtonSearch_CallBackClick(object sender, ClientSetEventArgs e)
{
//设置UI变化
//if (SERVERPART_ID.SelectedValue != "1=1")
//{
// e.SetVisible(GridViewEx1, true);
// //e.SetVisible(GridPageEx1, true);
// e.SetVisible(GridViewEx2, false);
// //e.SetVisible(GridPageEx2, false);
// GridViewEx1.SelectingWithInit<Business.SERVERPART>(ObjectDataSource1, GridPageEx1);
// e.SetValue(GridViewEx1);
// e.ExcuteClientScript("setData('" + LblText.Text + "')");
//}
//else
//{
// e.SetVisible(GridViewEx1, false);
// //e.SetVisible(GridPageEx1, false);
// e.SetVisible(GridViewEx2, true);
// //e.SetVisible(GridPageEx2, true);
// GridViewEx2.SelectingWithInit<Business.SERVERPART>(ObjectDataSource2, GridPageEx2);
// e.SetValue(GridViewEx2);
// e.ExcuteClientScript("setData('" + LblText.Text + "')");
//}
}
protected void ButtonStatistics_Click(object sender, EventArgs e)
{
//绑定数据
//if (SERVERPART_ID.SelectedValue != "1=1")
//{
// GridViewEx1.Visible = true;
// //GridPageEx1.Visible = true;
// GridViewEx2.Visible = false;
// //GridPageEx2.Visible = false;
// GridViewEx1.SelectingWithInit<Business.SERVERPART>(ObjectDataSource1, GridPageEx1);
// Label1.Text = SERVERPART_ID.SelectedItem.Text + "营收实时汇总表";
//}
//else
//{
// GridViewEx1.Visible = false;
// //GridPageEx1.Visible = false;
// GridViewEx2.Visible = true;
// //GridPageEx2.Visible = true;
// GridViewEx2.SelectingWithInit<Business.SERVERPART>(ObjectDataSource2, GridPageEx2);
// Label1.Text = "浙江交通投资集团实业发展有限公司营收实时汇总表";
//}
}
#endregion
#region ->
protected void GridViewEx1_RowDataBound(object sender, GridViewRowEventArgs e)
{
#region -
//if (e.Row.RowType == DataControlRowType.Header)
//{
// e.Row.Cells[0].ColumnSpan = 2;
// e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Center;
// e.Row.Cells[0].Font.Bold = true;
// string TmpTd = "服务区信息</td><td colspan='3'style='FONT-WEIGHT:bold;border:solid #c0c0c0 1px;width:25%;' align='Center'>东(南)区</td>" +
// "<td colspan='3'style='FONT-WEIGHT:bold;border:solid #c0c0c0 1px;width:25%;' align='Center'>西(北)区</td>" +
// "<td colspan='4'style='FONT-WEIGHT:bold;border:solid #c0c0c0 1px;width:35%;' align='Center'>合计</td></tr>";
// TmpTd += "<tr class='item' style='background-color:#F0F0F0;' align='Center'>" +
// "<td nowrap='nowrap' style='border:solid #c0c0c0 1px;'>序号</td>" +
// "<td nowrap='nowrap' style='border:solid #c0c0c0 1px;'>服务区</td>";
// TmpTd += //"<td nowrap='nowrap' style='border:solid #c0c0c0 1px;'>收银状态</td>" +
// "<td nowrap='nowrap' style='border:solid #c0c0c0 1px;'>客单数量</td>" +
// "<td nowrap='nowrap' style='border:solid #c0c0c0 1px;'>客单均价</td>" +
// "<td nowrap='nowrap' style='border:solid #c0c0c0 1px;'>今日营收</td>";
// TmpTd += //"<td nowrap='nowrap' style='border:solid #c0c0c0 1px;'>收银状态</td>" +
// "<td nowrap='nowrap' style='border:solid #c0c0c0 1px;'>客单数量</td>" +
// "<td nowrap='nowrap' style='border:solid #c0c0c0 1px;'>客单均价</td>" +
// "<td nowrap='nowrap' style='border:solid #c0c0c0 1px;'>今日营收</td>";
// TmpTd += "<td nowrap='nowrap' style='border:solid #c0c0c0 1px;'>收银状态</td>" +
// "<td nowrap='nowrap' style='border:solid #c0c0c0 1px;'>客单数量</td>" +
// "<td nowrap='nowrap' style='border:solid #c0c0c0 1px;'>客均单价</td>" +
// "<td nowrap='nowrap' style='border:solid #c0c0c0 1px;'>今日营收</td>";
// e.Row.Cells[0].Text = TmpTd;
// e.Row.Cells[1].Visible = false;
// e.Row.Cells[2].Visible = false;
// e.Row.Cells[3].Visible = false;
// e.Row.Cells[4].Visible = false;
// e.Row.Cells[5].Visible = false;
// e.Row.Cells[6].Visible = false;
// e.Row.Cells[7].Visible = false;
// e.Row.Cells[8].Visible = false;
// e.Row.Cells[9].Visible = false;
// e.Row.Cells[10].Visible = false;
// e.Row.Cells[11].Visible = false;
// e.Row.Cells[12].Visible = false;
// e.Row.Cells[13].Visible = false;
//}
#endregion
if (e.Row.RowType == DataControlRowType.DataRow)
{
string Date_A = null;
string Date_B = null;
Business.COMMODITY _COMMODITY = new Business.COMMODITY(this.Transaction);
//服务区内码
string _SERVERPART_ID = GridViewEx1.DataKeys[e.Row.RowIndex].Values["SERVERPART_ID"].ToString();
if (!string.IsNullOrEmpty(GridViewEx1.DataKeys[e.Row.RowIndex].Values["CONNECT_DATE_A"].ToString()))
{
Date_A = GridViewEx1.DataKeys[e.Row.RowIndex].Values["CONNECT_DATE_A"].ToString();
}
else
{
Date_A = DateTime.Now.AddDays(-1).ToString();
}
if (!string.IsNullOrEmpty(GridViewEx1.DataKeys[e.Row.RowIndex].Values["CONNECT_DATE_B"].ToString()))
{
Date_B = GridViewEx1.DataKeys[e.Row.RowIndex].Values["CONNECT_DATE_B"].ToString();
}
else
{
Date_B = DateTime.Now.AddDays(-1).ToString();
}
string CommCountSqlString = @"select count(1) from HIGHWAY_STORAGE.T_COMMODITY where EXISTS (
SELECT 1 FROM HIGHWAY_STORAGE.T_SERVERPARTSHOP WHERE SERVERPART_ID = " + _SERVERPART_ID +
" AND SHOPTRADE LIKE '%' || BUSINESSTYPE || '%') AND SERVERPART_ID IN (" + Serverpart_ID + "," +
_SERVERPART_ID + ") AND COMMODITY_STATE = 1 AND BUSINESSTYPE IS NOT NULL";
//状态
try
{
#region
//回传时间
System.TimeSpan _TimeSpan_Back_A = System.DateTime.Now - DateTime.Parse(Date_A);
System.TimeSpan _TimeSpan_Back_B = System.DateTime.Now - DateTime.Parse(Date_B);
if (_TimeSpan_Back_A.TotalMinutes > 10)
{
//5分钟无反馈数据 找不到日结 网络断开中。。橙色
//5分钟无反馈数据 具有日结,已经结账下班 灰色
//查询日结
e.Row.Cells[2].Text = "网络未连接";
e.Row.Cells[2].ForeColor = System.Drawing.Color.MediumVioletRed;
try
{
string EndAccountSql =
"select count(*) from HIGHWAY_SELLDATA.T_ENDACCOUNT where SERVERPART_ID = '" + _SERVERPART_ID +
"' AND TO_DATE('" + Date_A + "','YYYY/MM/DD HH24:MI:SS') - ENDACCOUNT_DATE BETWEEN 0 AND 1/24";
if (int.Parse(_COMMODITY.ExecuteDataTable(EndAccountSql).Rows[0][0].ToString()) > 0)
{
e.Row.Cells[2].Text = "已经结账下班";
e.Row.Cells[2].ForeColor = System.Drawing.Color.DimGray;
}
}
catch
{
e.Row.Cells[2].Text = "网络未连接";
e.Row.Cells[2].ForeColor = System.Drawing.Color.MediumVioletRed;
}
}
else
{
//5分钟之内无客单 等待上班中。。绿色
//5分钟之内有客单 收银状态正常 蓝色
try
{
//if (e.Row.Cells[3].Text == "0")
//{
// e.Row.Cells[2].Text = "等待上班中";
// e.Row.Cells[2].ForeColor = System.Drawing.Color.ForestGreen;
//}
//else
//{
//检测到客单
e.Row.Cells[2].Text = "收银状态正常";
e.Row.Cells[2].ForeColor = System.Drawing.Color.DeepSkyBlue;
//}
}
catch
{
e.Row.Cells[2].Text = "收银状态正常";
e.Row.Cells[2].ForeColor = System.Drawing.Color.DeepSkyBlue;
}
}
if (_TimeSpan_Back_B.TotalMinutes > 10)
{
//5分钟无反馈数据 找不到日结 网络断开中。。橙色
//5分钟无反馈数据 具有日结,已经结账下班 灰色
//查询日结
e.Row.Cells[6].Text = "网络未连接";
e.Row.Cells[6].ForeColor = System.Drawing.Color.MediumVioletRed;
try
{
string EndAccountSql =
"select count(*) from HIGHWAY_SELLDATA.T_ENDACCOUNT where SERVERPART_ID = '" + _SERVERPART_ID +
"' AND TO_DATE('" + Date_B + "','YYYY/MM/DD HH24:MI:SS') - ENDACCOUNT_DATE BETWEEN 0 AND 1/24";
if (int.Parse(_COMMODITY.ExecuteDataTable(EndAccountSql).Rows[0][0].ToString()) > 0)
{
e.Row.Cells[6].Text = "已经结账下班";
e.Row.Cells[6].ForeColor = System.Drawing.Color.DimGray;
}
}
catch
{
e.Row.Cells[6].Text = "网络未连接";
e.Row.Cells[6].ForeColor = System.Drawing.Color.MediumVioletRed;
}
}
else
{
//5分钟之内无客单 等待上班中。。绿色
//5分钟之内有客单 收银状态正常 蓝色
try
{
//if (e.Row.Cells[7].Text == "0")
//{
// e.Row.Cells[6].Text = "等待上班中";
// e.Row.Cells[6].ForeColor = System.Drawing.Color.ForestGreen;
//}
//else
//{
//检测到客单
e.Row.Cells[6].Text = "收银状态正常";
e.Row.Cells[6].ForeColor = System.Drawing.Color.DeepSkyBlue;
//}
}
catch
{
e.Row.Cells[6].Text = "收银状态正常";
e.Row.Cells[6].ForeColor = System.Drawing.Color.DeepSkyBlue;
}
}
//当前时间与最后订单
#endregion
}
catch
{
e.Row.Cells[2].Text = "网络未连接";
e.Row.Cells[2].ForeColor = System.Drawing.Color.MediumVioletRed;
e.Row.Cells[6].Text = "网络未连接";
e.Row.Cells[6].ForeColor = System.Drawing.Color.MediumVioletRed;
//e.Row.Cells[e.Row.Cells.Count - 4].Text = "网络未连接";
//e.Row.Cells[e.Row.Cells.Count - 4].ForeColor = System.Drawing.Color.MediumVioletRed;
}
if (e.Row.Cells[1].Text != "合计")
{
e.Row.Attributes["onclick"] = GridViewEx1.GetOpenPopDialogClientScript(
"CurServerPartRevenue.aspx?SERVERPART_ID=" + _SERVERPART_ID.ToEncrypt(), 1000, 400);
switch (e.Row.Cells[2].Text)
{
case "收银状态正常":
e.Row.Cells[e.Row.Cells.Count - 4].Text = "收银状态正常";
e.Row.Cells[e.Row.Cells.Count - 4].ForeColor = System.Drawing.Color.DeepSkyBlue;
break;
case "已经结账下班":
switch (e.Row.Cells[6].Text)
{
case "收银状态正常":
e.Row.Cells[e.Row.Cells.Count - 4].Text = "收银状态正常";
e.Row.Cells[e.Row.Cells.Count - 4].ForeColor = System.Drawing.Color.DeepSkyBlue;
break;
default:
e.Row.Cells[e.Row.Cells.Count - 4].Text = "已经结账下班";
e.Row.Cells[e.Row.Cells.Count - 4].ForeColor = System.Drawing.Color.DimGray;
break;
}
break;
default:
switch (e.Row.Cells[6].Text)
{
case "收银状态正常":
e.Row.Cells[e.Row.Cells.Count - 4].Text = "收银状态正常";
e.Row.Cells[e.Row.Cells.Count - 4].ForeColor = System.Drawing.Color.DeepSkyBlue;
break;
case "已经结账下班":
e.Row.Cells[e.Row.Cells.Count - 4].Text = "已经结账下班";
e.Row.Cells[e.Row.Cells.Count - 4].ForeColor = System.Drawing.Color.DimGray;
break;
default:
e.Row.Cells[e.Row.Cells.Count - 4].Text = "网络未连接";
e.Row.Cells[e.Row.Cells.Count - 4].ForeColor = System.Drawing.Color.MediumVioletRed;
break;
}
break;
}
}
else
{
e.Row.Cells[2].Text = "";
e.Row.Cells[6].Text = "";
LblText.Text = "今日营收合计:" + e.Row.Cells[e.Row.Cells.Count - 1].Text;
LblText.Text += " 统计时间:" + DateTime.Now.Date.ToString() + "至" + DateTime.Now.ToString();
}
}
}
#endregion
#region ->
protected void GridPageEx1_CallBackPageChanged(object sender, ClientSetEventArgs e)
{
GridViewEx1.Pagging<Business.SERVERPART>(ObjectDataSource1, GridPageEx1);
//设置UI变化
e.SetValue(GridViewEx1);
}
#endregion
#region ->
protected void GridViewEx1_SelectMethodParameters(object sender, SelectMethodParametersArgs e)
{
//且搜索条件
e.AddAndParams("1", 1);
//搜索选项的搜索条件过滤
string SERVERPART_IDS = new Business.SERVERPART(Transaction).GetPassportServerPartID(PassportInfo.CityAuthority);
e.SetOtherUserCustomWhereSqlString = " SERVERPART_ID IN (" + SERVERPART_IDS + ")";
//if (SERVERPART_ID.SelectedValue != "1=1")
//{
// e.AddAndParams("SERVERPART_ID", SERVERPART_ID.SelectedValue.ToDecrypt());
//}
//且搜索条件
//e.AddAndParams(字段名, 值);
//或搜索条件
//e.AddOrParams(字段名, 值);
//排序
e.AddOrderByParams("SERVERPART_INDEX,SERVERPARTCODE", false);
}
#endregion
}
}