Пример #1
0
        protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e)
        {

            DropDownList dlist = DetailsView1.FindControl("ddlDepartment") as DropDownList;
            TextBox txtName = DetailsView1.FindControl("txtLoginName") as TextBox;
            TextBox txtPwd = DetailsView1.FindControl("txtPassword") as TextBox;
            CheckBox chkSuper = DetailsView1.FindControl("chkSuperAdmin") as CheckBox;

            if (dlist == null || txtName == null || txtPwd == null || chkSuper == null)
            {
                Response.Write("出错,不能获取相关控件");
                return;
            }
            int did=int.Parse(dlist.SelectedValue);
          
            AdminUserInfo a = new AdminUserInfo();
            a.LoginName = txtName.Text;
            a.Password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtPwd.Text, "SHA1"); 
            a.DepartmentID = did;
            a.IsSuperAdmin = chkSuper.Checked;
            AdminUser.InsertAdminUser(a);
           this. ClientScript.RegisterStartupScript(this.GetType(), "Hint", "<script>alert('成功添加管理员信息')</script>");
            DetailsView1.Visible = false;
            GridView1.DataBind();
            e.Cancel = true;
        }
Пример #2
0
 /// <summary>
 /// 删除一个管理员用户
 /// </summary>
 /// <param name="a"></param>
  public static void DeleteAdminUser(AdminUserInfo a,ExamDbDataContext dc)
  {
      AttachInfo<AdminUserInfo>(dc.AdminUserInfo,a);
      dc.AdminUserInfo.DeleteOnSubmit(a);
      dc.SubmitChanges();        
  }
Пример #3
0
 /// <summary>
 /// 更新管理员用户信息
 /// </summary>
 /// <param name="a"></param>
 public static void UpdateAdminUser(AdminUserInfo a)
 {
     ExamDbDataContext dc = DataAccess.CreateDBContext();
     AttachInfo<AdminUserInfo>(dc.AdminUserInfo, a);
     dc.SubmitChanges();
 }
Пример #4
0
 /// <summary>
 /// 添加一个管理员用户
 /// </summary>
 /// <param name="a"></param>
  public static void InsertAdminUser(AdminUserInfo a)
  {
      ExamDbDataContext dc = DataAccess.CreateDBContext();
      dc.AdminUserInfo.InsertOnSubmit(a);
      dc.SubmitChanges();
     
  }
Пример #5
0
		private void detach_AdminUserInfo(AdminUserInfo entity)
		{
			this.SendPropertyChanging();
			entity.RoleInfo = null;
		}
Пример #6
0
		private void attach_AdminUserInfo(AdminUserInfo entity)
		{
			this.SendPropertyChanging();
			entity.DepartmentInfo = this;
		}