//设置日期按钮状态 protected void SetSelectDate() { string dates = _selectdate.ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = 0; i <= 32; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddDays(i - 1) <= DateTime.Now && (i <= dte.Day || i == 32)) { btn.Visible = true; if (btn.Text == _selectdate.ToString("dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } }
//设置日期按钮状态 protected void SetSelectDate() { string dates = _selectdateb.ToString("yyyy-01-01"); DateTime dtb = Convert.ToDateTime(dates); for (int i = 0; i <= 13; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddMonths(i - 1) <= DateTime.Now) { btn.Text = dtb.AddMonths(i - 1).ToString("yyyy-MM"); btn.Visible = true; DateTime dttb = Convert.ToDateTime(btn.Text); DateTime dtte = dttb.AddMonths(1) > DateTime.Now ? DateTime.Now : dttb.AddMonths(1).AddDays(-1); if (dttb.ToString("yyyy-MM-dd") == _selectdateb.ToString("yyyy-MM-dd") && dtte.ToString("yyyy-MM-dd") == _selectdatee.ToString("yyyy-MM-dd")) { btn.CssClass = "buttonblo"; btn.Enabled = false; } else { btn.CssClass = "buttonbl"; btn.Enabled = true; } } else { btn.Visible = false; } } } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = -1; i <= 31; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (i <= dte.Day && dtb.AddDays(i) <= DateTime.Now) { btn.Text = dtb.AddDays(i).ToString("MM-dd"); btn.Visible = true; if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("MM-dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToShortDateString() + " "; string sqlwhere = " where 1=1 "; sqlwhere += @" and F_Date='" + searchdateB.ToShortDateString() + "'"; if (DropDownListArea1.SelectedIndex > 0) { sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } if (DropDownListArea2.SelectedIndex > 0) { sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[1] + ""; } string sql = ""; sql = @"with RVcte(F_Level,F_VocationType, F_VocationNum) as ( SELECT F_Level,F_VocationType, Sum(F_VocationNum) as F_VocationNum FROM T_RoleLevel " + sqlwhere + @" group by F_Level,F_VocationType ) select distinct(a.F_Level) as 等级, (select isnull(Sum(F_VocationNum),0) from RVcte where F_Level=a.F_Level and F_VocationType/6=6) as 虎贲, (select isnull(Sum(F_VocationNum),0) from RVcte where F_Level=a.F_Level and F_VocationType/6=2) as 浪人, (select isnull(Sum(F_VocationNum),0) from RVcte where F_Level=a.F_Level and F_VocationType/6=3) as 龙胆, (select isnull(Sum(F_VocationNum),0) from RVcte where F_Level=a.F_Level and F_VocationType/6=4) as 巧工, (select isnull(Sum(F_VocationNum),0) from RVcte where F_Level=a.F_Level and F_VocationType/6=7) as 气功师, (select isnull(Sum(F_VocationNum),0) from RVcte where F_Level=a.F_Level and F_VocationType/6=0) as 花灵, (select isnull(Sum(F_VocationNum),0) from RVcte where F_Level=a.F_Level and F_VocationType/6=1) as 天师, (select isnull(Sum(F_VocationNum),0) from RVcte where F_Level=a.F_Level and F_VocationType/6=5) as 行者 FROM RVcte a order by a.F_Level asc"; try { ds = DBHelperDigGameDB.Query(sql); DataView myView = ds.Tables[0].DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = "出错:" + ex.Message; //lblerro.Text = sql; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { if (!Common.Validate.IsDateTime(tboxTimeB.Text) || !Common.Validate.IsDateTime(tboxTimeE.Text)) { Common.MsgBox.Show(this, App_GlobalResources.Language.Tip_TimeError); return; } //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = 0; i <= 32; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddDays(i - 1) <= DateTime.Now && (i <= dte.Day || i == 32)) { btn.Visible = true; if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToString(SmallDateTimeFormat) + " "; string sqlwhere = " where 1=1 "; sqlwhere += @" and F_Date='" + searchdateB.ToString(SmallDateTimeFormat) + "'"; if (DropDownListArea1.SelectedIndex > 0) { sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } if (DropDownListArea2.SelectedIndex > 0) { sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[1] + ""; } string itemid = "1"; if (Request["itemid"] != null) { itemid = Request["itemid"].ToString(); } string sql = ""; sql = @"SELECT * FROM T_QuestKey WITH(NOLOCK) where F_ItemID=" + itemid + " order by F_ItemID "; try { ds = DBHelperGSSDB.Query(sql); DataView myView = ds.Tables[0].DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblTitle.Text = myView.Table.Rows[0]["F_ItemTitle"].ToString(); lblSum.Text = GetAnswerSum(myView); lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); if (ControlChart1.Visible == true) { ControlChart1.SetChart(GridView1, LabelTitle.Text.Replace(">>", " - ") + " " + lblTitle.Text + " " + LabelTime.Text, ControlChartSelect1.State, false, 0, 1); } } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = App_GlobalResources.Language.LblError + ex.Message; //lblerro.Text = sql; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { if (!Common.Validate.IsDateTime(tboxTimeB.Text) || !Common.Validate.IsDateTime(tboxTimeE.Text)) { Common.MsgBox.Show(this, App_GlobalResources.Language.Tip_TimeError); return; } //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = 0; i <= 32; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddDays(i - 1) <= DateTime.Now && (i <= dte.Day || i == 32)) { btn.Visible = true; if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToString(SmallDateTimeFormat) + " "; string sqlwhere = ""; //sqlwhere += @" and F_Date='" + searchdateB.ToString(SmallDateTimeFormat) + "'"; if (DropDownListArea1.SelectedIndex > 0) { sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[0] + ""; } if (DropDownListArea2.SelectedIndex > 0) { sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[0] + ""; } string sql = ""; //sql = @"SELECT top 100 ROW_NUMBER() OVER(order by sum(F_IPLoginNum) desc) AS rownum, SUM(F_IPLoginNum) as F_IPLoginNum, F_AreaName from T_UserLoginArea where 1=1 " + sqlwhere + " group by F_AreaName"; sql = @"SELECT F_UserID,F_UserName,F_LoginTime,F_ExitTime,F_LoginIP,F_Device_id FROM [LKSV_1_GameLogDB_0].GameLogDB.[dbo].[T_UserEnterExitLog" + searchdateB.ToString("yyyyMMdd") + "] WHERE 1=1" + sqlwhere + "ORDER BY F_UserID"; try { ds = DBHelperDigGameDB.Query(sql); DataView myView = ds.Tables[0].DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; //lblSum.Text = GetSum(myView); } GridView1.DataSource = myView; GridView1.DataBind(); if (ControlChart1.Visible == true) { ControlChart1.SetChart(GridView1, LabelTitle.Text.Replace(">>", " - ") + " " + LabelArea.Text + " " + LabelTime.Text, ControlChartSelect1.State, false, 1, 1); } } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = App_GlobalResources.Language.LblError + ex.Message; //lblerro.Text = sql; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { if (!Common.Validate.IsDateTime(tboxTimeB.Text) || !Common.Validate.IsDateTime(tboxTimeE.Text)) { Common.MsgBox.Show(this, App_GlobalResources.Language.Tip_TimeError); return; } //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = 0; i <= 32; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddDays(i - 1) <= DateTime.Now && (i <= dte.Day || i == 32)) { btn.Visible = true; if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToString(SmallDateTimeFormat) + " "; string sqlwhere = " where 1=1 "; sqlwhere += @" and F_Date='" + searchdateB.ToString(SmallDateTimeFormat) + "'"; if (DropDownListArea1.SelectedIndex > 0) { sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } if (DropDownListArea2.SelectedIndex > 0) { sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[1] + ""; } string sql = ""; sql = @" with RVcte(F_TimePara, F_Pro, F_Num) as ( SELECT F_TimePara,F_Pro,Sum(F_Num) as F_Num FROM T_RoleLoseTimeALL " + sqlwhere + @" group by F_TimePara,F_Pro ) select distinct(a.F_TimePara) as '" + App_GlobalResources.Language.LblTime + @"',CAST(replace(replace(replace(a.F_TimePara,'HOUR',''),'DAY',''),'MONTH','') AS INT) AS TimeInt, {0} FROM RVcte a order by TimeInt ASC "; try { string tmpl = "(select isnull(Sum(F_Num),0) from RVcte where F_TimePara=a.F_TimePara and F_Pro={0}) as '{1}'"; List <string> fields = new List <string>(); foreach (KeyValuePair <string, string> item in MapVacationType()) { fields.Add(string.Format(tmpl, item.Key, item.Value)); } sql = string.Format(sql, string.Join(",", fields)); ds = DBHelperDigGameDB.Query(sql); DataTable dtNew = ds.Tables[0].Clone(); string[] times = { "HOUR", "DAY", "MONTH" }; foreach (string time in times) { DataRow[] drs = ds.Tables[0].Select("" + App_GlobalResources.Language.LblTime + " like '%" + time + "'", "TimeInt asc"); if (drs.Length > 0) { foreach (DataRow dr in drs) { DataRow drnew = dtNew.NewRow(); for (int i = 0; i < dtNew.Columns.Count; i++) { drnew[i] = dr[i].ToString().Replace("HOUR", App_GlobalResources.Language.LblUnit_Hour).Replace("DAY", App_GlobalResources.Language.LblUnit_Day).Replace("MONTH", App_GlobalResources.Language.LblUnit_Month); } string ti = drnew["TimeInt"].ToString(); string tp = drnew[App_GlobalResources.Language.LblTime].ToString().Replace(ti, ""); drnew[App_GlobalResources.Language.LblTime] = string.Format("{0}-{1} {2}", ti, Convert.ToInt32(ti) + 1, tp); dtNew.Rows.Add(drnew); } } } //结果集中忽略字段处理 GridView1.Columns.Clear(); columnValue = new List <long>(); columnValue.Add(0); GridView1.Columns.Add(new BoundField() { DataField = App_GlobalResources.Language.LblTime, HeaderText = App_GlobalResources.Language.LblTime }); foreach (KeyValuePair <string, string> item in MapVacationType()) { columnValue.Add(0); GridView1.Columns.Add(new BoundField() { DataField = item.Value, HeaderText = item.Value }); } GridView1.Columns.Add(new BoundField() { HeaderText = App_GlobalResources.Language.LblSum }); DataView myView = dtNew.DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); if (ControlChart1.Visible == true) { ControlChart1.SetChart(GridView1, LabelTitle.Text.Replace(">>", " - ") + " " + LabelArea.Text + " " + LabelTime.Text, ControlChartSelect1.State); } } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = App_GlobalResources.Language.LblError + ex.Message; lblinfo.Text = sql; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { if (!Common.Validate.IsDateTime(tboxTimeB.Text) || !Common.Validate.IsDateTime(tboxTimeE.Text)) { Common.MsgBox.Show(this, App_GlobalResources.Language.Tip_TimeError); return; } //if (Convert.ToDateTime(tboxTimeB.Text) > DateTime.Now.AddDays(-1)) //{ // tboxTimeB.Text = DateTime.Now.AddDays(-1).ToString(SmallDateTimeFormat) ; //} //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = 0; i <= 32; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddDays(i - 1) <= DateTime.Now && (i <= dte.Day || i == 32)) { btn.Visible = true; if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } if (DropDownListArea1.SelectedItem != null) { LabelArea.Text = DropDownListArea1.SelectedItem.Text; } if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now.AddDays(-1); DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToString(SmallDateTimeFormat) + " "; string sqlwhere = " where 1=1 "; if (tboxUID.Text.Trim().Length > 0) { sqlwhere += @" and UID =" + tboxUID.Text.Replace("'", "") + ""; } if (tboxCID.Text.Trim().Length > 0) { sqlwhere += @" and CID =" + tboxCID.Text.Replace("'", "") + ""; } if (tboxPARA_1.Text.Trim().Length > 0) { sqlwhere += @" and PARA_1 =" + tboxPARA_1.Text.Replace("'", "") + ""; } if (tboxPARA_2.Text.Trim().Length > 0) { sqlwhere += @" and PARA_2 =" + tboxPARA_2.Text.Replace("'", "") + ""; } if (DropDownListCType.SelectedIndex > 0) { sqlwhere += @" and OPID = " + DropDownListCType.SelectedValue + ""; } else if (tboxOPID.Text.Length > 0) { sqlwhere += @" and OPID = " + tboxOPID.Text.Replace("'", "") + ""; } if (tboxContent.Text.Trim().Length > 0) { string content = tboxContent.Text.Replace("'", ""); sqlwhere += @" and OP_BAK like ''%" + content + "%''"; } try { string bigzoneid = DropDownListArea1.SelectedValue.Split(',')[1]; string zoneid = DropDownListArea2.SelectedValue.Split(',')[1]; int pcount = 0; SqlParameter[] parameters = { new SqlParameter("@BigZoneID", SqlDbType.Int), new SqlParameter("@ZoneID", SqlDbType.Int), new SqlParameter("@DBType", SqlDbType.Int), new SqlParameter("@QueryTable", SqlDbType.NVarChar, 50), new SqlParameter("@QueryDate", SqlDbType.DateTime), new SqlParameter("@Query", SqlDbType.NVarChar, 100), new SqlParameter("@PageIndex", SqlDbType.Int), new SqlParameter("@PageSize", SqlDbType.Int), new SqlParameter("@PageType", SqlDbType.Int), new SqlParameter("@PCount", SqlDbType.Int), }; parameters[0].Value = bigzoneid; parameters[1].Value = zoneid; parameters[2].Value = 0; parameters[3].Value = "_other_log"; parameters[4].Value = searchdateB.ToString(SmallDateTimeFormat); parameters[5].Value = sqlwhere; parameters[6].Value = lblPageIndex.Text; parameters[7].Value = GridView1.PageSize; parameters[8].Value = lblPageType.Text;//0普通分页 1连续ID分页 parameters[9].Direction = ParameterDirection.Output; ds = DBHelperDigGameDB.RunProcedure("_Query_GSLOGDB", parameters, "ds", 180); DataView myView = ds.Tables[0].DefaultView; pcount = (int)parameters[9].Value; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); lblCount.Text = pcount.ToString(); lblPageCount.Text = (pcount % GridView1.PageSize == 0 ? pcount / GridView1.PageSize : pcount / GridView1.PageSize + 1).ToString(); } else { lblerro.Visible = false; lblPageCount.Text = (pcount % GridView1.PageSize == 0 ? pcount / GridView1.PageSize : pcount / GridView1.PageSize + 1).ToString(); lblCount.Text = pcount.ToString(); lbtnF.Enabled = true; lbtnP.Enabled = true; lbtnN.Enabled = true; lbtnE.Enabled = true; if (lblPageIndex.Text == "1") { lbtnF.Enabled = false; lbtnP.Enabled = false; } else if (lblPageIndex.Text == lblPageCount.Text) { lbtnN.Enabled = false; lbtnE.Enabled = false; } tboxPageIndex.Text = lblPageIndex.Text; } GridView1.DataSource = myView; GridView1.DataBind(); } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = App_GlobalResources.Language.LblError + ex.Message; lblinfo.Text = ex.Message; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { if (!Common.Validate.IsDateTime(tboxTimeB.Text) || !Common.Validate.IsDateTime(tboxTimeE.Text)) { Common.MsgBox.Show(this, App_GlobalResources.Language.Tip_TimeError); return; } //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = 0; i <= 32; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddDays(i - 1) <= DateTime.Now && (i <= dte.Day || i == 32)) { btn.Visible = true; if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToString(SmallDateTimeFormat) + " - " + searchdateE.ToString(SmallDateTimeFormat); string sqlwhere = ""; sqlwhere += @" and F_Date>='" + searchdateB.ToString(SmallDateTimeFormat) + "'"; sqlwhere += @" and F_Date<='" + searchdateE.ToString(SmallDateTimeFormat) + "'"; if (DropDownListArea1.SelectedIndex > 0) { sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } if (DropDownListArea2.SelectedIndex > 0) { sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[1] + ""; } string sql = ""; sql = @"SELECT ROW_NUMBER() OVER(order by {0}) AS rownum,* FROM (SELECT top 1000 F_TaskID, max(F_TaskName) as F_TaskName, sum(F_NumAccept) as F_NumAccept, sum(F_NumFinish) as F_NumFinish,(case sum(F_NumAccept) when 0 then 1 else cast( sum(F_NumFinish) as numeric(18, 2))/cast(sum(F_NumAccept) as numeric(18, 2)) end )as F_AC FROM T_TaskAcceptFinish where 1=1 " + sqlwhere + " group by F_TaskID ) a"; try { string sortField = ViewState["SortOrder"] == null ? string.Empty : ViewState["SortOrder"].ToString() + " " + ViewState["OrderDire"].ToString(); if (!string.IsNullOrEmpty(sortField)) { sql = string.Format(sql, sortField); } else { sql = string.Format(sql, "F_AC ASC"); } ds = DBHelperDigGameDB.Query(sql); DataView myView = ds.Tables[0].DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = App_GlobalResources.Language.LblError + ex.Message; //lblerro.Text = sql; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { if (!Common.Validate.IsDateTime(tboxTimeB.Text) || !Common.Validate.IsDateTime(tboxTimeE.Text)) { Common.MsgBox.Show(this, App_GlobalResources.Language.Tip_TimeError); return; } //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = 0; i <= 32; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddDays(i - 1) <= DateTime.Now && (i <= dte.Day || i == 32)) { btn.Visible = true; if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = App_GlobalResources.Language.LblAllBigZone; //if (DropDownListArea2.SelectedIndex >= 0) //{ // LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; //} //if (DropDownListArea3.SelectedIndex > 0) //{ // LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; //} DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToString(SmallDateTimeFormat) + " "; try { string sql = ""; sql = @"SELECT F_CreateTime,SUM(F_PlayerNumOnline) as F_PlayerNumOnline from (SELECT replace(convert(nvarchar(2), F_CreateTime,108)+':'+convert(varchar(4),substring(convert(nvarchar(8), F_CreateTime,108),4,2)/15*15),':0',':00') as F_CreateTime,Max(F_PlayerNumOnline) as F_PlayerNumOnline from T_RoleOnLineFlow with(nolock) where F_Date='" + searchdateB.ToString("yyyy-MM-dd 00:00") + @"' AND F_GZONENAME IS NOT NULL group by replace(convert(nvarchar(2), F_CreateTime,108)+':'+convert(varchar(4),substring(convert(nvarchar(8), F_CreateTime,108),4,2)/15*15),':0',':00'),F_GNGSID,F_GGSID) TEMP GROUP BY F_CreateTime"; ds = DBHelperDigGameDB.Query(sql); if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { int temp = 0; maxNum = ""; for (int index = 0; index < ds.Tables[0].Rows.Count; index++) { if (Convert.ToInt32(ds.Tables[0].Rows[index]["F_PlayerNumOnline"]) > temp) { temp = Convert.ToInt32(ds.Tables[0].Rows[index]["F_PlayerNumOnline"]); maxNum = string.Format("{0}[{1}]", Convert.ToInt32(ds.Tables[0].Rows[index]["F_PlayerNumOnline"]), Convert.ToString(ds.Tables[0].Rows[index]["F_CreateTime"])); } } } DataView myView = ds.Tables[0].DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = App_GlobalResources.Language.LblError + ex.Message; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { if (!Common.Validate.IsDateTime(tboxTimeB.Text) || !Common.Validate.IsDateTime(tboxTimeE.Text)) { Common.MsgBox.Show(this, App_GlobalResources.Language.Tip_TimeError); return; } //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = 0; i <= 32; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddDays(i - 1) <= DateTime.Now && (i <= dte.Day || i == 32)) { btn.Visible = true; if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToString(SmallDateTimeFormat) + " - " + searchdateE.ToString(SmallDateTimeFormat); string sqlwhere = ""; sqlwhere += @" and F_Date>='" + searchdateB.ToString(SmallDateTimeFormat) + "'"; sqlwhere += @" and F_Date<='" + searchdateE.ToString(SmallDateTimeFormat) + "'"; if (DropDownListArea1.SelectedIndex > 0) { sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } if (DropDownListArea2.SelectedIndex > 0) { sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[1] + ""; } string sql = "SELECT F_PARA_1,SUM(isnull(F_LoginCount,0) as F_LoginCount,SUM(isnull(F_InRoleCount,0)) as F_InRoleCount,SUM(isnull(F_InCount,0)) as F_InCount FROM T_Other_GSLog_Total GROUP BY F_PARA_1 ORDER BY F_InRoleCount DESC WHERE 1=1 " + sqlwhere + ""; try { ds = DBHelperDigGameDB.Query(sql); DataView myView = ds.Tables[0].DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = App_GlobalResources.Language.LblError + ex.Message; //lblerro.Text = sql; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { if (!Common.Validate.IsDateTime(tboxTimeB.Text) || !Common.Validate.IsDateTime(tboxTimeE.Text)) { Common.MsgBox.Show(this, App_GlobalResources.Language.Tip_TimeError); return; } //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = 0; i <= 32; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddDays(i - 1) <= DateTime.Now && (i <= dte.Day || i == 32)) { btn.Visible = true; if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToString(SmallDateTimeFormat) + " "; string sqlwhere = " where 1=1 "; sqlwhere += @" and F_Date='" + searchdateB.ToString(SmallDateTimeFormat) + "'"; if (DropDownListArea1.SelectedIndex > 0) { sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } if (DropDownListArea2.SelectedIndex > 0) { sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[1] + ""; } string sql = ""; sql = @" with RVcte(F_TimePara, F_Pro, F_Num) as ( SELECT F_TimePara,F_Pro,Sum(F_Num) as F_Num FROM T_RoleLoseTimeALL " + sqlwhere + @" group by F_TimePara,F_Pro ) select distinct(a.F_TimePara) as aa ,F_TimePara as 时间, (select isnull(Sum(F_Num),0) from RVcte where F_TimePara=a.F_TimePara and F_Pro/6=6) as 虎贲, (select isnull(Sum(F_Num),0) from RVcte where F_TimePara=a.F_TimePara and F_Pro/6=2) as 浪人, (select isnull(Sum(F_Num),0) from RVcte where F_TimePara=a.F_TimePara and F_Pro/6=3) as 龙胆, (select isnull(Sum(F_Num),0) from RVcte where F_TimePara=a.F_TimePara and F_Pro/6=4) as 巧工, (select isnull(Sum(F_Num),0) from RVcte where F_TimePara=a.F_TimePara and F_Pro/6=7) as 气功师, (select isnull(Sum(F_Num),0) from RVcte where F_TimePara=a.F_TimePara and F_Pro/6=0) as 花灵, (select isnull(Sum(F_Num),0) from RVcte where F_TimePara=a.F_TimePara and F_Pro/6=1) as 天师, (select isnull(Sum(F_Num),0) from RVcte where F_TimePara=a.F_TimePara and F_Pro/6=5) as 行者 FROM RVcte a order by a.F_TimePara asc "; try { ds = DBHelperDigGameDB.Query(sql); DataView myView = ds.Tables[0].DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = App_GlobalResources.Language.LblError + ex.Message; lblinfo.Text = sql; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = -1; i <= 31; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (i <= dte.Day && dtb.AddDays(i) <= DateTime.Now) { btn.Text = dtb.AddDays(i).ToString("MM-dd"); btn.Visible = true; if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("MM-dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex >= 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToShortDateString() + " "; string sqlwhere = ""; sqlwhere += @" and F_Date='" + searchdateB.ToShortDateString() + "'"; if (DropDownListArea1.SelectedIndex >= 0) { sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } if (DropDownListArea2.SelectedIndex >= 0) { sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[1] + ""; } string sql = ""; sql = @"SELECT replace(convert(nvarchar(2), F_CreateTime,108)+':'+convert(varchar(4),substring(convert(nvarchar(8), F_CreateTime,108),4,2)/15*15),':0',':00') as F_CreateTime, F_GGSNAME, F_GNGSID, F_GNGSNAME, F_GZONEID, F_GZONENAME, F_PlayerNumOnline, F_MaxPlayerNumHistory, F_DateTimeMaxPlayerNum from T_RoleOnLineFlow where 1=1 " + sqlwhere + " order by F_CreateTime asc"; try { ds = DBHelperDigGameDB.Query(sql); List <string> lines = new List <string>(); DataTable dtt = new DataTable(); dtt.Columns.Add("F_Time", typeof(string)); foreach (DataRow dr in ds.Tables[0].Rows) { string line = dr["F_GNGSNAME"].ToString(); string time = dr["F_CreateTime"].ToString(); if (!lines.Contains(line) && !string.IsNullOrEmpty(line)) { lines.Add(line); } if (dtt.Select("F_Time='" + time + "'").Length == 0) { DataRow drt = dtt.NewRow(); drt["F_Time"] = time; dtt.Rows.Add(drt); } } while (GridView1.Columns.Count > 1) { GridView1.Columns.RemoveAt(1); } foreach (string linename in lines) { BoundField col = new BoundField(); col.HeaderText = linename; GridView1.Columns.Add(col); lblHistory.Text += GetHistoryOnlineInfo(linename); } BoundField coli = new BoundField(); coli.HeaderText = "总 计"; GridView1.Columns.Add(coli); DataView myView = dtt.DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); for (int i = 1; i < GridView1.Columns.Count; i++) { GridView1.FooterRow.Cells[i].Text = "0"; for (int y = 0; y < GridView1.Rows.Count; y++) { string max = GetMax(GridView1.FooterRow.Cells[i].Text, GridView1.Rows[y].Cells[i].Text); string now = GridView1.FooterRow.Cells[i].Text.Split(' ')[0]; if (Convert.ToInt32(max) > Convert.ToInt32(now)) { GridView1.FooterRow.Cells[i].Text = "" + max + " [" + GridView1.Rows[y].Cells[0].Text + "]"; } } } GridView1.HeaderRow.Cells[GridView1.Columns.Count - 1].Text = "总 计 <span class=tyellow>" + GridView1.FooterRow.Cells[GridView1.Columns.Count - 1].Text + "</span>"; } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = "出错:" + ex.Message; //lblerro.Text = sql; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { if (!Common.Validate.IsDateTime(tboxTimeB.Text) || !Common.Validate.IsDateTime(tboxTimeE.Text)) { Common.MsgBox.Show(this, App_GlobalResources.Language.Tip_TimeError); return; } //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-01-01"); DateTime dtb = Convert.ToDateTime(dates); for (int i = 1; i <= 12; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddMonths(i - 1) <= DateTime.Now) { btn.Text = dtb.AddMonths(i - 1).ToString("yyyy-MM"); btn.Visible = true; DateTime dttb = Convert.ToDateTime(btn.Text); DateTime dtte = dttb.AddMonths(1) > DateTime.Now ? DateTime.Now : dttb.AddMonths(1).AddDays(-1); if (dttb.ToString("yyyy-MM-dd") == tboxTimeB.Text && dtte.ToString("yyyy-MM-dd") == tboxTimeE.Text) { btn.CssClass = "buttonblo"; btn.Enabled = false; } else { btn.CssClass = "buttonbl"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToString(SmallDateTimeFormat) + " " + App_GlobalResources.Language.LblTo + " " + searchdateE.ToString(SmallDateTimeFormat); string sqlwhere = " where 1=1 "; sqlwhere += @" and F_Date>='" + searchdateB.ToString(SmallDateTimeFormat) + "' and F_Date<='" + searchdateE.ToString(SmallDateTimeFormat) + "' "; if (DropDownListArea1.SelectedIndex > 0) { sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } if (DropDownListArea2.SelectedIndex > 0) { sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[1] + ""; } string sql = ""; sql = @"SELECT Convert(varchar(10),F_Date,120) as F_Date,F_ChatType, Sum(F_Num) as F_Num FROM T_ChatTypeNum " + sqlwhere + @" group by F_Date,F_ChatType"; try { ds = DBHelperDigGameDB.Query(sql); List <string> lines = new List <string>(); DataTable dtt = new DataTable(); dtt.Columns.Add("F_Date", typeof(string)); foreach (DataRow dr in ds.Tables[0].Rows) { string line = dr["F_ChatType"].ToString().Trim(); string time = dr["F_Date"].ToString(); string lineName = GetChatTypeName(line); if (!lines.Contains(lineName) && !string.IsNullOrEmpty(lineName)) { lines.Add(lineName); } if (dtt.Select("F_Date='" + time + "'").Length == 0) { DataRow drt = dtt.NewRow(); drt["F_Date"] = time; dtt.Rows.Add(drt); } } while (GridView1.Columns.Count > 1) { GridView1.Columns.RemoveAt(1); } foreach (string linename in lines) { BoundField col = new BoundField(); col.HeaderText = linename; GridView1.Columns.Add(col); } BoundField coli = new BoundField(); coli.HeaderText = App_GlobalResources.Language.LblSum; GridView1.Columns.Add(coli); DataView myView = dtt.DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); if (ControlChart1.Visible == true) { ControlChart1.SetChart(GridView1, LabelTitle.Text.Replace(">>", " - ") + " " + LabelArea.Text + " " + LabelTime.Text, ControlChartSelect1.State, false, 0, 1); } } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = App_GlobalResources.Language.LblError + ex.Message; //lblerro.Text = sql; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { if (!Common.Validate.IsDateTime(tboxTimeB.Text) || !Common.Validate.IsDateTime(tboxTimeE.Text)) { Common.MsgBox.Show(this, App_GlobalResources.Language.Tip_TimeError); return; } //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = 0; i <= 32; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddDays(i - 1) <= DateTime.Now && (i <= dte.Day || i == 32)) { btn.Visible = true; if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToString(SmallDateTimeFormat) + " "; string sqlwhere = ""; sqlwhere += @" and F_Date='" + searchdateB.ToString(SmallDateTimeFormat) + "'"; if (DropDownListArea1.SelectedIndex > 0) { sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } if (DropDownListArea2.SelectedIndex > 0) { sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[1] + ""; } string sql = ""; sql = @"SELECT top 100 ROW_NUMBER() OVER(order by F_Num desc) AS rownum, F_UserID, F_RoleID, F_Content, F_Num from T_ChatRoleRepeatRank where 1=1 " + sqlwhere + " "; try { ds = DBHelperDigGameDB.Query(sql); DataView myView = ds.Tables[0].DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataKeyNames = new string[] { "F_RoleID" }; GridView1.DataBind(); } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = App_GlobalResources.Language.LblError + ex.Message; //lblerro.Text = sql; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = -1; i <= 31; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (i <= dte.Day && dtb.AddDays(i) <= DateTime.Now) { btn.Text = dtb.AddDays(i).ToString("MM-dd"); btn.Visible = true; if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("MM-dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToShortDateString() + " "; string sqlwhere = " where 1=1 "; sqlwhere += @" and F_Date='" + searchdateB.ToShortDateString() + "'"; if (DropDownListArea1.SelectedIndex > 0) { sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } if (DropDownListArea2.SelectedIndex > 0) { sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[1] + ""; } string sql = ""; sql = @"with RVcte(F_BigZone, F_ZoneID,F_Level, F_Experience, F_RoleID, F_Pro, F_RoleName, F_LevelUpTime, F_LastTime) as ( SELECT F_BigZone, F_ZoneID,F_Level, F_Experience, F_RoleID, F_Pro, F_RoleName, F_LevelUpTime, F_LastTime FROM T_RoleLevelRank " + sqlwhere + @" ) select * from (SELECT TOP 50 ROW_NUMBER() OVER(order by F_Experience desc) AS rownum,F_BigZone, F_ZoneID,F_Level, F_Experience, F_RoleID, F_Pro, F_RoleName, F_LevelUpTime, F_LastTime FROM RVcte) a left join (SELECT TOP 50 ROW_NUMBER() OVER(order by F_Experience desc) AS rownum0,F_BigZone as F_BigZone0,F_ZoneID as F_ZoneID0,F_Level as F_Level0, F_Experience as F_Experience0, F_RoleID as F_RoleID0, F_Pro as F_Pro0, F_RoleName as F_RoleName0, F_LevelUpTime as F_LevelUpTime0, F_LastTime as F_LastTime0 FROM RVcte where F_Pro/6=0) a0 on a.rownum=a0.rownum0 left join (SELECT TOP 50 ROW_NUMBER() OVER(order by F_Experience desc) AS rownum1,F_BigZone as F_BigZone1,F_ZoneID as F_ZoneID1,F_Level as F_Level1, F_Experience as F_Experience1, F_RoleID as F_RoleID1, F_Pro as F_Pro1, F_RoleName as F_RoleName1, F_LevelUpTime as F_LevelUpTime1, F_LastTime as F_LastTime1 FROM RVcte where F_Pro/6=1) a1 on a.rownum=a1.rownum1 left join (SELECT TOP 50 ROW_NUMBER() OVER(order by F_Experience desc) AS rownum2,F_BigZone as F_BigZone2,F_ZoneID as F_ZoneID2,F_Level as F_Level2, F_Experience as F_Experience2, F_RoleID as F_RoleID2, F_Pro as F_Pro2, F_RoleName as F_RoleName2, F_LevelUpTime as F_LevelUpTime2, F_LastTime as F_LastTime2 FROM RVcte where F_Pro/6=2) a2 on a.rownum=a2.rownum2 left join (SELECT TOP 50 ROW_NUMBER() OVER(order by F_Experience desc) AS rownum3,F_BigZone as F_BigZone3,F_ZoneID as F_ZoneID3,F_Level as F_Level3, F_Experience as F_Experience3, F_RoleID as F_RoleID3, F_Pro as F_Pro3, F_RoleName as F_RoleName3, F_LevelUpTime as F_LevelUpTime3, F_LastTime as F_LastTime3 FROM RVcte where F_Pro/6=3) a3 on a.rownum=a3.rownum3 left join (SELECT TOP 50 ROW_NUMBER() OVER(order by F_Experience desc) AS rownum4,F_BigZone as F_BigZone4,F_ZoneID as F_ZoneID4,F_Level as F_Level4, F_Experience as F_Experience4, F_RoleID as F_RoleID4, F_Pro as F_Pro4, F_RoleName as F_RoleName4, F_LevelUpTime as F_LevelUpTime4, F_LastTime as F_LastTime4 FROM RVcte where F_Pro/6=4) a4 on a.rownum=a4.rownum4 left join (SELECT TOP 50 ROW_NUMBER() OVER(order by F_Experience desc) AS rownum5,F_BigZone as F_BigZone5,F_ZoneID as F_ZoneID5,F_Level as F_Level5, F_Experience as F_Experience5, F_RoleID as F_RoleID5, F_Pro as F_Pro5, F_RoleName as F_RoleName5, F_LevelUpTime as F_LevelUpTime5, F_LastTime as F_LastTime5 FROM RVcte where F_Pro/6=5) a5 on a.rownum=a5.rownum5 left join (SELECT TOP 50 ROW_NUMBER() OVER(order by F_Experience desc) AS rownum6,F_BigZone as F_BigZone6,F_ZoneID as F_ZoneID6,F_Level as F_Level6, F_Experience as F_Experience6, F_RoleID as F_RoleID6, F_Pro as F_Pro6, F_RoleName as F_RoleName6, F_LevelUpTime as F_LevelUpTime6, F_LastTime as F_LastTime6 FROM RVcte where F_Pro/6=6) a6 on a.rownum=a6.rownum6 left join (SELECT TOP 50 ROW_NUMBER() OVER(order by F_Experience desc) AS rownum7,F_BigZone as F_BigZone7,F_ZoneID as F_ZoneID7,F_Level as F_Level7, F_Experience as F_Experience7, F_RoleID as F_RoleID7, F_Pro as F_Pro7, F_RoleName as F_RoleName7, F_LevelUpTime as F_LevelUpTime7, F_LastTime as F_LastTime7 FROM RVcte where F_Pro/6=7) a7 on a.rownum=a7.rownum7 left join (SELECT TOP 50 ROW_NUMBER() OVER(order by F_Experience desc,F_LastTime desc) AS rownum99,F_BigZone as F_BigZone99,F_ZoneID as F_ZoneID99,F_Level as F_Level99, F_Experience as F_Experience99, F_RoleID as F_RoleID99, F_Pro as F_Pro99, F_RoleName as F_RoleName99, F_LevelUpTime as F_LevelUpTime99, F_LastTime as F_LastTime99 FROM RVcte ) a99 on a.rownum=a99.rownum99 "; // select //(select isnull(Sum(F_VocationNum),0) from RVcte where F_Level=a.F_Level and F_VocationType/6=6) as 虎贲, //(select isnull(Sum(F_VocationNum),0) from RVcte where F_Level=a.F_Level and F_VocationType/6=2) as 浪人, //(select isnull(Sum(F_VocationNum),0) from RVcte where F_Level=a.F_Level and F_VocationType/6=3) as 龙胆, //(select isnull(Sum(F_VocationNum),0) from RVcte where F_Level=a.F_Level and F_VocationType/6=4) as 巧工, //(select isnull(Sum(F_VocationNum),0) from RVcte where F_Level=a.F_Level and F_VocationType/6=7) as 气功师, //(select isnull(Sum(F_VocationNum),0) from RVcte where F_Level=a.F_Level and F_VocationType/6=0) as 花灵, //(select isnull(Sum(F_VocationNum),0) from RVcte where F_Level=a.F_Level and F_VocationType/6=1) as 天师, //(select isnull(Sum(F_VocationNum),0) from RVcte where F_Level=a.F_Level and F_VocationType/6=5) as 行者 // FROM RVcte a order by a.F_Level asc try { ds = DBHelperDigGameDB.Query(sql); DataView myView = ds.Tables[0].DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = "出错:" + ex.Message; //lblerro.Text = sql; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { if (!Common.Validate.IsDateTime(tboxTimeB.Text) || !Common.Validate.IsDateTime(tboxTimeE.Text)) { Common.MsgBox.Show(this, App_GlobalResources.Language.Tip_TimeError); return; } //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = 0; i <= 32; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddDays(i - 1) <= DateTime.Now && (i <= dte.Day || i == 32)) { btn.Visible = true; if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; //if (DropDownListArea2.SelectedIndex >= 0) //{ // LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; //} //if (DropDownListArea3.SelectedIndex > 0) //{ // LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; //} DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToString(SmallDateTimeFormat) + " "; QueryZoneRole(searchdateB); return; string sqlwhere = ""; sqlwhere += @" and F_Date='" + searchdateB.ToString(SmallDateTimeFormat) + "'"; if (DropDownListArea1.SelectedIndex >= 0) { sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } //if (DropDownListArea2.SelectedIndex >= 0) //{ // sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[1] + ""; //} string sql = ""; sql = @"SELECT convert(nvarchar(2), F_CreateTime,108) as F_CreateTime, F_GZONEID , max(F_GZONENAME) as F_GZONENAME from T_RoleOnLineFlow with(nolock) where 1=1 " + sqlwhere + " group by convert(nvarchar(2), F_CreateTime,108),F_GZONEID order by F_CreateTime asc"; try { ds = DBHelperDigGameDB.Query(sql); lblDebug.Text = sql; List <string> lines = new List <string>(); DataTable dtt = new DataTable(); dtt.Columns.Add("F_Time", typeof(string)); dtt.Columns.Add("num", typeof(int)); foreach (DataRow dr in ds.Tables[0].Rows) { string line = dr["F_GZONENAME"].ToString(); string time = dr["F_CreateTime"].ToString(); if (!lines.Contains(line) && !string.IsNullOrEmpty(line)) { lines.Add(line); } if (dtt.Select("F_Time='" + time + "'").Length == 0) { DataRow drt = dtt.NewRow(); drt["F_Time"] = time; drt["num"] = 1; dtt.Rows.Add(drt); } } while (GridView1.Columns.Count > 1) { GridView1.Columns.RemoveAt(1); } foreach (string linename in lines) { BoundField col = new BoundField(); col.HeaderText = linename; GridView1.Columns.Add(col); lblHistory.Text += GetHistoryOnlineInfo(linename); } BoundField coli = new BoundField(); coli.HeaderText = App_GlobalResources.Language.LblSum; GridView1.Columns.Add(coli); DataView myView = dtt.DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); for (int i = 1; i < GridView1.Columns.Count; i++) { GridView1.FooterRow.Cells[i].Text = "0"; for (int y = 0; y < GridView1.Rows.Count; y++) { string max = GetMax(GridView1.FooterRow.Cells[i].Text, GridView1.Rows[y].Cells[i].Text); string now = GridView1.FooterRow.Cells[i].Text.Split(' ')[0]; if (Convert.ToInt32(max) > Convert.ToInt32(now)) { GridView1.FooterRow.Cells[i].Text = "" + max + " [" + GridView1.Rows[y].Cells[0].Text + "]"; } } } GridView1.HeaderRow.Cells[GridView1.Columns.Count - 1].Text = App_GlobalResources.Language.LblSum + " <span class=tyellow>" + GridView1.FooterRow.Cells[GridView1.Columns.Count - 1].Text + "</span>"; if (ControlChart1.Visible == true) { ControlChart1.SetChart(GridView1, LabelTitle.Text.Replace(">>", " - ") + " " + LabelArea.Text + " " + LabelTime.Text, ControlChartSelect1.State); } } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = App_GlobalResources.Language.LblError + ex.Message; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { if (!Common.Validate.IsDateTime(tboxTimeB.Text) || !Common.Validate.IsDateTime(tboxTimeE.Text)) { Common.MsgBox.Show(this, App_GlobalResources.Language.Tip_TimeError); return; } //if (Convert.ToDateTime(tboxTimeB.Text) > DateTime.Now.AddDays(-1)) //{ // tboxTimeB.Text = DateTime.Now.AddDays(-1).ToString(SmallDateTimeFormat) ; //} //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = 0; i <= 32; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddDays(i - 1) <= DateTime.Now && (i <= dte.Day || i == 32)) { btn.Visible = true; if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now.AddDays(-1); DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToString(SmallDateTimeFormat) + " "; string sqlwhere = string.Format(@"SELECT UID,CID,OP_BAK,count(1) AS RCOUNT FROM {0:yyyy_MM_dd}_chat_log ", searchdateB); sqlwhere += " where (para_1 =3 or para_1 =4)"; if (tboxUID.Text.Trim().Length > 0) { sqlwhere += @" and UID =" + tboxUID.Text.Replace("'", "") + ""; } if (tboxCID.Text.Trim().Length > 0) { sqlwhere += @" and CID =" + tboxCID.Text.Replace("'", "") + ""; } if (DropDownListCType.SelectedIndex > 0) { sqlwhere += @" and PARA_1 = " + DropDownListCType.SelectedValue + ""; } if (tboxContent.Text.Trim().Length > 0) { string content = tboxContent.Text.Replace("'", ""); content = TransEn(content); sqlwhere += @" and OP_BAK like ''%" + content + "%''"; } if (txtHourse.Text.Trim().Length > 0) { int hourse = 0; if (int.TryParse(txtHourse.Text, out hourse)) { sqlwhere += @" and hour(OP_TIME) =" + hourse; } } sqlwhere += @" group by CID,OP_BAK HAVING count(1)>3 order by count(1) DESC"; try { int pcount = 0; string bigzoneid = DropDownListArea1.SelectedValue.Split(',')[1]; string zoneid = DropDownListArea2.SelectedValue.Split(',')[1]; SqlParameter[] parameters = { new SqlParameter("@BigZoneID", SqlDbType.Int), new SqlParameter("@ZoneID", SqlDbType.Int), new SqlParameter("@DBType", SqlDbType.Int), new SqlParameter("@Query", SqlDbType.NVarChar), new SqlParameter("@PageIndex", SqlDbType.Int), new SqlParameter("@PageSize", SqlDbType.Int), new SqlParameter("@PCount", SqlDbType.Int), }; parameters[0].Value = bigzoneid; parameters[1].Value = zoneid; parameters[2].Value = 0;//gslog_db parameters[3].Value = sqlwhere.Replace("'", "''"); parameters[4].Value = 1; parameters[5].Value = 1000; parameters[6].Direction = ParameterDirection.Output; ds = DBHelperDigGameDB.RunProcedure("_Query_SQLCustom", parameters, "ds", 180); DataView myView = ds.Tables[0].DefaultView; pcount = (int)parameters[6].Value; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); lblCount.Text = pcount.ToString(); lblPageCount.Text = (pcount % GridView1.PageSize == 0 ? pcount / GridView1.PageSize : pcount / GridView1.PageSize + 1).ToString(); } else { lblerro.Visible = false; lblPageCount.Text = (pcount % GridView1.PageSize == 0 ? pcount / GridView1.PageSize : pcount / GridView1.PageSize + 1).ToString(); lblCount.Text = pcount.ToString(); lbtnF.Enabled = true; lbtnP.Enabled = true; lbtnN.Enabled = true; lbtnE.Enabled = true; if (lblPageIndex.Text == "1") { lbtnF.Enabled = false; lbtnP.Enabled = false; } else if (lblPageIndex.Text == lblPageCount.Text) { lbtnN.Enabled = false; lbtnE.Enabled = false; } tboxPageIndex.Text = lblPageIndex.Text; } GridView1.DataSource = myView; GridView1.DataBind(); } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = App_GlobalResources.Language.LblError + ex.Message; lblinfo.Text = ex.Message; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { if (!Common.Validate.IsDateTime(tboxTimeB.Text) || !Common.Validate.IsDateTime(tboxTimeE.Text)) { Common.MsgBox.Show(this, App_GlobalResources.Language.Tip_TimeError); return; } //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-01-01"); DateTime dtb = Convert.ToDateTime(dates); for (int i = 1; i <= 12; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddMonths(i - 1) <= DateTime.Now) { btn.Text = dtb.AddMonths(i - 1).ToString("yyyy-MM"); btn.Visible = true; DateTime dttb = Convert.ToDateTime(btn.Text); DateTime dtte = dttb.AddMonths(1) > DateTime.Now ? DateTime.Now : dttb.AddMonths(1).AddDays(-1); if (dttb.ToString("yyyy-MM-dd") == tboxTimeB.Text && dtte.ToString("yyyy-MM-dd") == tboxTimeE.Text) { btn.CssClass = "buttonblo"; btn.Enabled = false; } else { btn.CssClass = "buttonbl"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToString(SmallDateTimeFormat) + " " + App_GlobalResources.Language.LblTo + " " + searchdateE.ToString(SmallDateTimeFormat); string sqlwhere = ""; sqlwhere += @" and F_Date>='" + searchdateB.ToString(SmallDateTimeFormat) + "' and F_Date<='" + searchdateE.ToString(SmallDateTimeFormat) + "' "; if (DropDownListArea1.SelectedIndex > 0) { sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } if (DropDownListArea2.SelectedIndex > 0) { sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[1] + ""; } string sql = ""; sql = @"select distinct F_Date as '" + App_GlobalResources.Language.LblTime + @"', {0},(select SUM(F_VocationNum) from T_RoleVocationGrow where F_Date=a.F_Date ) as '" + App_GlobalResources.Language.LblSum + "' FROM T_RoleVocationGrow a WHERE 1=1"; sql += sqlwhere; sql += " order by a.F_Date desc"; try { string template = "(select isnull(Sum(F_VocationNum),0) from T_RoleVocationGrow where F_Date=a.F_Date and F_VocationType={0} ) as '{1}'"; List <string> fields = new List <string>(); foreach (KeyValuePair <string, string> item in MapVacationType()) { fields.Add(string.Format(template, item.Key, item.Value)); } sql = string.Format(sql, string.Join(",", fields)); ds = DBHelperDigGameDB.Query(sql); DataTable table = ds.Tables[0]; GridView1.Columns.Clear(); foreach (DataColumn item in table.Columns) { GridView1.Columns.Add(new BoundField() { DataField = item.ColumnName, HeaderText = item.ColumnName }); } DataView myView = ds.Tables[0].DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); if (ControlChart1.Visible == true) { ControlChart1.SetChart(GridView1, LabelTitle.Text.Replace(">>", " - ") + " " + LabelArea.Text + " " + LabelTime.Text, ControlChartSelect1.State, true); } } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = App_GlobalResources.Language.LblError + ex.Message; //lblerro.Text = sql; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-01-01"); DateTime dtb = Convert.ToDateTime(dates); for (int i = 1; i <= 12; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddMonths(i - 1) <= DateTime.Now) { btn.Text = dtb.AddMonths(i - 1).ToString("yyyy-MM"); btn.Visible = true; DateTime dttb = Convert.ToDateTime(btn.Text); DateTime dtte = dttb.AddMonths(1) > DateTime.Now ? DateTime.Now : dttb.AddMonths(1).AddDays(-1); if (dttb.ToString("yyyy-MM-dd") == tboxTimeB.Text && dtte.ToString("yyyy-MM-dd") == tboxTimeE.Text) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToShortDateString() + " 至 " + searchdateE.ToShortDateString(); string sqlwhere = " where 1=1 "; sqlwhere += @" and F_Date>='" + searchdateB.ToShortDateString() + "' and F_Date<='" + searchdateE.ToShortDateString() + "' "; if (DropDownListArea1.SelectedIndex > 0) { sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } if (DropDownListArea2.SelectedIndex > 0) { sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[1] + ""; } string sql = ""; sql = @"select F_Date,sum(F_OnlineNum) as F_OnlineNum,sum(F_OnlineIpNum) as F_OnlineIpNum, sum(F_OnlineTime) as F_OnlineTime, sum(F_LoginNum) as F_LoginNum, sum(F_LoginIpNum) as F_LoginIpNum,sum(F_ExitNum) as F_ExitNum,sum(F_ExitIpNum) as F_ExitIpNum,sum(F_OnlineTime)/60/24 as F_ACU from T_UserOnlineBaseDig " + sqlwhere + " group by F_Date"; try { ds = DBHelperDigGameDB.Query(sql); DataView myView = ds.Tables[0].DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = "出错:" + ex.Message; //lblerro.Text = sql; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = -1; i <= 31; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (i <= dte.Day && dtb.AddDays(i) <= DateTime.Now) { btn.Text = dtb.AddDays(i).ToString("MM-dd"); btn.Visible = true; if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("MM-dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToShortDateString() + " "; string sqlwhere = ""; sqlwhere += @" and F_Date='" + searchdateB.ToShortDateString() + "'"; if (DropDownListArea1.SelectedIndex > 0) { sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } if (DropDownListArea2.SelectedIndex > 0) { sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[1] + ""; } string sql = ""; sql = @"SELECT top 100 ROW_NUMBER() OVER(order by sum(F_LoginNum) desc) AS rownum, max(F_BigZone) as F_BigZone, max(F_ZoneID) as F_ZoneID , Sum(F_LoginNum) as F_LoginNum, max(F_UserName) as F_UserName,max(F_UserID) as F_UserID, max(F_LoginIP) as F_LoginIP from T_UserOnlineLoginRank where 1=1 " + sqlwhere + " group by F_UserName"; try { ds = DBHelperDigGameDB.Query(sql); DataView myView = ds.Tables[0].DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = "出错:" + ex.Message; //lblerro.Text = sql; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { if (!Common.Validate.IsDateTime(tboxTimeB.Text) || !Common.Validate.IsDateTime(tboxTimeE.Text)) { Common.MsgBox.Show(this, App_GlobalResources.Language.Tip_TimeError); return; } //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = 0; i <= 32; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddDays(i - 1) <= DateTime.Now && (i <= dte.Day || i == 32)) { btn.Visible = true; if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToString(SmallDateTimeFormat) + " "; string sqlwhere = " where 1=1 "; sqlwhere += @" and F_Date='" + searchdateB.ToString(SmallDateTimeFormat) + "'"; if (DropDownListArea1.SelectedIndex > 0) { sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } if (DropDownListArea2.SelectedIndex > 0) { sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[1] + ""; } string sql = ""; sql = @"with RVcte(F_TimePara, F_Pro, F_Num) as ( SELECT F_TimePara,F_Pro,Sum(F_Num) as F_Num FROM T_RoleLoseTimeFrist " + sqlwhere + @" group by F_TimePara,F_Pro ) select distinct(a.F_TimePara) as aa ,replace(F_TimePara,'301-9999999','" + string.Format(App_GlobalResources.Language.Msg_AndAboveFormat, "301") + "') as '" + App_GlobalResources.Language.LblTime + "',{0} FROM RVcte a order by a.F_TimePara asc"; try { string tmpl = "(select isnull(Sum(F_Num),0) from RVcte where F_TimePara=a.F_TimePara and F_Pro={0}) as '{1}'"; List <string> fields = new List <string>(); foreach (KeyValuePair <string, string> item in MapVacationType()) { fields.Add(string.Format(tmpl, item.Key, item.Value)); } sql = string.Format(sql, string.Join(",", fields)); ds = DBHelperDigGameDB.Query(sql); DataTable dtNew = ds.Tables[0].Clone(); string[] times = { "0-5", "6-10", "11-15", "16-30", "31-60", "61-90", "91-120", "121-180", "181-300", string.Format(App_GlobalResources.Language.Msg_AndAboveFormat, "301") }; foreach (string time in times) { DataRow[] drs = ds.Tables[0].Select(App_GlobalResources.Language.LblTime + "='" + time + "'"); if (drs.Length > 0) { DataRow drnew = dtNew.NewRow(); for (int i = 0; i < dtNew.Columns.Count; i++) { drnew[i] = drs[0][i].ToString(); } dtNew.Rows.Add(drnew); } } dtNew.Columns.Remove("aa"); GridView1.Columns.Clear(); columnValue = new List <long>(); foreach (DataColumn item in dtNew.Columns) { columnValue.Add(0); if (item.ColumnName == "F_TimeParaArea") { GridView1.Columns.Add(new BoundField() { DataField = item.ColumnName, HeaderText = item.ColumnName, DataFormatString = App_GlobalResources.Language.Msg_MinuteFormat }); } else { GridView1.Columns.Add(new BoundField() { DataField = item.ColumnName, HeaderText = item.ColumnName }); } } GridView1.Columns.Add(new BoundField() { HeaderText = App_GlobalResources.Language.LblSum }); DataView myView = dtNew.DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); if (ControlChart1.Visible == true) { ControlChart1.SetChart(GridView1, LabelTitle.Text.Replace(">>", " - ") + " " + LabelArea.Text + " " + LabelTime.Text, ControlChartSelect1.State); } } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = App_GlobalResources.Language.LblError + ex.Message; lblinfo.Text = sql; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { if (!Common.Validate.IsDateTime(tboxTimeB.Text) || !Common.Validate.IsDateTime(tboxTimeE.Text)) { Common.MsgBox.Show(this, App_GlobalResources.Language.Tip_TimeError); return; } //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-01-01"); DateTime dtb = Convert.ToDateTime(dates); for (int i = 1; i <= 12; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddMonths(i - 1) <= DateTime.Now) { btn.Text = dtb.AddMonths(i - 1).ToString("yyyy-MM"); btn.Visible = true; DateTime dttb = Convert.ToDateTime(btn.Text); DateTime dtte = dttb.AddMonths(1) > DateTime.Now ? DateTime.Now : dttb.AddMonths(1).AddDays(-1); if (dttb.ToString("yyyy-MM-dd") == tboxTimeB.Text && dtte.ToString("yyyy-MM-dd") == tboxTimeE.Text) { btn.CssClass = "buttonblo"; btn.Enabled = false; } else { btn.CssClass = "buttonbl"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToString(SmallDateTimeFormat) + " " + App_GlobalResources.Language.LblTo + " " + searchdateE.ToString(SmallDateTimeFormat); string sqlwhere = " where F_OPID=40052 "; sqlwhere += @" and F_Date>='" + searchdateB.ToString(SmallDateTimeFormat) + "' and F_Date<='" + searchdateE.ToString(SmallDateTimeFormat) + "' "; if (DropDownListArea1.SelectedIndex > 0) { sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } if (DropDownListArea2.SelectedIndex > 0) { sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[1] + ""; } string sql = @"SELECT F_Date,SUM(F_InRoleCount) as F_InRoleCount FROM T_Other_GSLog_Total " + sqlwhere + @" group by F_Date order by F_Date"; try { ds = DBHelperDigGameDB.Query(sql); DataView myView = ds.Tables[0].DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); if (ControlChart1.Visible == true) { ControlChart1.SetChart(GridView1, LabelTitle.Text.Replace(">>", " - ") + " " + LabelArea.Text + " " + LabelTime.Text, ControlChartSelect1.State, true, 0, 0); } } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = App_GlobalResources.Language.LblError + ex.Message; //lblerro.Text = sql; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { if (!Common.Validate.IsDateTime(tboxTimeB.Text) || !Common.Validate.IsDateTime(tboxTimeE.Text)) { Common.MsgBox.Show(this, App_GlobalResources.Language.Tip_TimeError); return; } //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = 0; i <= 32; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddDays(i - 1) <= DateTime.Now && (i <= dte.Day || i == 32)) { btn.Visible = true; if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToString(SmallDateTimeFormat) + " "; string sqlwhere = " where 1=1 "; sqlwhere += @" and F_Date='" + searchdateB.ToString(SmallDateTimeFormat) + "'"; if (DropDownListArea1.SelectedIndex > 0) { sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } if (DropDownListArea2.SelectedIndex > 0) { sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[1] + ""; } string sql = ""; sql = @"with RVcte(F_Level,F_VocationType, F_VocationNum) as ( SELECT (F_Level-1)/5 as F_Level,F_VocationType, Sum(F_VocationNum) as F_VocationNum FROM T_RoleLevelGrow " + sqlwhere + @" group by (F_Level-1)/5,F_VocationType ) select distinct(a.F_Level) as aa ,cast(F_Level*5+1 as varchar(3))+' - '+cast((F_Level+1)*5 as varchar(3)) as F_LevelArea, {0} FROM RVcte a order by a.F_Level asc"; try { string template = "(select isnull(Sum(F_VocationNum),0) from RVcte where F_Level=a.F_Level and F_VocationType={0}) as '{1}'"; List <string> fields = new List <string>(); columnValue = new List <long>(); foreach (KeyValuePair <string, string> item in MapVacationType()) { fields.Add(string.Format(template, item.Key, item.Value)); columnValue.Add(0); } sql = string.Format(sql, string.Join(",", fields)); ds = DBHelperDigGameDB.Query(sql); DataTable table = ds.Tables[0]; table.Columns.Remove("aa"); GridView1.Columns.Clear(); foreach (DataColumn item in table.Columns) { if (item.ColumnName == "F_LevelArea") { GridView1.Columns.Add(new BoundField() { DataField = item.ColumnName, HeaderText = App_GlobalResources.Language.LblLevel, DataFormatString = App_GlobalResources.Language.Msg_RoleGradeFormat }); } else { GridView1.Columns.Add(new BoundField() { DataField = item.ColumnName, HeaderText = item.ColumnName }); } } GridView1.Columns.Add(new BoundField() { HeaderText = App_GlobalResources.Language.LblSum }); DataView myView = table.DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); if (ControlChart1.Visible == true) { ControlChart1.SetChart(GridView1, LabelTitle.Text.Replace(">>", " - ") + " " + LabelArea.Text + " " + LabelTime.Text, ControlChartSelect1.State); } } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = App_GlobalResources.Language.LblError + ex.Message; //lblerro.Text = sql; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { //if (!Common.Validate.IsDateTime(tboxTimeB.Text) || !Common.Validate.IsDateTime(tboxTimeE.Text)) //{ // Common.MsgBox.Show(this, App_GlobalResources.Language.Tip_TimeError); // return; //} //设置日期按钮状态 //string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); //DateTime dtb = Convert.ToDateTime(dates); //DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = 0; i <= 32; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; //if (dtb.AddDays(i - 1) <= DateTime.Now && (i <= dte.Day || i == 32)) //{ // btn.Visible = true; // if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("dd")) // { // btn.CssClass = "buttonblueo"; // btn.Enabled = false; // } // else // { // btn.CssClass = "buttonblue"; // btn.Enabled = true; // } //} //else //{ // btn.Visible = false; //} } } //LabelArea.Text = DropDownListArea1.SelectedItem.Text; DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; //if (tboxTimeB.Text.Length > 0) //{ // searchdateB = Convert.ToDateTime(tboxTimeB.Text); //} //if (tboxTimeE.Text.Length > 0) //{ // searchdateE = Convert.ToDateTime(tboxTimeE.Text); //} LabelTime.Text = searchdateB.ToString(SmallDateTimeFormat) + " "; string sqlwhere = ""; //sqlwhere += @" and F_Date='" + searchdateB.ToString(SmallDateTimeFormat) + "'"; if (!string.IsNullOrEmpty(DropDownList1.SelectedValue)) { sqlwhere += @"where 1=1 and UnionId=" + DropDownList1.SelectedValue; } string bigZone = DropDownListArea1.SelectedIndex > 0 ? DropDownListArea1.SelectedValue.Split(',')[1] + "" : "0"; string battleZone = string.Empty; if (WssPublish == "0") { battleZone = DropDownListArea2.SelectedIndex > 0 ? DropDownListArea2.SelectedValue.Split(',')[1] + "" : "1"; } else { battleZone = DropDownListArea2.SelectedIndex > 0 ? DropDownListArea2.SelectedValue.Split(',')[1] + "" : "5"; } string sql = ""; sql = @"SELECT * FROM OPENQUERY ([LKSV_3_gsdata_db_" + bigZone + "_" + battleZone + "],'SELECT szName,nLevel,UnionId,MeritLevel FROM playerbaseinfo WHERE 1=1' ) " + sqlwhere + "order by szName"; try { ds = DBHelperDigGameDB.Query(sql); DataView myView = ds.Tables[0].DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); //if (ControlChart1.Visible == true) //{ // ControlChart1.SetChart(GridView1, LabelTitle.Text.Replace(">>", " - ") + " " + LabelArea.Text + " " + LabelTime.Text, ControlChartSelect1.State, false, 1, 1); //} } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = App_GlobalResources.Language.LblError + ex.Message; //lblerro.Text = sql; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { if (!Common.Validate.IsDateTime(tboxTimeB.Text) || !Common.Validate.IsDateTime(tboxTimeE.Text)) { Common.MsgBox.Show(this, App_GlobalResources.Language.Tip_TimeError); return; } //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = 0; i <= 32; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (dtb.AddDays(i - 1) <= DateTime.Now && (i <= dte.Day || i == 32)) { btn.Visible = true; if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } string searchdateB = DateTime.Now.ToString("yyyy-MM-dd"); string searchdateE = DateTime.Now.ToString("yyyy-MM-dd"); if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-dd"); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text).ToString("yyyy-MM-dd"); } LabelTime.Text = searchdateB; string sqlwhere = " where 1=1 "; //if (DropDownListArea1.SelectedIndex > 0) //{ // sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; //} if (DropDownListArea2.SelectedIndex > 0) { sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[1] + ""; } string sql = ""; sql = string.Format(@"WITH RVcte(F_Level,F_Pro,F_Num) AS ( SELECT F_Level,F_Pro,Sum(Num) AS F_Num FROM ( SELECT CONVERT(VARCHAR(100),F_CreateTime,23) F_CreateTime,F_ZoneID,F_Level,F_Pro,count(1) AS Num FROM GameCoreDB.dbo.T_RoleBaseData_0 WITH(NOLOCK) WHERE F_UpdateTime<Dateadd(DAY,-3,GETDATE()) AND CONVERT(VARCHAR(100),F_CreateTime,23)>='{0}' AND CONVERT(VARCHAR(100),F_CreateTime,23)<='{1}' group by CONVERT(VARCHAR(100),F_CreateTime,23),F_ZoneID,F_Level,F_Pro UNION ALL SELECT CONVERT(VARCHAR(100),F_CreateTime,23) F_CreateTime,F_ZoneID,F_Level,F_Pro,count(1) AS Num FROM GameCoreDB.dbo.T_RoleBaseData_1 WITH(NOLOCK) WHERE F_UpdateTime<Dateadd(DAY,-3,GETDATE()) AND CONVERT(VARCHAR(100),F_CreateTime,23)>='{2}' AND CONVERT(VARCHAR(100),F_CreateTime,23)<='{3}' group by CONVERT(VARCHAR(100),F_CreateTime,23),F_ZoneID,F_Level,F_Pro UNION ALL SELECT CONVERT(VARCHAR(100),F_CreateTime,23) F_CreateTime,F_ZoneID,F_Level,F_Pro,count(1) AS Num FROM GameCoreDB.dbo.T_RoleBaseData_2 WITH(NOLOCK) WHERE F_UpdateTime<Dateadd(DAY,-3,GETDATE()) AND CONVERT(VARCHAR(100),F_CreateTime,23)>='{4}' AND CONVERT(VARCHAR(100),F_CreateTime,23)<='{5}' group by CONVERT(VARCHAR(100),F_CreateTime,23),F_ZoneID,F_Level,F_Pro UNION ALL SELECT CONVERT(VARCHAR(100),F_CreateTime,23) F_CreateTime,F_ZoneID,F_Level,F_Pro,count(1) AS Num FROM GameCoreDB.dbo.T_RoleBaseData_3 WITH(NOLOCK) WHERE F_UpdateTime<Dateadd(DAY,-3,GETDATE()) AND CONVERT(VARCHAR(100),F_CreateTime,23)>='{6}' AND CONVERT(VARCHAR(100),F_CreateTime,23)<='{7}' group by CONVERT(VARCHAR(100),F_CreateTime,23),F_ZoneID,F_Level,F_Pro UNION ALL SELECT CONVERT(VARCHAR(100),F_CreateTime,23) F_CreateTime,F_ZoneID,F_Level,F_Pro,count(1) AS Num FROM GameCoreDB.dbo.T_RoleBaseData_4 WITH(NOLOCK) WHERE F_UpdateTime<Dateadd(DAY,-3,GETDATE()) AND CONVERT(VARCHAR(100),F_CreateTime,23)>='{8}' AND CONVERT(VARCHAR(100),F_CreateTime,23)<='{9}' group by CONVERT(VARCHAR(100),F_CreateTime,23),F_ZoneID,F_Level,F_Pro )TEMP {10} GROUP BY F_Level,F_Pro ) SELECT DISTINCT (a.F_Level) AS '等级', (SELECT ISNULL(SUM(F_Num), 0) FROM RVcte WHERE F_Level = a.F_Level AND F_Pro = 1) AS '猎魔者', (SELECT ISNULL(SUM(F_Num), 0) FROM RVcte WHERE F_Level = a.F_Level AND F_Pro = 2) AS '魔导师', (SELECT ISNULL(SUM(F_Num), 0) FROM RVcte WHERE F_Level = a.F_Level AND F_Pro = 3) AS '龙战士', (SELECT ISNULL(SUM(F_Num), 0) FROM RVcte WHERE F_Level = a.F_Level AND F_Pro = 4) AS '召唤师' FROM RVcte a ORDER BY a.F_Level ASC", searchdateB, searchdateE, searchdateB, searchdateE, searchdateB, searchdateE, searchdateB, searchdateE, searchdateB, searchdateE, sqlwhere); try { //string tmpl = "(select isnull(Sum(F_Num),0) from RVcte where F_Level=a.F_Level and F_Pro={0}) as '{1}'"; //List<string> fields = new List<string>(); //foreach (KeyValuePair<String, string> item in MapVacationType()) //{ // fields.Add(string.Format(tmpl, item.Key, item.Value)); //} //sql = string.Format(sql, string.Join(",", fields)); ds = DBHelperGameCoreDB.Query(sql); columnValue = new List <long>(); DataTable table = ds.Tables[0]; GridView1.Columns.Clear(); GridView1.Columns.Add(new BoundField() { DataField = "等级", HeaderText = App_GlobalResources.Language.LblLevel, DataFormatString = App_GlobalResources.Language.Msg_RoleGradeFormat }); columnValue.Add(0); foreach (KeyValuePair <string, string> item in MapVacationType1()) { GridView1.Columns.Add(new BoundField() { DataField = item.Value, HeaderText = item.Value }); columnValue.Add(0); } GridView1.Columns.Add(new BoundField() { HeaderText = App_GlobalResources.Language.LblSum }); DataView myView = table.DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); if (ControlChart1.Visible == true) { ControlChart1.SetChart(GridView1, LabelTitle.Text.Replace(">>", " - ") + " " + LabelArea.Text + " " + LabelTime.Text, ControlChartSelect1.State); } } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = App_GlobalResources.Language.LblError + ex.Message; lblinfo.Text = sql; } }