2015-11-04 报表(c#部分)(Datatable 查询,弹出日期控件,输入是否整数)
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Globalization;
using System.IO;
public partial class Scrap_p : System.Web.UI.Page
{
protected System.Data.SqlClient.SqlConnection SqlConnection1;
protected System.Data.SqlClient.SqlDataAdapter SqlDataAdapter1;
protected System.Data.DataSet DataSet1;
protected System.Data.DataSet DataSet2;
protected System.Data.DataSet DataSet3;
protected System.Data.DataSet DataSet6;
protected System.Data.DataSet DataSet7;
string Str_sql = "";
static int int_count = 9; //used row count
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
databind();
DropDownList2_databind();
this.Btn_search.Focus();
}
}
// 动态计算列数
protected void row_count()
{
P_ht.H_data P_data = new P_ht.H_data();
P_data.sql_text1 = " SELECT TaskId as 任务号 FROM SysBpmITask WHERE FlowGuid = 'c0c0bd0a-8d95-41ae-ae60-d9d43c686618'order by 任务号 desc ";
Str_sql = P_data.sql_text1;
P_data.select_tables();
DataSet6 = P_data.DataSet8;
string str_id = "";
int int_temp = 0;
if (DataSet6.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < DataSet6.Tables[0].Rows.Count; i++)
{
str_id = DataSet6.Tables[0].Rows[i]["任务号"].ToString().Trim();
P_data.sql_text1 = " select COUNT(*) from SysBpmIProc where HandlerUserId <> '0' and TaskId = '" + str_id.Trim() + "' ";
Str_sql = P_data.sql_text1;
P_data.select_tables();
DataSet7 = P_data.DataSet8;
if (DataSet7.Tables[0].Rows.Count > 0)
{
int_temp = System.Convert.ToInt32(DataSet7.Tables[0].Rows[0][0].ToString().Trim());
if (int_temp > int_count)
{
int_count = int_temp;
}
}
}
}
//Response.Write(int_count);
//if (int_count == 11)
//{
// DataSet1.Tables[0].Columns.Add("审核11", Type.GetType("System.String"));
// DataSet1.Tables[0].Columns.Add("时间11", Type.GetType("System.String"));
// BoundField 审核11 = new BoundField();
// 审核11.HeaderText = "审核11";
// 审核11.DataField = "审核11";
// 审核11.ReadOnly = true;
// BoundField 时间11 = new BoundField();
// 时间11.HeaderText = "时间11";
// 时间11.DataField = "时间11";
// 时间11.ReadOnly = true;
// this.GridView1.Columns.Add(审核11);
// this.GridView1.Columns.Add(时间11);
//}
}
protected void databind()
{
//
P_ht.H_data P_data = new P_ht.H_data();
P_data.sql_text1 = " SELECT SysBpmITask.TaskId as 任务号, TaskName as 提交内容, ZY_scrap_m.RBC04 as 部门 FROM SysBpmITask "
+ " LEFT JOIN ZY_scrap_m ON ZY_scrap_m.TaskId = SysBpmITask.TaskId"
+ " WHERE FlowGuid = 'c0c0bd0a-8d95-41ae-ae60-d9d43c686618'order by 任务号 desc ";
Str_sql = P_data.sql_text1;
P_data.select_tables();
DataSet1 = P_data.DataSet8;
DataSet1.Tables[0].Columns.Add("签核完成情况", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("提交人1", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("提交时间1", typeof(System.DateTime));
DataSet1.Tables[0].Columns.Add("审核2", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间2", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("审核3", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间3", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("审核4", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间4", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("审核5", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间5", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("审核6", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间6", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("审核7", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间7", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("审核8", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间8", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("审核9", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间9", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("审核10", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间10", Type.GetType("System.String"));
#region "固定增加列数"
/*
//
//if ((DataSet2.Tables[0].Rows.Count > 10) && (DataSet1.Tables[0].Columns.Count < 24))
//{
DataSet1.Tables[0].Columns.Add("审核11", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间11", Type.GetType("System.String"));
BoundField 审核11 = new BoundField();
审核11.HeaderText = "审核11";
审核11.DataField = "审核11";
审核11.ReadOnly = true;
BoundField 时间11 = new BoundField();
时间11.HeaderText = "时间11";
时间11.DataField = "时间11";
时间11.ReadOnly = true;
this.GridView1.Columns.Add(审核11);
this.GridView1.Columns.Add(时间11);
//}
//if ((DataSet2.Tables[0].Rows.Count == 12) && (DataSet1.Tables[0].Columns.Count < 26))
//{
BoundField 审核12 = new BoundField();
审核12.HeaderText = "审核12";
审核12.DataField = "审核12";
审核12.ReadOnly = true;
BoundField 时间12 = new BoundField();
时间12.HeaderText = "时间12";
时间12.DataField = "时间12";
时间12.ReadOnly = true;
this.GridView1.Columns.Add(审核12);
this.GridView1.Columns.Add(时间12);
DataSet1.Tables[0].Columns.Add("审核12", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间12", Type.GetType("System.String"));
//}
//if ((DataSet2.Tables[0].Rows.Count == 13) && (DataSet1.Tables[0].Columns.Count < 28))
//{
BoundField 审核13 = new BoundField();
审核13.HeaderText = "审核13";
审核13.DataField = "审核13";
审核13.ReadOnly = true;
BoundField 时间13 = new BoundField();
时间13.HeaderText = "时间13";
时间13.DataField = "时间13";
时间13.ReadOnly = true;
this.GridView1.Columns.Add(审核13);
this.GridView1.Columns.Add(时间13);
DataSet1.Tables[0].Columns.Add("审核13", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间13", Type.GetType("System.String"));
//}
//if ((DataSet2.Tables[0].Rows.Count == 14) && (DataSet1.Tables[0].Columns.Count < 30))
//{
BoundField 审核14 = new BoundField();
审核14.HeaderText = "审核14";
审核14.DataField = "审核14";
审核14.ReadOnly = true;
BoundField 时间14 = new BoundField();
时间14.HeaderText = "时间14";
时间14.DataField = "时间14";
时间14.ReadOnly = true;
this.GridView1.Columns.Add(审核14);
this.GridView1.Columns.Add(时间14);
DataSet1.Tables[0].Columns.Add("审核14", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间14", Type.GetType("System.String"));
//}
//if ((DataSet2.Tables[0].Rows.Count == 15) && (DataSet1.Tables[0].Columns.Count < 32))
//{
BoundField 审核15 = new BoundField();
审核15.HeaderText = "审核15";
审核15.DataField = "审核15";
审核15.ReadOnly = true;
BoundField 时间15 = new BoundField();
时间15.HeaderText = "时间15";
时间15.DataField = "时间15";
时间15.ReadOnly = true;
this.GridView1.Columns.Add(审核15);
this.GridView1.Columns.Add(时间15);
DataSet1.Tables[0].Columns.Add("审核15", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间15", Type.GetType("System.String"));
//}
//if ((DataSet2.Tables[0].Rows.Count == 16) && (DataSet1.Tables[0].Columns.Count < 34))
//{
BoundField 审核16 = new BoundField();
审核16.HeaderText = "审核16";
审核16.DataField = "审核16";
审核16.ReadOnly = true;
BoundField 时间16 = new BoundField();
时间16.HeaderText = "时间16";
时间16.DataField = "时间16";
时间16.ReadOnly = true;
this.GridView1.Columns.Add(审核16);
this.GridView1.Columns.Add(时间16);
DataSet1.Tables[0].Columns.Add("审核16", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间16", Type.GetType("System.String"));
//}
//
*/
#endregion
row_count();
#region "动态增加列数"
if (int_count == 11)
{
DataSet1.Tables[0].Columns.Add("审核11", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间11", Type.GetType("System.String"));
BoundField 审核11 = new BoundField();
审核11.HeaderText = "审核11";
审核11.DataField = "审核11";
审核11.ReadOnly = true;
BoundField 时间11 = new BoundField();
时间11.HeaderText = "时间11";
时间11.DataField = "时间11";
时间11.ReadOnly = true;
this.GridView1.Columns.Add(审核11);
this.GridView1.Columns.Add(时间11);
}
if (int_count == 12)
{
DataSet1.Tables[0].Columns.Add("审核11", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间11", Type.GetType("System.String"));
BoundField 审核11 = new BoundField();
审核11.HeaderText = "审核11";
审核11.DataField = "审核11";
审核11.ReadOnly = true;
BoundField 时间11 = new BoundField();
时间11.HeaderText = "时间11";
时间11.DataField = "时间11";
时间11.ReadOnly = true;
this.GridView1.Columns.Add(审核11);
this.GridView1.Columns.Add(时间11);
//
BoundField 审核12 = new BoundField();
审核12.HeaderText = "审核12";
审核12.DataField = "审核12";
审核12.ReadOnly = true;
BoundField 时间12 = new BoundField();
时间12.HeaderText = "时间12";
时间12.DataField = "时间12";
时间12.ReadOnly = true;
this.GridView1.Columns.Add(审核12);
this.GridView1.Columns.Add(时间12);
DataSet1.Tables[0].Columns.Add("审核12", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间12", Type.GetType("System.String"));
}
if (int_count == 13)
{
DataSet1.Tables[0].Columns.Add("审核11", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间11", Type.GetType("System.String"));
BoundField 审核11 = new BoundField();
审核11.HeaderText = "审核11";
审核11.DataField = "审核11";
审核11.ReadOnly = true;
BoundField 时间11 = new BoundField();
时间11.HeaderText = "时间11";
时间11.DataField = "时间11";
时间11.ReadOnly = true;
this.GridView1.Columns.Add(审核11);
this.GridView1.Columns.Add(时间11);
//
BoundField 审核12 = new BoundField();
审核12.HeaderText = "审核12";
审核12.DataField = "审核12";
审核12.ReadOnly = true;
BoundField 时间12 = new BoundField();
时间12.HeaderText = "时间12";
时间12.DataField = "时间12";
时间12.ReadOnly = true;
this.GridView1.Columns.Add(审核12);
this.GridView1.Columns.Add(时间12);
DataSet1.Tables[0].Columns.Add("审核12", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间12", Type.GetType("System.String"));
//
BoundField 审核13 = new BoundField();
审核13.HeaderText = "审核13";
审核13.DataField = "审核13";
审核13.ReadOnly = true;
BoundField 时间13 = new BoundField();
时间13.HeaderText = "时间13";
时间13.DataField = "时间13";
时间13.ReadOnly = true;
this.GridView1.Columns.Add(审核13);
this.GridView1.Columns.Add(时间13);
DataSet1.Tables[0].Columns.Add("审核13", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间13", Type.GetType("System.String"));
}
if (int_count == 14)
{
DataSet1.Tables[0].Columns.Add("审核11", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间11", Type.GetType("System.String"));
BoundField 审核11 = new BoundField();
审核11.HeaderText = "审核11";
审核11.DataField = "审核11";
审核11.ReadOnly = true;
BoundField 时间11 = new BoundField();
时间11.HeaderText = "时间11";
时间11.DataField = "时间11";
时间11.ReadOnly = true;
this.GridView1.Columns.Add(审核11);
this.GridView1.Columns.Add(时间11);
//
BoundField 审核12 = new BoundField();
审核12.HeaderText = "审核12";
审核12.DataField = "审核12";
审核12.ReadOnly = true;
BoundField 时间12 = new BoundField();
时间12.HeaderText = "时间12";
时间12.DataField = "时间12";
时间12.ReadOnly = true;
this.GridView1.Columns.Add(审核12);
this.GridView1.Columns.Add(时间12);
DataSet1.Tables[0].Columns.Add("审核12", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间12", Type.GetType("System.String"));
//
BoundField 审核13 = new BoundField();
审核13.HeaderText = "审核13";
审核13.DataField = "审核13";
审核13.ReadOnly = true;
BoundField 时间13 = new BoundField();
时间13.HeaderText = "时间13";
时间13.DataField = "时间13";
时间13.ReadOnly = true;
this.GridView1.Columns.Add(审核13);
this.GridView1.Columns.Add(时间13);
DataSet1.Tables[0].Columns.Add("审核13", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间13", Type.GetType("System.String"));
//
BoundField 审核14 = new BoundField();
审核14.HeaderText = "审核14";
审核14.DataField = "审核14";
审核14.ReadOnly = true;
BoundField 时间14 = new BoundField();
时间14.HeaderText = "时间14";
时间14.DataField = "时间14";
时间14.ReadOnly = true;
this.GridView1.Columns.Add(审核14);
this.GridView1.Columns.Add(时间14);
DataSet1.Tables[0].Columns.Add("审核14", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间14", Type.GetType("System.String"));
}
if (int_count == 15)
{
DataSet1.Tables[0].Columns.Add("审核11", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间11", Type.GetType("System.String"));
BoundField 审核11 = new BoundField();
审核11.HeaderText = "审核11";
审核11.DataField = "审核11";
审核11.ReadOnly = true;
BoundField 时间11 = new BoundField();
时间11.HeaderText = "时间11";
时间11.DataField = "时间11";
时间11.ReadOnly = true;
this.GridView1.Columns.Add(审核11);
this.GridView1.Columns.Add(时间11);
//
BoundField 审核12 = new BoundField();
审核12.HeaderText = "审核12";
审核12.DataField = "审核12";
审核12.ReadOnly = true;
BoundField 时间12 = new BoundField();
时间12.HeaderText = "时间12";
时间12.DataField = "时间12";
时间12.ReadOnly = true;
this.GridView1.Columns.Add(审核12);
this.GridView1.Columns.Add(时间12);
DataSet1.Tables[0].Columns.Add("审核12", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间12", Type.GetType("System.String"));
//
BoundField 审核13 = new BoundField();
审核13.HeaderText = "审核13";
审核13.DataField = "审核13";
审核13.ReadOnly = true;
BoundField 时间13 = new BoundField();
时间13.HeaderText = "时间13";
时间13.DataField = "时间13";
时间13.ReadOnly = true;
this.GridView1.Columns.Add(审核13);
this.GridView1.Columns.Add(时间13);
DataSet1.Tables[0].Columns.Add("审核13", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间13", Type.GetType("System.String"));
//
BoundField 审核14 = new BoundField();
审核14.HeaderText = "审核14";
审核14.DataField = "审核14";
审核14.ReadOnly = true;
BoundField 时间14 = new BoundField();
时间14.HeaderText = "时间14";
时间14.DataField = "时间14";
时间14.ReadOnly = true;
this.GridView1.Columns.Add(审核14);
this.GridView1.Columns.Add(时间14);
DataSet1.Tables[0].Columns.Add("审核14", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间14", Type.GetType("System.String"));
//
BoundField 审核15 = new BoundField();
审核15.HeaderText = "审核15";
审核15.DataField = "审核15";
审核15.ReadOnly = true;
BoundField 时间15 = new BoundField();
时间15.HeaderText = "时间15";
时间15.DataField = "时间15";
时间15.ReadOnly = true;
this.GridView1.Columns.Add(审核15);
this.GridView1.Columns.Add(时间15);
DataSet1.Tables[0].Columns.Add("审核15", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间15", Type.GetType("System.String"));
}
if (int_count == 16)
{
DataSet1.Tables[0].Columns.Add("审核11", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间11", Type.GetType("System.String"));
BoundField 审核11 = new BoundField();
审核11.HeaderText = "审核11";
审核11.DataField = "审核11";
审核11.ReadOnly = true;
BoundField 时间11 = new BoundField();
时间11.HeaderText = "时间11";
时间11.DataField = "时间11";
时间11.ReadOnly = true;
this.GridView1.Columns.Add(审核11);
this.GridView1.Columns.Add(时间11);
//
BoundField 审核12 = new BoundField();
审核12.HeaderText = "审核12";
审核12.DataField = "审核12";
审核12.ReadOnly = true;
BoundField 时间12 = new BoundField();
时间12.HeaderText = "时间12";
时间12.DataField = "时间12";
时间12.ReadOnly = true;
this.GridView1.Columns.Add(审核12);
this.GridView1.Columns.Add(时间12);
DataSet1.Tables[0].Columns.Add("审核12", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间12", Type.GetType("System.String"));
//
BoundField 审核13 = new BoundField();
审核13.HeaderText = "审核13";
审核13.DataField = "审核13";
审核13.ReadOnly = true;
BoundField 时间13 = new BoundField();
时间13.HeaderText = "时间13";
时间13.DataField = "时间13";
时间13.ReadOnly = true;
this.GridView1.Columns.Add(审核13);
this.GridView1.Columns.Add(时间13);
DataSet1.Tables[0].Columns.Add("审核13", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间13", Type.GetType("System.String"));
//
BoundField 审核14 = new BoundField();
审核14.HeaderText = "审核14";
审核14.DataField = "审核14";
审核14.ReadOnly = true;
BoundField 时间14 = new BoundField();
时间14.HeaderText = "时间14";
时间14.DataField = "时间14";
时间14.ReadOnly = true;
this.GridView1.Columns.Add(审核14);
this.GridView1.Columns.Add(时间14);
DataSet1.Tables[0].Columns.Add("审核14", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间14", Type.GetType("System.String"));
//
BoundField 审核15 = new BoundField();
审核15.HeaderText = "审核15";
审核15.DataField = "审核15";
审核15.ReadOnly = true;
BoundField 时间15 = new BoundField();
时间15.HeaderText = "时间15";
时间15.DataField = "时间15";
时间15.ReadOnly = true;
this.GridView1.Columns.Add(审核15);
this.GridView1.Columns.Add(时间15);
DataSet1.Tables[0].Columns.Add("审核15", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间15", Type.GetType("System.String"));
//
BoundField 审核16 = new BoundField();
审核16.HeaderText = "审核16";
审核16.DataField = "审核16";
审核16.ReadOnly = true;
BoundField 时间16 = new BoundField();
时间16.HeaderText = "时间16";
时间16.DataField = "时间16";
时间16.ReadOnly = true;
this.GridView1.Columns.Add(审核16);
this.GridView1.Columns.Add(时间16);
DataSet1.Tables[0].Columns.Add("审核16", Type.GetType("System.String"));
DataSet1.Tables[0].Columns.Add("时间16", Type.GetType("System.String"));
}
#endregion
//Int32 i_sum1 = DataSet1.Tables[0].Rows.Count;
string str_id = "";
//
if (DataSet1.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < DataSet1.Tables[0].Rows.Count; i++)
{
str_id = DataSet1.Tables[0].Rows[i]["任务号"].ToString().Trim();
//
P_data.sql_text1 = " select HandlerUserName, FinishDate from SysBpmIProc where HandlerUserId <> '0' and TaskId = '" + str_id.Trim() + "' order by FinishDate Asc ";
Str_sql = P_data.sql_text1;
P_data.select_tables();
DataSet2 = P_data.DataSet8;
if (DataSet2.Tables[0].Rows.Count > 0)
{
for (int i2 = 0; i2 < DataSet2.Tables[0].Rows.Count; i2++)
{
DataSet1.Tables[0].Rows[i][(i2 + 1)*2 + 2] = DataSet2.Tables[0].Rows[i2][0].ToString();
if (DataSet2.Tables[0].Rows[i2][1].ToString().Trim() != "")
{
DataSet1.Tables[0].Rows[i][(i2 + 1) * 2 + 3] = DataSet2.Tables[0].Rows[i2][1].ToString();
}
}
}
//
P_data.sql_text1 = " select TaskId FROM SysBpmITask WHERE FlowGuid = 'c0c0bd0a-8d95-41ae-ae60-d9d43c686618' AND ([Status] = '4' or [Status] = '5') and TaskId = '" + str_id.Trim() + "' ";
Str_sql = P_data.sql_text1;
P_data.select_tables();
DataSet2 = P_data.DataSet8;
if (DataSet2.Tables[0].Rows.Count > 0)
{
DataSet1.Tables[0].Rows[i][3] = "已完成";
}
else
{
DataSet1.Tables[0].Rows[i][3] = "未完成";
P_data.sql_text1 = " select SubmissionDate FROM SysBpmITask WHERE TaskId = '" + str_id.Trim() + "' ";
Str_sql = P_data.sql_text1;
P_data.select_tables();
DataSet3 = P_data.DataSet8;
if (DataSet3.Tables[0].Rows.Count > 0)
{
DataSet1.Tables[0].Rows[i][5] = DataSet3.Tables[0].Rows[0][0].ToString();
}
}
}
}
Session["DS_all"] = this.DataSet1;
Session["DS_temp"] = this.DataSet1;
this.GridView1.DataSource = DataSet1;
this.GridView1.DataBind();
//BoundField bf1 = new BoundField();
//bf1.HeaderText = "creator";
//bf1.DataField = "creator";
//bf1.ReadOnly = true;
////bf1.SortExpression = "EmployeeID";
//this.GridView1.Columns.Add(bf1);
////
//P_ht.H_data P_data = new P_ht.H_data();
//P_data.sql_text1 = " SELECT ZY_scrap_m.TaskId, RBC01, RBC17, RBC02, SysBpmITask.FinishDate as FinishDate, creator FROM ZY_scrap_m "
// + " LEFT JOIN SysBpmITask ON ZY_scrap_m.TaskId = SysBpmITask.TaskId ";
//Str_sql = P_data.sql_text1;
//P_data.select_tables();
//DataSet1 = P_data.DataSet8;
//Session["ZY_scrap_m"] = this.DataSet1;
//this.GridView1.DataSource = DataSet1;
//this.GridView1.DataBind();
}
protected void DropDownList2_databind()
{
P_ht.H_data P_data = new P_ht.H_data();
P_data.sql_text1 = " SELECT distinct RBC04 FROM ZY_scrap_m ";
Str_sql = P_data.sql_text1;
P_data.select_tables();
DataSet2 = P_data.DataSet8;
DropDownList2.DataSource = DataSet2;
//指定DropDownList使用的表里的那些字段
DropDownList2.DataTextField = "RBC04"; //dropdownlist的Text的字段
DropDownList2.DataValueField = "RBC04"; //dropdownlist的Value的字段
DropDownList2.DataBind();
DropDownList2.Items.Add("全部");
DropDownList2.Text = "全部";
DataSet2.Dispose();
}
protected void Btn_reset_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
DropDownList1.Text = "全部";
DropDownList2.Text = "全部";
GridView1.Width = 4032;
GridView1.Height = 92;
//databind();
this.DataSet1 = (DataSet)Session["DS_all"];
this.GridView1.DataSource = DataSet1;
this.GridView1.DataBind();
}
protected void Btn_search_Click(object sender, EventArgs e)
{
//
//dt.Select("C1='abc'");//
string m_Where = "";
//
//// 正则表示式验证
//
//
//// check
//
//// Response.Write("非标准日期");
//
//dt.Select("C1='abc'");
this.DataSet2 = new System.Data.DataSet();
this.DataSet2 = (DataSet)Session["DS_all"];
DataRow[] drArr = null;
//
DateTime dt1, dt2;
//
if ((this.TextBox1.Text.Trim() != "") && (this.TextBox2.Text.Trim() != ""))
{
if (DateTime.TryParseExact(this.TextBox1.Text.Trim(), "yyyy-MM-dd", null, DateTimeStyles.None, out dt1))
{
//验证通过
}
else
{
ClientScriptManager scriptManager = ((Page)System.Web.HttpContext.Current.Handler).ClientScript;
scriptManager.RegisterStartupScript(typeof(string), "", "alert('提示: 项目开始日期不是日期格式! ');", true);
return;
}
if (DateTime.TryParseExact(this.TextBox2.Text.Trim(), "yyyy-MM-dd", null, DateTimeStyles.None, out dt2))
{
//验证通过
}
else
{
ClientScriptManager scriptManager = ((Page)System.Web.HttpContext.Current.Handler).ClientScript;
scriptManager.RegisterStartupScript(typeof(string), "", "alert('提示: 项目截止日期不是日期格式! ');", true);
return;
}
////
if ((dt2 < dt1))
{
ClientScriptManager scriptManager = ((Page)System.Web.HttpContext.Current.Handler).ClientScript;
scriptManager.RegisterStartupScript(typeof(string), "", "alert('提示: 项目开始日期不能大于项目截止日期! ');", true);
return;
}
else
{
m_Where += (m_Where == "" ? "" : " and ") + " 提交时间1 >= '" + this.TextBox1.Text.Trim() + "' and 提交时间1 <= '" + this.TextBox2.Text.Trim() + "' ";
//m_Where += (m_Where == "" ? "" : " and ") + " 提交时间1 >= '2015-10-10 00:00:00' and 提交时间1 <= '2015-11-10 00:00:00' ";
}
}
else
{
if ((this.TextBox1.Text.Trim() != "") && (this.TextBox2.Text.Trim() == ""))
{
if (DateTime.TryParseExact(this.TextBox1.Text.Trim(), "yyyy-MM-dd", null, DateTimeStyles.None, out dt1))
{
//验证通过
m_Where += (m_Where == "" ? "" : " and ") + " 提交时间1 >= '" + this.TextBox1.Text.Trim() + "' ";
}
else
{
ClientScriptManager scriptManager = ((Page)System.Web.HttpContext.Current.Handler).ClientScript;
scriptManager.RegisterStartupScript(typeof(string), "", "alert('提示: 项目开始日期不是日期格式! ');", true);
return;
}
}
else
{
if ((this.TextBox1.Text.Trim() == "") && (this.TextBox2.Text.Trim() != ""))
{
if (DateTime.TryParseExact(this.TextBox2.Text.Trim(), "yyyy-MM-dd", null, DateTimeStyles.None, out dt1))
{
//验证通过
m_Where += (m_Where == "" ? "" : " and ") + " 提交时间1 <= '" + this.TextBox2.Text.Trim() + "' ";
}
else
{
ClientScriptManager scriptManager = ((Page)System.Web.HttpContext.Current.Handler).ClientScript;
scriptManager.RegisterStartupScript(typeof(string), "", "alert('提示: 项目开始日期不是日期格式! ');", true);
return;
}
}
}
}
// TaskId
if (this.TextBox4.Text.Trim() != "")
{
int int_1;
if (int.TryParse(this.TextBox4.Text.Trim(), out int_1) == false) //判断是否可以转换为整型
{
ClientScriptManager scriptManager = ((Page)System.Web.HttpContext.Current.Handler).ClientScript;
scriptManager.RegisterStartupScript(typeof(string), "", "alert('提示: 任务号输入不正确, 请输入正确的整数格式! ');", true);
return;
}
else
{
m_Where += (m_Where == "" ? "" : " and ") + " 任务号 = '" + this.TextBox4.Text.Trim() + "' ";
}
//drArr = DataSet2.Tables[0].Select(" 任务号 = '" + this.TextBox4.Text.Trim() + "' ");
//m_Where += (m_Where == "" ? "" : " and ") + " 任务号 = '" + this.TextBox4.Text.Trim() + "' ";
}
// CREATOR
if (this.TextBox3.Text.Trim() != "")
{
//drArr = DataSet2.Tables[0].Select(" 提交人1 = '" + this.TextBox3.Text.Trim() + "' ");
m_Where += (m_Where == "" ? "" : " and ") + " 提交人1 = '" + this.TextBox3.Text.Trim() + "' ";
}
// DropDownList1
if (DropDownList1.Text.Trim() != "全部")
{
if (DropDownList1.Text.Trim() == "已完成")
{
//drArr = DataSet2.Tables[0].Select(" 签核完成情况 = '已完成'");
m_Where += (m_Where == "" ? "" : " and ") + " 签核完成情况 = '已完成' ";
}
if (DropDownList1.Text.Trim() == "未完成")
{
//drArr = DataSet2.Tables[0].Select(" 签核完成情况 = '未完成'");
m_Where += (m_Where == "" ? "" : " and ") + " 签核完成情况 = '未完成' ";
}
}
// RBC04
if ((DropDownList2.Text.Trim() != "全部") && (DropDownList2.Text.Trim() != ""))
{
m_Where += (m_Where == "" ? "" : " and ") + " 部门 = '" + DropDownList2.Text.Trim() + "' ";
}
//
drArr = DataSet2.Tables[0].Select(m_Where);
DataTable dtNew = DataSet2.Tables[0].Clone();
for (int i = 0; i < drArr.Length; i++)
{
dtNew.ImportRow(drArr[i]);
}
this.GridView1.DataSource = dtNew;
DataSet3 = new System.Data.DataSet();
this.DataSet3.Tables.Add(dtNew.Copy());
Session["DS_temp"] = this.DataSet3;
this.GridView1.DataBind();
//this.DataSet2 = new System.Data.DataSet();
//this.DataSet2 = (DataSet)Session["ZY_scrap_m"];
////this.DataSet2.Tables[0].Select(m_Where);
////DataTable dtNew = DataSet2.Tables[0].Select(m_Where);
////DataTable dtNew = DataSet2.Tables[0].Select(m_Where).DefaultView.ToTable();
//this.GridView1.DataSource = dtNew;
//this.GridView1.DataBind();
/*
string m_Where = "";
//
//// 正则表示式验证
//
//
//// check
//
//// Response.Write("非标准日期");
DateTime dt1, dt2;
//
if ((this.TextBox1.Text.Trim() != "") && (this.TextBox2.Text.Trim() != ""))
{
if (DateTime.TryParseExact(this.TextBox1.Text.Trim(), "yyyy-MM-dd", null, DateTimeStyles.None, out dt1))
{
//验证通过
}
else
{
ClientScriptManager scriptManager = ((Page)System.Web.HttpContext.Current.Handler).ClientScript;
scriptManager.RegisterStartupScript(typeof(string), "", "alert('提示: 项目开始日期不是日期格式! ');", true);
return;
}
if (DateTime.TryParseExact(this.TextBox2.Text.Trim(), "yyyy-MM-dd", null, DateTimeStyles.None, out dt2))
{
//验证通过
}
else
{
ClientScriptManager scriptManager = ((Page)System.Web.HttpContext.Current.Handler).ClientScript;
scriptManager.RegisterStartupScript(typeof(string), "", "alert('提示: 项目截止日期不是日期格式! ');", true);
return;
}
////
if ((dt2 < dt1))
{
ClientScriptManager scriptManager = ((Page)System.Web.HttpContext.Current.Handler).ClientScript;
scriptManager.RegisterStartupScript(typeof(string), "", "alert('提示: 项目开始日期不能大于项目截止日期! ');", true);
return;
}
else
{
m_Where += (m_Where == "" ? "" : " and ") + " RBC02 Between '" + this.TextBox1.Text.Trim() + "' and '" + this.TextBox2.Text.Trim() + "'";
}
}
else
{
if ((this.TextBox1.Text.Trim() != "") && (this.TextBox2.Text.Trim() == ""))
{
if (DateTime.TryParseExact(this.TextBox1.Text.Trim(), "yyyy-MM-dd", null, DateTimeStyles.None, out dt1))
{
//验证通过
m_Where += (m_Where == "" ? "" : " and ") + " RBC02 > '" + this.TextBox1.Text.Trim() + "' ";
}
else
{
ClientScriptManager scriptManager = ((Page)System.Web.HttpContext.Current.Handler).ClientScript;
scriptManager.RegisterStartupScript(typeof(string), "", "alert('提示: 项目开始日期不是日期格式! ');", true);
return;
}
}
else
{
if ((this.TextBox1.Text.Trim() == "") && (this.TextBox2.Text.Trim() != ""))
{
if (DateTime.TryParseExact(this.TextBox2.Text.Trim(), "yyyy-MM-dd", null, DateTimeStyles.None, out dt1))
{
//验证通过
m_Where += (m_Where == "" ? "" : " and ") + " RBC02 < '" + this.TextBox2.Text.Trim() + "' ";
}
else
{
ClientScriptManager scriptManager = ((Page)System.Web.HttpContext.Current.Handler).ClientScript;
scriptManager.RegisterStartupScript(typeof(string), "", "alert('提示: 项目开始日期不是日期格式! ');", true);
return;
}
}
}
}
//// project
//if (this.TextBox3.Text.Trim() != "")
//{
// m_Where += (m_Where == "" ? "" : " and ") + " projectName like '%" + this.TextBox3.Text.Trim() + "%' ";
//}
// CREATOR
if (this.TextBox3.Text.Trim() != "")
{
m_Where += (m_Where == "" ? "" : " and ") + " CREATOR = '" + this.TextBox3.Text.Trim() + "' ";
}
// TaskId
if (this.TextBox4.Text.Trim() != "")
{
m_Where += (m_Where == "" ? "" : " and ") + " ZY_scrap_m.TaskId = '" + this.TextBox4.Text.Trim() + "' ";
}
// DropDownList1
if (DropDownList1.Text.Trim() != "全部")
{
if (DropDownList1.Text.Trim() == "已完成")
{
m_Where += (m_Where == "" ? "" : " and ") + " ZY_scrap_m.TaskId in (select TaskId FROM SysBpmITask WHERE FlowGuid = 'c0c0bd0a-8d95-41ae-ae60-d9d43c686618 ' AND ([Status] = '4' or [Status] = '5'))";
}
if (DropDownList1.Text.Trim() == "未完成")
{
m_Where += (m_Where == "" ? "" : " and ") + " ZY_scrap_m.TaskId in (select TaskId FROM SysBpmITask WHERE FlowGuid = 'c0c0bd0a-8d95-41ae-ae60-d9d43c686618 ' AND ([Status] <> '4' AND [Status] <> '5')) ";
}
}
// RBC04
if ((DropDownList2.Text.Trim() != "全部") && (DropDownList2.Text.Trim() != ""))
{
m_Where += (m_Where == "" ? "" : " and ") + " RBC04 = '" + DropDownList2.Text.Trim() + "' ";
}
//
//// Select
//
P_ht.H_data P_data = new P_ht.H_data();
if (m_Where.Trim() != "")
{
P_data.sql_text1 = " SELECT ZY_scrap_m.TaskId, RBC01, RBC17, RBC02, SysBpmITask.FinishDate as FinishDate, creator FROM ZY_scrap_m "
+ " LEFT JOIN SysBpmITask ON ZY_scrap_m.TaskId = SysBpmITask.TaskId where " + m_Where + " ";
}
else
{
P_data.sql_text1 = " SELECT ZY_scrap_m.TaskId, RBC01, RBC17, RBC02, SysBpmITask.FinishDate as FinishDate, creator FROM ZY_scrap_m "
+ " LEFT JOIN SysBpmITask ON ZY_scrap_m.TaskId = SysBpmITask.TaskId ";
}
Str_sql = P_data.sql_text1;
P_data.select_tables();
DataSet1 = P_data.DataSet8;
Session["ZY_scrap_m"] = this.DataSet1;
this.GridView1.DataSource = DataSet1;
this.GridView1.DataBind();
*/
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
this.DataSet2 = new System.Data.DataSet();
this.DataSet2 = (DataSet)Session["DS_temp"];
this.GridView1.DataSource = this.DataSet2;
this.GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
int i;
//执行循环,保证每条数据都可以更新
for (i = -1; i < GridView1.Rows.Count; i++)
{
//首先判断是否是数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#bcbf56'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
}
}
protected void btn_export_Click(object sender, EventArgs e)
{
//Server.Transfer("PIE_Project2.aspx");
//Response.Write("<script>window.open('PIE_Project2.aspx','_blank')</script>");
//原窗口保留,以对话框形式打开新窗口:
//Response.Write("<script>window.showModelessDialog('PIE_Project2.aspx')</script>");
//
DateTime dt1 = System.DateTime.Now;
string str_dt = string.Format("{0:yyyyMMddHHmmssffff}", dt1);
//
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentType = "application/vnd.ms-xls";
StringWriter stringWrite = new StringWriter();
HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
DataGrid dg = new DataGrid();
//dg.DataSource = ds;
this.DataSet2 = new System.Data.DataSet();
this.DataSet2 = (DataSet)Session["DS_temp"];
dg.DataSource = DataSet2;
dg.DataBind();
dg.RenderControl(htmlWrite);
//HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename="+HttpUtility.UrlEncode(excelName))
HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode("报废申请单-" + str_dt.Trim().ToString() + ".xls"));
HttpContext.Current.Response.Write(stringWrite.ToString());
HttpContext.Current.Response.End();
}
static string str_ca = "";
protected void Button1_Click(object sender, EventArgs e)
{
LayerCC.Visible = !LayerCC.Visible;
str_ca = "1";
}
protected void Button2_Click(object sender, EventArgs e)
{
LayerCC.Visible = !LayerCC.Visible;
str_ca = "2";
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
if (str_ca == "1")
{
TextBox1.Text = Calendar1.SelectedDate.ToString("yyyy-MM-dd");
LayerCC.Visible = false;
}
if (str_ca == "2")
{
TextBox2.Text = Calendar1.SelectedDate.ToString("yyyy-MM-dd");
LayerCC.Visible = false;
}
}
}
2015-11-04 报表(c#部分)(Datatable 查询,弹出日期控件,输入是否整数)的更多相关文章
- 二十六、【开源框架】EFW框架Winform前端开发之Grid++Report报表、条形码、Excel导出、图表控件
回<[开源]EFW框架系列文章索引> EFW框架源代码下载V1.2:http://pan.baidu.com/s/1hcnuA EFW框架实例源代码下载:http://pan ...
- MVC无刷新查询,PagedList分页控件使用,导出Excel
使用MVC开发也有一段时间了,总结下无刷新部分视图的使用.PagedList分页控件的使用. @using PagedList @model StaticPagedList<T> < ...
- 实现带查询功能的Combox控件
前言 ComBox 还可以实现查询功能,通过设置 ComBox 控件的 AutoCompleteSource 属性和 AutoCompleteMode 属性,可以实现从 Combox 控件中查询已存在 ...
- ASP.NET AJAX入门系列(11):在多个UpdatePanle中使用Timer控件
本文将使用Timer控件更新两个UpdatePanel控件,Timer控件将放在UpdatePanel控件的外面,并将它配置为UpdatePanel的触发器,翻译自官方文档. 主要内容 在多个Upda ...
- 从DataTable中删除不被控件支持的字段类型
DataTable dt = DB.GetDataTable(sql); //从dt中删除不被控件支持的字段类型 for (int ...
- Murano Weekly Meeting 2015.11.04
Meeting time: 2015.November.4th 1:00~2:00 Chairperson: Serg Melikyan, PTL from Mirantis Meeting sum ...
- 实现带查询功能的ComboBox控件
实现效果: 知识运用: ComboBox控件的AutoCompleteMode属性 public AutoCompleteMode AutoCompleteMode{get;set;} //属性值为枚 ...
- ASP.NETserver控件使用之Reportviewer 报表
1. Reportviewer 报表 1.1. Reportviewer控件 注:本教程附2个事例: l 演练:在本地处理模式下将数据库数据源与 ReportViewer W ...
- 在Bootstrap开发框架中使用dataTable直接录入表格行数据(2)--- 控件数据源绑定
在前面随笔<在Bootstrap开发框架中使用dataTable直接录入表格行数据>中介绍了在Web页面中使用Jquery DataTable插件进行对数据直接录入操作,这种处理能够给用户 ...
随机推荐
- SuSE Apache2 VirtualHost Build
1,linux version:openSuSE 12.1 2,add ServerName to DNS(johv.ts.com ,use the same IP) 3,mkdir /srv/www ...
- git打tag 三步骤
git status git tag publish/1.0.0 git push origin publish/1.0.0
- oracle pl sql 解锁表
select p.spid,a.serial#, c.object_name,b.session_id,b.oracle_username,b.os_user_name from v$pr ...
- Good Bye 2013
C:有点这种题的经验,先存起来相等的 D:赛后还搓了好久的代码,其实长度就100,枚举两边情况,其实A和C就涵盖了所有情况!所以到2就可以了,而且我弄出了有多少个后,和两边情况,也不知道能否或怎么凑成 ...
- JavaScript: Advanced
DOM 1. 节点 getElementsByName方法 <!DOCTYPE HTML> <html> <head> <script type=" ...
- yii框架中邮箱激活(数字签名)
控制器: //发送邮箱,激活账号 public function actionEmail() { $email=Yii::$app->request->get('em ...
- JSP文件编码
1. pageEncoding: <%@ page pageEncoding="UTF-8"%> jsp页面编码: jsp文件本身的编码 2. contentType: ...
- bzoj4137 [FJOI2015]火星商店问题
比较容易想到的做法是线段树套字典树,修改操作时在字典树上经过的节点维护一个最近被访问过的时间,这样询问操作只经过满足时间条件的节点,时间复杂度O(NlogN^2)但是因为线段树每个节点都要套个字典树, ...
- Android 利用Service BroadcastReceiver实现小例子
Activity: package com.example.test; import android.app.Activity; import android.content.Context; imp ...
- 夺命雷公狗ThinkPHP项目之----企业网站12之文章添加的实现
我们现在就开始写文章添加了,居然是添加当然布列外,我们还是要先讲模版搞定再说被: <!doctype html> <html> <head> <meta ch ...