Default.aspx.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data;
  8. using System.Data.OleDb;
  9. using System.Data.Sql;
  10. using System.Data.SqlClient;
  11. public partial class _Default : System.Web.UI.Page
  12. {
  13. // UserData myud = new UserData();
  14. LYS.UserData1 myud = new LYS.UserData1();
  15. // int id;
  16. string connectionString ="data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\\MYDBSQL.mdf;User Instance=true";
  17. protected void Page_Load(object sender, EventArgs e)
  18. {
  19. string myURL = myud.GetAddressUrl();
  20. // int i = 0;
  21. if (Session["Username"] == null)
  22. { Response.Redirect("LoginNew.aspx"); }
  23. string sql = "select * from DDTreeGJK where followid=0 Order by ID";
  24. TextBox1.Text = Session["Username"].ToString();
  25. ZJ.Text = DateTime.Now.ToLongDateString().ToString();
  26. //Literal1.Text = myud.DispNB("", "所属类别", "Select distinct 所属类别 from PY", 10, "Left").ToString();
  27. //Literal1.Text = myud.ViewInCurrentSWF("Select distinct(所属类别) from PY", 1).ToString();
  28. if (myURL.LastIndexOf("OP") < 0)
  29. {
  30. }
  31. else
  32. {
  33. if (Request.QueryString["OP"].ToString() == "auto")
  34. {
  35. Literal1.Text = myud.main8(sql).ToString();
  36. }
  37. }
  38. }
  39. protected void Button2_Click(object sender, EventArgs e)
  40. {
  41. Response.Redirect("DisplayPJ.aspx");
  42. }
  43. protected void Button1_Click(object sender, EventArgs e)
  44. {
  45. Boolean yn = true;
  46. if (TextBox5.Text.Trim().Length < 100)
  47. {
  48. Response.Write("<script>alert('评语太简单,字数不能少于100字!!');</script>");
  49. yn = false;
  50. Response.Write("<script>window.history.go(-1)</script>");
  51. }
  52. if (TextBox2.Text.Trim().Length < 60)
  53. {
  54. Response.Write("<script>alert('督导情况记录字数不能少于60字!!');</script>");
  55. yn = false;
  56. Response.Write("<script>window.history.go(-1)</script>");
  57. }
  58. if (DD.Text.Trim().Length == 0 || JSXM.Text.Trim().Length == 0 || BJ.Text.Trim().Length == 0 || KM.Text.Trim().Length == 0 || PF.Text.Trim().Length == 0)
  59. {
  60. Response.Write("<script>alert('请检查听课地点、教师姓名、授课班级、课程名称、评价分等内容是否填写完整!!');</script>");
  61. yn = false;
  62. Response.Write("<script>window.history.go(-1)</script>");
  63. }
  64. if(yn==true)
  65. {
  66. //检查是否有同样sql="SELECT * FROM Pengfeng where csid="&request.Form("CSID")&" and 评价人='"&request.Form("MyName1")&"' and 评价组='"&request.Form("MyName2")&"'"
  67. string sql = "select * from TKJL where 督导姓名='" + TextBox1.Text.Trim() + "' and 课程名='" + KM.Text.Trim() + "' and 教师姓名='" + JSXM.Text.Trim() + "' and 听课日期='" + Convert.ToDateTime(ZJ.Text.Trim()).ToShortDateString() + "'";
  68. //Response.Write(Convert.ToDateTime(ZJ.Text).ToShortDateString());
  69. //Response.Write(sql);
  70. //Response.End();
  71. if (myud.CheckRecord(sql))
  72. {
  73. Response.Write("<script>alert('您已经评价,不能重复对同一个人同一门课程,同一个时间进行评价!');</script>");
  74. //Response.Write("<script>window.history.back();</script>");
  75. }
  76. else
  77. {
  78. SqlConnection objConn = new SqlConnection(connectionString);
  79. objConn.Open();
  80. SqlDataAdapter objcmd = new SqlDataAdapter();
  81. objcmd.SelectCommand = new SqlCommand("select * from TKJL", objConn);
  82. SqlCommandBuilder objtable = new SqlCommandBuilder(objcmd);
  83. DataSet ds = new DataSet();
  84. objcmd.Fill(ds, "TKJL");
  85. objConn.Close();
  86. DataTable dt = ds.Tables["TKJL"];
  87. DataRow dtrow = dt.NewRow();
  88. // dtrow[0] = DBNull.Value;
  89. dtrow["教师姓名"] = JSXM.Text.ToString();//老师
  90. dtrow["系部"] = XB.Text; //系部
  91. dtrow["课程名"] = KM.Text; //课程名
  92. dtrow["督导姓名"] = TextBox1.Text; //督导姓名
  93. dtrow["听课日期"] = ZJ.Text; //听课日期
  94. dtrow["班级"] = BJ.Text; //班级
  95. dtrow["星期"] = XQ.Text; //星期
  96. dtrow["节次"] = JC.Text; //节次
  97. dtrow["上课地点"] = DD.Text; //上课地点
  98. dtrow["情况记录"] = TextBox2.Text; //督导姓名
  99. dtrow["点评评价"] = TextBox5.Text;//总评分
  100. dtrow["总评分"] = PF.Text;//总评分
  101. dt.Rows.Add(dtrow);
  102. objcmd.Update(ds, "TKJL");
  103. Response.Write("<script>alert('评价成功!')</script>");
  104. }
  105. }
  106. }
  107. }