2015-11-04 报表(c#部分)(Datatable 查询,弹出日期控件,输入是否整数)

时间:2021-02-23 16:13:41

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;
        }
    }

}