using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.OleDb; using System.Data.Sql; using System.Data.SqlClient; public partial class AddOther : System.Web.UI.Page { LYS.UserData1 myud = new LYS.UserData1(); // int id; string connectionString = "data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\\MYDBSQL.mdf;User Instance=true"; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ZJ.Text = DateTime.Now.ToLongDateString().ToString(); } TextBox1.Text = Session["Username"].ToString(); } protected void Button1_Click(object sender, EventArgs e) { try { string DDXm = TextBox1.Text.Trim(); //督导姓名 string DDZJ = ZJ.Text.Trim(); //督导时间 string DDXMM = DropDProg.SelectedValue.Trim();//督导项目名 //检查是否有同样sql="SELECT * FROM Pengfeng where csid="&request.Form("CSID")&" and 评价人='"&request.Form("MyName1")&"' and 评价组='"&request.Form("MyName2")&"'" string sql = "select * from OthProg where 督导姓名='" + DDXm + "' and 督导项目名='" + DDXMM.Trim() + "' and 督导地点='" + DD.Text.Trim() + "' and 星期='" + XQ.SelectedValue.Trim()+ "' and 节次='" + JC.SelectedValue.Trim() + "' and 督导时间='" + Convert.ToDateTime(DDZJ).ToShortDateString() + "'"; //Response.Write(Convert.ToDateTime(ZJ.Text).ToShortDateString()); //Response.Write(sql); //Response.End(); if (myud.CheckRecord(sql)) { Response.Write(""); //Response.Write(""); } else { //Response.Write(""); SqlConnection objConn = new SqlConnection(connectionString); objConn.Open(); SqlDataAdapter objcmd = new SqlDataAdapter(); objcmd.SelectCommand = new SqlCommand("select * from OthProg", objConn); SqlCommandBuilder objtable = new SqlCommandBuilder(objcmd); DataSet ds = new DataSet(); objcmd.Fill(ds, "OthProg"); objConn.Close(); DataTable dt = ds.Tables["OthProg"]; DataRow dtrow = dt.NewRow(); // dtrow[0] = DBNull.Value; dtrow["系部"] = XB.SelectedValue; //系部 dtrow["督导姓名"] = DDXm;//督导姓名 dtrow["督导项目名"] = DDXMM; //督导项目名 dtrow["督导时间"] = DDZJ; dtrow["星期"] = XQ.Text; //星期 dtrow["节次"] = JC.Text; //节次 dtrow["督导地点"] = DD.Text; //督导地点 dtrow["督导内容"] = TextBox5.Text;//督导内容 dtrow["参与人员"] = BJ.Text;//参与人员 dtrow["建议或结果"] = TextBox2.Text;//参与人员 dtrow["备注"] = PF.Text;//备注 dt.Rows.Add(dtrow); objcmd.Update(ds, "OthProg"); Response.Write(""); } } catch (Exception ex) { Response.Write(""); } finally { } } protected void Button2_Click(object sender, EventArgs e) { Response.Redirect("DispUPlist.aspx"); } }