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 PlanTask : System.Web.UI.Page { LYS.UserData1 myud = new LYS.UserData1(); // string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + HttpContext.Current.Server.MapPath("~\\App_Data\\ZY.mdb"); protected void Page_Load(object sender, EventArgs e) { DDLXQ.Items.Add(getCurrentXQ("E")); TextBox2.Text = Session["Username"].ToString(); for (int i = 1; i <= 20; i++) { DDLZC.Items.Add("第"+i.ToString()+"周"); } } protected void Button1_Click(object sender, EventArgs e) { if (DD.Text.Trim().Length == 0 || TaskTitle.Text.Trim().Length == 0 || DDLXQ.SelectedValue.Trim().Length == 0 || DDLZC.SelectedValue.Trim().Length == 0 || TextBox2.Text.Trim().Length == 0 || TaskContent.Text.Trim().Length==0) { Response.Write(""); } else { //检查是否有同样sql="SELECT * FROM Pengfeng where csid="&request.Form("CSID")&" and 评价人='"&request.Form("MyName1")&"' and 评价组='"&request.Form("MyName2")&"'" string sql = "select * from PlanSet where 周次='" + DDLZC.SelectedValue.Trim() + "' and 任务主题='" + TaskTitle.Text.Trim() + "' and 任务内容='" + TaskContent.Text.Trim() +"'"; //Response.Write(Convert.ToDateTime(ZJ.Text).ToShortDateString()); //Response.Write(sql); //Response.End(); if (myud.CheckRecord(sql)) { Response.Write(""); //Response.Write(""); } else { SqlConnection objConn = new SqlConnection(myud.ConnString()); objConn.Open(); SqlDataAdapter objcmd = new SqlDataAdapter(); objcmd.SelectCommand = new SqlCommand("select * from PlanSet", objConn); SqlCommandBuilder objtable = new SqlCommandBuilder(objcmd); DataSet ds = new DataSet(); objcmd.Fill(ds, "PlanSet"); objConn.Close(); DataTable dt = ds.Tables["PlanSet"]; DataRow dtrow = dt.NewRow(); dtrow[0] = DBNull.Value; dtrow["学期"] = DDLXQ.SelectedValue.Trim().ToString(); dtrow["周次"] = DDLZC.SelectedValue.Trim().ToString(); //系部 dtrow["安排者"] = TextBox2.Text.Trim(); //课程名 dtrow["任务主题"] = TaskTitle.Text.Trim(); // dtrow["任务内容"] = TaskContent.Text.Trim(); // dtrow["所在部门"] = XB.SelectedValue.Trim(); //班级 dtrow["星期"] = XQ.Text; //星期 dtrow["节次"] = JC.Text; //节次 dtrow["地点"] = DD.Text; //上课地点 dt.Rows.Add(dtrow); objcmd.Update(ds, "PlanSet"); Response.Write(""); } } } //获得当前学期 public string getCurrentXQ(string EC) { System.DateTime currentTime = System.DateTime.Now; int strYear = Convert.ToInt32(currentTime.Year.ToString()); int strMonth = Convert.ToInt32(currentTime.Month.ToString()); string xq = "", xq1 = ""; if (strMonth > 1 && strMonth < 8) { xq = (strYear - 1).ToString() + "-" + strYear.ToString() + "年度第2学期"; xq1 = strYear.ToString() + "春"; } else { xq = strYear.ToString() + "-" + (strYear + 1).ToString() + "年度第1学期"; xq1 = strYear.ToString() + "秋"; } if (strMonth < 2) { xq = (strYear - 1).ToString() + "-" + strYear.ToString() + "年度第1学期"; xq1 = (strYear - 1).ToString() + "秋"; } if (EC == "E") { return xq; } else { return xq1; } } }