protected void Button1_Click(object sender, EventArgs e) { Label1.Text = ""; string rq = rqBox1.Text.Trim(); string ks = DropDownList1.Text.Trim(); string gh = ghBox2.Text.Trim(); string sql = ""; if (rq == "") { Label1.Text = "请选择月份!"; } else { if (gh == "") { if (ks == "") { sql = "jsrq='" + rq + "'"; } else { sql = "jsrq='" + rq + "' and cyks='" + ks + "'"; } } else { sql = "jsrq = '" + rq + "' and ysgh = '" + gh + "'"; } mycon = new Sql_connecter(); DataSet ds = mycon.getzb(sql); GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } }
protected void loadks() { mycon = new Sql_connecter(); DataSet ds = mycon.getks(); if (ds != null) { DataTable dt = ds.Tables[0]; DropDownList1.DataSource = dt.DefaultView; DropDownList1.DataValueField = dt.Columns[0].ColumnName; DropDownList1.DataTextField = dt.Columns[0].ColumnName; DropDownList1.DataBind(); DropDownList1.Items.Insert(0, new ListItem("", "")); } }
protected void Button2_Click(object sender, EventArgs e) { int maxid = 0; string target = "drgsdb.dbo.fkb"; Sql_connecter mysc = new Sql_connecter(); maxid = mysc.getmaxid(target); mysc.writetoserver(myds.Tables[0], target); divState.InnerHtml += "<br>写入数据库成功!"; myds.Tables.RemoveAt(0); excelview.DataSource = null; excelview.DataBind(); int gxts = 0; gxts = mysc.createljb(maxid); divState.InnerHtml += "<br>创建链接表成功:" + gxts.ToString(); mysc.writetozb(gxts); divState.InnerHtml += "<br>写入主表成功,任务完成。"; }