批量补差

来源:互联网 发布:轩辕剑天使进阶数据 编辑:程序博客网 时间:2024/04/19 14:40

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data.Sql;

using System.Data.SqlClient;

using System.Configuration;

using System.Data;

using System.Text.RegularExpressions;


public partial class Default3 : System.Web.UI.Page

{

    bool loadflag = false;

    private string DataFormatString;


    ////记录房屋面积的变量,用来进行差异率的计算和数据库更新的数据

    //String unit_area_jianzhu = "";

    //String unit_area_taonei = "";


    //GRIDVIEW数据源

    DataTable dt = new DataTable();


    protected void Page_Load(object sender, EventArgs e)

    {

        //if (loadflag == false)

        //{

        //    //设置为不可见

        //    VisibleFalse();

        //    loadflag = true;

        //}


        


    }

    //读取项目信息

    protected void Button1_Click(object sender, EventArgs e)

    {

        Button3.Enabled = false;

        DropDownList1.Items.Clear();

        DropDownList1.Items.Add("");

        //设置为可见

        Visibletrue();

        String constr = ConfigurationManager.ConnectionStrings["mycon"].ConnectionString;

        String querystr = "select project_name from t_sys_project";


        SqlConnection sqlcon = new SqlConnection(constr);


        try

        {

            sqlcon.Open();

            SqlCommand sc = new SqlCommand(querystr, sqlcon);

            SqlDataReader sr = sc.ExecuteReader();

            if (sr.HasRows)

            {

                while (sr.Read())

                {

                    DropDownList1.Items.Add(sr[0].ToString());

                }

                DropDownList1.DataBind();

            }


            sqlcon.Close();


        }

        catch (Exception ex)

        {

            Label7.Text = "提示信息:" + Label7.Text + "项目错误" + ex.ToString();

        }

    }



    //读取楼号信息

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)

    {

        DropDownList2.Items.Clear();

        DropDownList2.Items.Add("");


        String constr = ConfigurationManager.ConnectionStrings["mycon"].ConnectionString;

        String querystr = "SELECT t_hou_building.building_name from t_hou_structon  right join t_hou_building  on t_hou_structon.structon_guid=t_hou_building.structon_guid     RIGHT JOIN t_sys_project ON t_hou_structon.parent_structon_guid = t_sys_project.PROJECT_ID     where t_hou_structon.inactive<>1 AND t_sys_project.PROJECT_NAME  = '" + DropDownList1.SelectedValue.ToString() + "' ORDER BY t_hou_building.building_name ";


        SqlConnection sqlcon = new SqlConnection(constr);


        try

        {

            sqlcon.Open();

            SqlCommand sc = new SqlCommand(querystr, sqlcon);

            SqlDataReader sr = sc.ExecuteReader();

            if (sr.HasRows)

            {

                while (sr.Read())

                {

                    DropDownList2.Items.Add(sr[0].ToString());

                }

                DropDownList2.DataBind();

            }


            sqlcon.Close();


        }

        catch (Exception ex)

        {

            Label7.Text = "提示信息:" + Label7.Text + "楼号错误" + ex.ToString();

        }

    }


    public void VisibleFalse()

    {

        Label1.Visible = false;

        Label2.Visible = false;

        Label3.Visible = false;

        Label4.Visible = false;

        Label5.Visible = false;

        Label6.Visible = false;

        Label7.Visible = false;

        DropDownList1.Visible = false;

        DropDownList2.Visible = false;

        DropDownList3.Visible = false;

        DropDownList4.Visible = false;

        DropDownList5.Visible = false;

        DropDownList6.Visible = false;


    }


    public void Visibletrue()

    {

        Label1.Visible = true;

        Label2.Visible = true;

        Label3.Visible = true;

        Label4.Visible = true;

        Label5.Visible = true;

        Label6.Visible = true;

        Label7.Visible = true;

        DropDownList1.Visible = true;

        DropDownList2.Visible = true;

        DropDownList3.Visible = true;

        DropDownList4.Visible = true;

        DropDownList5.Visible = true;

        DropDownList6.Visible = true;


    }



    //读取单元信息

    protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)

    {

        DropDownList3.Items.Clear();

        DropDownList3.Items.Add("");

        String XiangmuName = DropDownList1.SelectedValue.ToString();


        String constr = ConfigurationManager.ConnectionStrings["mycon"].ConnectionString;

        String querystr = "SELECT distinct unit.COLUMN_NAME FROM t_hou_unit unit RIGHT JOIN t_hou_building  building ON building.STRUCTON_GUID = unit.STRUCTON_GUID RIGHT JOIN  (SELECT t_hou_building.structon_guid ,t_hou_building.building_name ,t_sys_project.PROJECT_NAME from t_hou_structon  right join t_hou_building  on t_hou_structon.structon_guid=t_hou_building.structon_guid     RIGHT JOIN t_sys_project ON t_hou_structon.parent_structon_guid = t_sys_project.PROJECT_ID  WHERE  t_sys_project.PROJECT_NAME = '" + DropDownList1.SelectedValue.ToString() + "' )t1 ON t1.structon_guid = unit.structon_guid  where building.building_name = '" + DropDownList2.SelectedValue.ToString() + "'   and column_name <> '商铺' and unit.INACTIVE=0 order by unit.COLUMN_NAME DESC";


        SqlConnection sqlcon = new SqlConnection(constr);


        try

        {

            sqlcon.Open();

            SqlCommand sc = new SqlCommand(querystr, sqlcon);

            SqlDataReader sr = sc.ExecuteReader();

            if (sr.HasRows)

            {

                while (sr.Read())

                {

                    DropDownList3.Items.Add(sr[0].ToString());

                }

                DropDownList3.DataBind();

            }


            sqlcon.Close();


        }

        catch (Exception ex)

        {

            Label7.Text = "提示信息:" + Label7.Text + "单元号错误" + ex.ToString();

        }

    }


    //读取单元下级信息

    protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)

    {

        DropDownList4.Items.Clear();

        DropDownList4.Items.Add("");

        String XiangmuName = DropDownList1.SelectedValue.ToString();


        String constr = ConfigurationManager.ConnectionStrings["mycon"].ConnectionString;

        String querystr = "SELECT distinct order_no FROM t_hou_unit unit RIGHT JOIN t_hou_building  building ON building.STRUCTON_GUID = unit.STRUCTON_GUID RIGHT JOIN  (SELECT t_hou_building.structon_guid ,t_hou_building.building_name ,t_sys_project.PROJECT_NAME from t_hou_structon  right join t_hou_building  on t_hou_structon.structon_guid=t_hou_building.structon_guid     RIGHT JOIN t_sys_project ON t_hou_structon.parent_structon_guid = t_sys_project.PROJECT_ID  WHERE  t_sys_project.PROJECT_NAME = '" + DropDownList1.SelectedValue.ToString() + "' )t1 ON t1.structon_guid = unit.structon_guid  where building.building_name = '" + DropDownList2.SelectedValue.ToString() + "'  and column_name <> '商铺'  and unit.INACTIVE=0 order by order_no";


        SqlConnection sqlcon = new SqlConnection(constr);


        try

        {

            sqlcon.Open();

            SqlCommand sc = new SqlCommand(querystr, sqlcon);

            SqlDataReader sr = sc.ExecuteReader();

            if (sr.HasRows)

            {

                while (sr.Read())

                {

                    DropDownList4.Items.Add(sr[0].ToString());

                }

                DropDownList4.DataBind();

            }


            sqlcon.Close();


        }

        catch (Exception ex)

        {

            Label7.Text = "提示信息:" + Label7.Text + "单元下级错误" + ex.ToString();

        }

    }

    //读取房间信息

    protected void DropDownList4_SelectedIndexChanged(object sender, EventArgs e)

    {

        DropDownList5.Items.Clear();

        DropDownList6.Items.Clear();

        DropDownList5.Items.Add("");

        DropDownList6.Items.Add("");

        String XiangmuName = DropDownList1.SelectedValue.ToString();


        String constr = ConfigurationManager.ConnectionStrings["mycon"].ConnectionString;

        String querystr = "select tunit.unit_name  from  t_sal_reservation tres left join t_hou_unit tunit on tunit.unit_guid=tres.unit_guid and tunit.inactive=0 left join t_hou_structon tstru on  tstru.structon_guid=tunit.structon_guid and tstru.inactive=0 left join t_hou_building tbuild on tstru.structon_guid=tbuild.structon_guid  left join t_sys_project tproj on tproj .project_id=tstru.project_guid left join t_cus_customer tper on tper.customer_guid=tres.customer_guid left join t_hou_unit_info tinfo on tinfo.unit_guid=tunit.unit_guid left join t_sal_area_expiation tae on tae.reservation_guid=tres.reservation_guid and tae.inactive=0 left join t_sal_process tproc on tproc.unit_guid = tres.unit_guid where tres.inactive=0  and tproc.status_id=5  AND project_name = '" + DropDownList1.SelectedValue.ToString() + "' and building_name = '" + DropDownList2.SelectedValue.ToString() + "' and column_name = '" + DropDownList3.SelectedValue.ToString() + "' AND tunit.order_no = '" + DropDownList4.SelectedValue.ToString() + "'  and column_name <> '商铺'  and   tae.aduit_user_guid is null   order by cast(unit_name  as int) ,project_name,building_name ";


        SqlConnection sqlcon = new SqlConnection(constr);


        try

        {

            sqlcon.Open();

            SqlCommand sc = new SqlCommand(querystr, sqlcon);

            SqlDataReader sr = sc.ExecuteReader();

            if (sr.HasRows)

            {

                while (sr.Read())

                {

                    DropDownList5.Items.Add(sr[0].ToString());

                    DropDownList6.Items.Add(sr[0].ToString());

                }

                DropDownList5.DataBind();

                DropDownList6.DataBind();

            }


            sqlcon.Close();


        }

        catch (Exception ex)

        {

            Label7.Text = "提示信息:" + Label7.Text + "单元下级错误" + ex.ToString();

        }

    }


    protected void DropDownList6_SelectedIndexChanged(object sender, EventArgs e)

    {

        //Label7.Text = "选择的房间信息为: " + DropDownList1.SelectedValue + " " + DropDownList2.SelectedValue

        //    + " " + DropDownList3.SelectedValue + " 第" + DropDownList4.SelectedValue + "列\n";

        //for (int i = DropDownList5.SelectedIndex; i <= DropDownList6.SelectedIndex; i++)

        //{

        //    Label7.Text = Label7.Text + DropDownList6.Items[i].Value + "  ";

        //}

        //Label7.Text = Label7.Text + " 号房间。";

        Button3.Enabled = true;


    }


    protected void Button3_Click(object sender, EventArgs e)

    {


        Label23.Text = "";

        String constr = ConfigurationManager.ConnectionStrings["mycon"].ConnectionString;

        SqlConnection sqlcon = new SqlConnection(constr);

        

        

        

        

        try

        {

            DataTable dt = new DataTable();

            dt.Columns.Add("项目名称");

            dt.Columns.Add("楼号");

            dt.Columns.Add("单元号");

            dt.Columns.Add("房间号");

            dt.Columns.Add("客户名称");

            dt.Columns.Add("认购日期");

            dt.Columns.Add("签约日期");

            dt.Columns.Add("合同建筑面积(㎡)");

            dt.Columns.Add("合同套内面积(㎡)");

            dt.Columns.Add("合同单价");

            dt.Columns.Add("合同总价");


            for (int i = DropDownList5.SelectedIndex; i <= DropDownList6.SelectedIndex; i++)

            {

                

                sqlcon.Open();

                String querystr = "select  CAST(tproj.project_id AS VARCHAR(32)) , tproj.project_name, tbuild.building_name, tunit.unit_guid,tunit.column_name ,tunit.order_no,tunit.unit_name, tper.customer_name as name, tinfo.construction_area, tres.reservation_guid, tres.amount, isnull(tae.aduit_user_guid,'-1') as exId, convert(varchar(10),tres.reservation_date,120) as rdate, convert(varchar(10),tres.sign_contract_date,120) as cdate, tres.construction_area_price, tinfo.use_area,    case    when tunit.column_name is not null then tunit.sales_code_prefix + '-' + tunit.column_name + '-' +tunit.unit_name         else tunit.sales_code_prefix + '-' + tunit.unit_name            end as roomCode  from  t_sal_reservation tres left join t_hou_unit tunit on tunit.unit_guid=tres.unit_guid and tunit.inactive=0 left join t_hou_structon tstru on  tstru.structon_guid=tunit.structon_guid and tstru.inactive=0 left join t_hou_building tbuild on tstru.structon_guid=tbuild.structon_guid  left join t_sys_project tproj on tproj .project_id=tstru.project_guid left join t_cus_customer tper on tper.customer_guid=tres.customer_guid left join t_hou_unit_info tinfo on tinfo.unit_guid=tunit.unit_guid left join t_sal_area_expiation tae on tae.reservation_guid=tres.reservation_guid and tae.inactive=0 left join t_sal_process tproc on tproc.unit_guid = tres.unit_guid where tres.inactive=0  and tproc.status_id=5  AND project_name = '" + DropDownList1.SelectedValue + "' and building_name = '" + DropDownList2.SelectedValue + "' and column_name = '" + DropDownList3.SelectedValue + "' AND tunit.order_no = '" + DropDownList4.SelectedValue + "'  AND unit_name = " + DropDownList6.Items[i].Value + " order by cast(unit_name  as int) ,project_name,building_name";

                SqlCommand sc = new SqlCommand(querystr, sqlcon);

                SqlDataReader sr = sc.ExecuteReader();

                

                if (sr.HasRows)

                {

                    while (sr.Read())

                    {

                        

                        DataRow dr = dt.NewRow();

                        dr["项目名称"] = sr["project_name"].ToString();

                        dr["楼号"] = sr["building_name"].ToString();

                        dr["单元号"] = sr["column_name"].ToString();

                        dr["房间号"] = sr["unit_name"].ToString();

                        dr["客户名称"] = sr["name"].ToString();

                        dr["认购日期"] = sr["rdate"].ToString();

                        dr["签约日期"] = sr["cdate"].ToString();                        

                        dr["合同建筑面积(㎡)"] = sr["construction_area"].ToString();

                        dr["合同套内面积(㎡)"] = sr["use_area"].ToString();

                        dr["合同单价"] = String.Format("{0:N}",Convert.ToDecimal(sr["construction_area_price"]));

                        dr["合同总价"] = String.Format("{0:N}",Convert.ToDecimal(sr["amount"].ToString()));

                        dt.Rows.Add(dr);


                    }

                }


                sqlcon.Close();

            }


            


            GridView1.DataSource = dt;

            GridView1.DataBind();


            for (int i = dt.Rows.Count - 1; i >= 1; i--)

            {

                DataRow dr1 = dt.Rows[i];

                DataRow dr2 = dt.Rows[i - 1];

                if (!dr1["合同建筑面积(㎡)"].Equals(dr2["合同建筑面积(㎡)"]))

                {

                    Label23.Text = Label23.Text + "选取房屋的建筑面积不一样,不能批量操作。";

                    Button6.Enabled = false;

                }

                 if (!dr1["合同套内面积(㎡)"].Equals(dr2["合同套内面积(㎡)"]))

                {

                    Label23.Text = Label23.Text + "选取房屋的套内面积不一样,不能批量操作。";

                    Button6.Enabled = false;

                }

                // if (dr1["合同建筑面积(㎡)"].Equals(dr2["合同建筑面积(㎡)"]))

                //{

                //    unit_area_jianzhu = dr1["合同建筑面积(㎡)"].ToString();

                //}

                // if (dr1["合同套内面积(㎡)"].Equals(dr2["合同套内面积(㎡)"]))

                //{

                //    unit_area_taonei = dr1["合同套内面积(㎡)"].ToString();

                //}

                

            }


            Button8.Focus();


            


        }

        catch (Exception ex)

        {

            Label23.Text = "房间信息错误:" + ex.ToString();

        }


        

    }

    protected void TextBox1_TextChanged(object sender, EventArgs e)

    {

        //TextBox3.Text = (Convert.ToDouble(TextBox1.Text) - Convert.ToDouble(unit_area_jianzhu)).ToString();

        TextBox3.Text = (Convert.ToDouble(TextBox1.Text) - Convert.ToDouble(GridView1.Rows[0].Cells[7].Text)).ToString();

        TextBox4.Text = (Convert.ToDouble(TextBox3.Text) / Convert.ToDouble(GridView1.Rows[0].Cells[7].Text)*100).ToString().Substring(0,5);

        Button8.Focus();

        

        

    }

    protected void TextBox2_TextChanged(object sender, EventArgs e)

    {

        TextBox5.Text = (Convert.ToDouble(TextBox2.Text) - Convert.ToDouble(GridView1.Rows[0].Cells[8].Text)).ToString();

        TextBox6.Text = (Convert.ToDouble(TextBox5.Text) / Convert.ToDouble(GridView1.Rows[0].Cells[8].Text)*100).ToString().Substring(0,5);

        Button6.Enabled = true;

        Button8.Focus();

        

    }

    

    protected void Calendar1_SelectionChanged(object sender, EventArgs e)

    {

        TextBox8.Text = Calendar1.SelectedDate.ToShortDateString();

        Button8.Focus();

    }

    protected void Button6_Click(object sender, EventArgs e)

    {


        DataTable dt2 = new DataTable();

        dt2.Columns.Add("项目名称");

        dt2.Columns.Add("楼号");

        dt2.Columns.Add("单元号");

        dt2.Columns.Add("房间号");

        dt2.Columns.Add("客户名称");

        dt2.Columns.Add("认购日期");

        dt2.Columns.Add("签约日期");

        dt2.Columns.Add("合同建筑面积(㎡)");

        dt2.Columns.Add("合同套内面积(㎡)");

        dt2.Columns.Add("合同单价");

        dt2.Columns.Add("合同总价");

        dt2.Columns.Add("实测建筑面积(㎡)");

        dt2.Columns.Add("实测套内面积(㎡)");

        dt2.Columns.Add("建筑面积差异(㎡)");

        dt2.Columns.Add("建筑面积差异率(%)");

        dt2.Columns.Add("套内面积差异(㎡)");

        dt2.Columns.Add("套内面积差异率(%)");

        dt2.Columns.Add("应补差款");


        for (int i = 0; i < GridView1.Rows.Count  ; i++)

        {

            DataRow dr = dt2.NewRow();

            dr["项目名称"] = GridView1.Rows[i].Cells[0].Text;

            dr["楼号"] = GridView1.Rows[i].Cells[1].Text;

            dr["单元号"] = GridView1.Rows[i].Cells[2].Text;

            dr["房间号"] = GridView1.Rows[i].Cells[3].Text;

            dr["客户名称"] = GridView1.Rows[i].Cells[4].Text;

            dr["认购日期"] = GridView1.Rows[i].Cells[5].Text;

            dr["签约日期"] = GridView1.Rows[i].Cells[6].Text;

            dr["合同建筑面积(㎡)"] = GridView1.Rows[i].Cells[7].Text;

            dr["合同套内面积(㎡)"] = GridView1.Rows[i].Cells[8].Text;

            dr["合同单价"] = String.Format("{0:N}",Convert.ToDecimal(DeleteQianFenWei(GridView1.Rows[i].Cells[9].Text)));

            dr["合同总价"] = String.Format("{0:N}",Convert.ToDecimal(DeleteQianFenWei(GridView1.Rows[i].Cells[10].Text)));

            dr["实测建筑面积(㎡)"] = TextBox1.Text;

            dr["实测套内面积(㎡)"] = TextBox2.Text;

            dr["建筑面积差异(㎡)"] = TextBox3.Text;

            dr["建筑面积差异率(%)"] = TextBox4.Text;

            dr["套内面积差异(㎡)"] = TextBox5.Text;

            dr["套内面积差异率(%)"] = TextBox6.Text;

            dr["应补差款"] = String.Format("{0:N}", Convert.ToDecimal(dr["合同单价"]) * Convert.ToDecimal(dr["建筑面积差异(㎡)"]));


            dt2.Rows.Add(dr);

         

          

        }


        GridView2.DataSource = dt2;

        GridView2.DataBind();        

        Button7.Focus();


    }

    protected void Button7_Click(object sender, EventArgs e)

    {


        


        String constr = ConfigurationManager.ConnectionStrings["mycon"].ConnectionString;

        SqlConnection sqlcon = new SqlConnection(constr);

        //成功写入数据数的统计

        int count = 0;

        for (int i = 0; i < GridView2.Rows.Count; i++)

        {


            String Banliren = "销售主管";

            String Pizhunren = "销售总监";

            String expiation_guid = System.Guid.NewGuid().ToString().Substring(0, 32);

            Double Jianzhumianji = Convert.ToDouble(GridView2.Rows[i].Cells[11].Text);

            Double Yonghumianji = Convert.ToDouble(GridView2.Rows[i].Cells[12].Text);

            String Cehuidanwei = "";

            if (!TextBox7.Text.Equals("")&&TextBox7.Text.Length >= 31)

            {

                Cehuidanwei = TextBox7.Text.Substring(0,31);

            }

            else if (!TextBox7.Text.Equals("") && TextBox7.Text.Length <= 31)

            {

                Cehuidanwei = TextBox7.Text;

            }


            String Cehuiriqi = "";

            if (!TextBox8.Text.Equals(""))

            {

                Cehuiriqi = TextBox8.Text;

            }


            String Xiangmu = GridView2.Rows[i].Cells[0].Text;

            String Louhao = GridView2.Rows[i].Cells[1].Text;

            String Danyuanhao = GridView2.Rows[i].Cells[2].Text;

            String Fangjianhao = GridView2.Rows[i].Cells[3].Text;


            Double BuchaJIANZHUmianji = Convert.ToDouble(GridView2.Rows[i].Cells[13].Text);

            Double BuchajinE = Convert.ToDouble(DeleteQianFenWei(GridView2.Rows[i].Cells[17].Text));

            String Beizhu = "";

            if (!TextBox10.Text.Equals("")&&TextBox10.Text.Length >= 31)

            {

                Beizhu = TextBox10.Text.Substring(0,31);

            }

            else if (!TextBox10.Text.Equals("")&&TextBox10.Text.Length <= 31)

            {

                Beizhu = TextBox10.Text;

            }

            String Banliriqi = "";

            if (!TextBox9.Text.Equals(""))

            {

                Banliriqi = TextBox9.Text;

            }

            

            String querystr = "DECLARE @P0 nvarchar(4000),@P1 float,@P2 float,@P3 nvarchar(4000),@P4 datetime,@P5 nvarchar(4000),@P6 "

                + " nvarchar(4000),@P7 nvarchar(4000),@P8 float,@P9 float,@P10 nvarchar(4000),@p11 nvarchar(4000),@p12 nvarchar(4000),@p13 datetime "

                + " SET @P0 =  '" + expiation_guid + "' "

                + " SET @p1 = "+Jianzhumianji+" "

                + " SET @p2 = "+Yonghumianji+" "

                + " SET @p3 = '"+Cehuidanwei+"' "

                + " SET @p4 = '"+Cehuiriqi+"' "

                + " SET @p5 = (SELECT org_id FROM T_SYS_USERINFO WHERE NAME = '" + Banliren + "') "

                + " SET @p6 = (SELECT tres.reservation_guid from  t_sal_reservation tres left join t_hou_unit tunit on tunit.unit_guid=tres.unit_guid and tunit.inactive=0 left join t_hou_structon tstru on  tstru.structon_guid=tunit.structon_guid and tstru.inactive=0 left join t_hou_building tbuild on tstru.structon_guid=tbuild.structon_guid  left join t_sys_project tproj on tproj .project_id=tstru.project_guid left join t_cus_customer tper on tper.customer_guid=tres.customer_guid left join t_hou_unit_info tinfo on tinfo.unit_guid=tunit.unit_guid left join t_sal_area_expiation tae on tae.reservation_guid=tres.reservation_guid and tae.inactive=0 left join t_sal_process tproc on tproc.unit_guid = tres.unit_guid where tres.inactive=0  and tproc.status_id=5  AND project_name = '"+Xiangmu+"' and building_name = '"+Louhao+"' and column_name = '"+Danyuanhao+"'    and column_name <> '商铺'  and   tae.aduit_user_guid is null  and unit_name = "+Fangjianhao+" ) "

                + " SET @p7 = 0 "

                + " SET @p8 = "+BuchaJIANZHUmianji+" "

                + " SET @p9 = "+BuchajinE+"1 "

                + " SET @p10 = ( "

                //这里没有判断公式

                + " select t2.expiation_means_guid from t_set_expiation_precept t1 left join  t_set_expiation_means t2 on  t1.expiation_precept_guid=t2.expiation_precept_guid "

                + " where     t1.project_guid= (    SELECT project_id FROM t_sys_project WHERE project_name = '"+Xiangmu+"' "

                + "     )  and t1.ACCORDING_TYPE= 1) "

                + " SET @p11 = (SELECT org_id FROM T_SYS_USERINFO WHERE NAME = '" + Pizhunren + "') "

                + " SET @p12 = '"+Beizhu+"' "

                + " SET @p13 = '"+Banliriqi+"' "

                + " insert into  "

                + " t_sal_area_expiation(expiation_guid,construction_area,use_area,expiation_corp,expiation_date,user_guid,reservation_guid,inactive,expiation_area,expiation_amount,expiation_means_guid,aduit_user_guid, DESCRIPTION,fcurrent_date) "

                + " values( @P0 , @P1 , @P2 , @P3 , @P4 , @P5 , @P6 , @P7 , @P8 , @P9 , @P10 ,@p11,@p12,@p13) ";



            try

            {

                sqlcon.Open();

                SqlCommand sc = new SqlCommand(querystr, sqlcon);

                sc.ExecuteNonQuery();

                count++ ;

                sqlcon.Close();


                


            }

            catch (Exception ex)

            {

                Label31.Text = Label31.Text + "第" + i + "行写入数据库错误" + ex.ToString();

                break;

            }

        }


        Label31.Text = "共"+GridView2.Rows.Count+"条数据,成功写入"+count+"条数据";


        Button7.Focus();

    }

    protected void Calendar2_SelectionChanged(object sender, EventArgs e)

    {

        TextBox9.Text = Calendar2.SelectedDate.ToShortDateString();

        Button7.Focus();

    }


    public double DeleteQianFenWei(String a)

    {

        string b = null;

        for (int i = 0; i < a.Length; i++)

        {

            if (a[i] != ',')

            {

                b = b + a[i];

            }

        }

        return Convert.ToDouble(b);

    }

    protected void Calendar2_VisibleMonthChanged(object sender, MonthChangedEventArgs e)

    {

        Button7.Focus();

    }

    protected void Calendar1_VisibleMonthChanged(object sender, MonthChangedEventArgs e)

    {

        Button8.Focus();

    }

}


原创粉丝点击