protected void Page_Load(object sender, EventArgs e) { addtype.Items.Clear(); deltype.Items.Clear(); deltype.Items.Insert(0, new ListItem("请选择类别", "0")); addtype.Items.Insert(0, new ListItem("请选择类别", "0")); string connStr = "Server=KEVINDING; Database=BczQg; uid=sa; pwd=1111"; string sql = "select LT_NAME from LecturerType"; SqlConnection conn = new SqlConnection(connStr); conn.Open(); SqlCommand con = new SqlCommand(sql, conn); con.CommandType = System.Data.CommandType.Text; SqlDataReader sdr = con.ExecuteReader(); while (sdr.Read()) { addtype.Items.Add(sdr["LT_NAME"].ToString()); deltype.Items.Add(sdr["LT_NAME"].ToString()); } BLL_Lecturer bl = new BLL_Lecturer(); list.DataSource = bl.Select(); list.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { BCZWeb.Views.adminLog al = new BCZWeb.Views.adminLog(); Lecturer lt = new Lecturer(); BLL_Lecturer blt = new BLL_Lecturer(); lt.L_ID = lt.L_ID; lt.L_NAME = al.Session["name"].ToString(); lt.L_PASS = al.Session["pass"].ToString(); blt.SelectLecturer(lt); adminId.Text = lt.L_ID.ToString(); adminType.Text = lt.L_TYPE.ToString(); time.Text = lt.L_VDATE.ToString(); account.Text = al.Session["name"].ToString(); }
protected void btnlog_Click(object sender, EventArgs e) { BLL_Lecturer log = new BLL_Lecturer(); string pass = FormsAuthentication.HashPasswordForStoringInConfigFile(apwd.Text, "MD5"); log.log(admin.Text, pass); if (log.log(admin.Text, pass)) { Session["name"] = admin.Text; Session["pass"] = pass; Response.Write("<script>window.location.href ='admin.aspx';</script>"); } else { Response.Write("<script>alert('用户名或密码错误!');history.go(-1);</script>"); } }
protected void del_Click(object sender, EventArgs e) { try { BLL_Lecturer del = new BLL_Lecturer(); Lecturer lt = new Lecturer(); lt.L_ID = Convert.ToInt32(aid.Text); lt.L_NAME = daname.Text; lt.L_TYPE = deltype.SelectedIndex; if (del.DeleteLecturer(lt) > 0) { Response.Write(@"<script>alert('删除成功!');location.reload();</script>"); } else { Response.Write(@"<script>alert('删除失败!');history.go(-1);</script>"); } } catch { Response.Write(@"<script>alert('删除失败!');history.go(-1);</script>"); } }
protected void add_Click(object sender, EventArgs e) { try { BLL_Lecturer add = new BLL_Lecturer(); Lecturer lt = new Lecturer(); lt.L_NAME = aname.Text; lt.L_PASS = FormsAuthentication.HashPasswordForStoringInConfigFile(apwd.Text, "MD5"); lt.L_TYPE = addtype.SelectedIndex; lt.L_VDATE = DateTime.Now; if (add.AddLecturer(lt) > 0) { Response.Write(@"<script>alert('添加成功!');location.reload();</script>"); } else { Response.Write("<script>alert('添加失败');history.go(-1);</script>"); } } catch { Response.Write(@"<script>alert('添加失败!');history.go(-1);</script>"); } }
protected void save_Click(object sender, EventArgs e) { try { Lecturer lt = new Lecturer(); lt.L_ID = Convert.ToInt32(adminId.Text); lt.L_NAME = account.Text; lt.L_PASS = FormsAuthentication.HashPasswordForStoringInConfigFile(passwd.Text, "MD5"); BLL_Lecturer update = new BLL_Lecturer(); update.UpdateLecturer(lt); if (update.UpdateLecturer(lt) > 0) { Response.Write(@"<script>alert('更新成功!');</script>"); } else { Response.Write(@"<script>alert('更新失败!');history.go(-1);</script>"); } } catch { Response.Write(@"<script>alert('更新失败!');history.go(-1);</script>"); } }