using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class AddRecord : System.Web.UI.Page { LYS.UserData1 myud = new LYS.UserData1(); //string ranCode = "";//HttpContext.Current.Request.QueryString["RanCode"].ToString(); /// /// 使用方法,首先从参数中得到表名,然后根据表名得到SQL语句 /// AddRecord.aspx?RanCode=Adr5332tr5454dai //班级管理表 /// /// /// protected void Page_Load(object sender, EventArgs e) { string myURL = myud.GetAddressUrl().ToString(); if (myURL.LastIndexOf("tn") <= 0) { Response.Write(""); Response.End(); } // ranCode = HttpContext.Current.Request.QueryString["tn"].ToString(); Session["TableNameSQL"] = Request.QueryString["tn"].ToString(); ; Session["addSQL"] = "select * from " + Session["TableNameSQL"].ToString(); // Session["TableNameSQL"] = "Tb_Dempent"; //Session["addSQL"] = "select * from " + Session["TableNameSQL"].ToString(); // Response.Write(Session["addSQL"].ToString()); Literal1.Text = myud.BuildAddRecordFormOK(Session["addSQL"].ToString()).ToString(); // Literal2.Text = Literal2.Text + "--" + myud.GetKeyFieldValue(3, "RanCode", ranCode, "AdminTreeGJK").ToString(); } protected void Button1_Click(object sender, EventArgs e) {// 自动添加之前自动查重 // string key1 = "用户名"; // string key2 = "工号";//myud.GetKeyFieldValue(9, "RanCode", ranCode, "AdminTreeGJK").ToString(); // string key1v=myud.GetKeyFieldName(key1, // Response.Write("Key2="+key1); //if (myud.CheckSQLRepeatRecord(SQL)) //{ // Response.Write(""); //} //for (int i = 1; i < HttpContext.Current.Request.Form.Count; i++) //{ // string name = HttpContext.Current.Request.Form.GetKey(i); // //Response.Write(name + ":
"); // if (name.IndexOf("Text") > 0 || name.IndexOf("Label") > 0) // { // if (HttpContext.Current.Request.Form[i].ToString() == key1) // { // Response.Write(HttpContext.Current.Request.Form[i].ToString() + ":"); // Response.Write(HttpContext.Current.Request.Form["MyText"+i.ToString()] + "
"); // } // if (HttpContext.Current.Request.Form[i].ToString() == key2) // { // Response.Write(HttpContext.Current.Request.Form[i].ToString() + ":"); // Response.Write(HttpContext.Current.Request.Form["MyText" + i.ToString()] + "
"); // } // } //if (name.IndexOf("Text") > 0) //{ // Response.Write("Text" + HttpContext.Current.Request.Form[i] + "
"); //} // } try { //myud.AddRecordToDB1(Session["addSQL"].ToString(), Session["TableNameSQL"].ToString(),key1,key2); //查重复,有点问题最后两个字段丢失 // string chkSQL= Session["addSQL"] +" where key1 myud.AddRecordToDB(Session["addSQL"].ToString(), Session["TableNameSQL"].ToString()); Response.Write(""); } catch (Exception ex) { Response.Write(""); } finally { } } protected void Button2_Click(object sender, EventArgs e) { // TextBox2.Text = myud.EncryptDes(TextBox1.Text); } }