Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     admin = Session["LoginAdmin"] as Model.Admin;
     if(admin==null)
     {
         admin=new Model.Admin();
     }
 }
Ejemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Model.Admin admin = (Model.Admin)Session["admin"];
     if (admin == null)
     {
         Response.Redirect("Login.aspx");
     }
     else
     {
         AdminName.Text = admin.Username;
         //是否是第一次请求,防止缓存
         if (!IsPostBack)
         {
             UpdatePage();
         }
     }
 }
Ejemplo n.º 3
0
 public int AddAdmin(string name, string pwd)
 {
     try
     {
         Admin newAdmin = new Admin();
         newAdmin.Name = name;
         Md5Helper md5 = new Md5Helper();
         newAdmin.Password = md5.ConvertToMd5(pwd);
         context.AddToAdmin(newAdmin);
         context.SaveChanges();
         return 1;
     }
     catch
     {
         return 0;
     }
 }
Ejemplo n.º 4
0
        public bool isExistence(Model.Admin admin, out string msg)
        {
            string sql = "select psw from student where id = @id and id_card = @pid";

            SqlParameter[] paras = new SqlParameter[]
            {
                new SqlParameter("@id", admin.Uid),
                new SqlParameter("@pid", admin.Pid)
            };
            string psw = (string )SqlDbHelper.ExecuteScalar(sql.ToString(), CommandType.Text, paras);

            if (psw != null)
            {
                msg = psw;
                return(true);
            }
            msg = "";
            return(false);
        }
Ejemplo n.º 5
0
        public bool getPassword(Model.Admin ad, out string msg)
        {
            string psd = "";

            if (admin.isExistence(ad, out psd))
            {
                if (SendEmail("*****@*****.**", ad.Email, "zjy8200.", null, null, psd))
                {
                    msg = "密码发送成功";
                }
                else
                {
                    msg = "密码发送失败";
                }
                return(true);
            }
            else
            {
                msg = "信息错误";
            }
            return(false);
        }
Ejemplo n.º 6
0
 public ActionResult Create(Admin admin)
 {
     CreateDropDown();
     try
     {
         UpdateModel(admin);
         if (ModelState.IsValid)
         {
             admin.Status = true;
             base.dbAdmin.Insert(admin);
             base.SetUserIDForAudit();
             base.dbAudit.Add("User has created a new admin account");
             return RedirectToAction("Index");
         }
         return View();
     }
     catch (Exception ex)
     {
         ViewBag.ErrorMessage = MessageBox.Error(ex.Message);
         return View();
     }
 }
Ejemplo n.º 7
0
        public ActionResult Edit(Admin admin, int id)
        {
            SetDropDown(admin);
            try
            {
                UpdateModel(admin);
                if (ModelState.IsValid)
                {
                    base.dbAdmin.Update(admin, id);
                    base.SetUserIDForAudit();
                    base.dbAudit.Edit("User has updated an admin account record");
                    return RedirectToAction("Index");
                }

                return View(admin);
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = MessageBox.Error(ex.Message);
                return View(admin);
            }
        }
Ejemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AdminBLL adminbll = new AdminBLL();

        Model.Admin myadmin = new Model.Admin();
        myadmin.Username = Request.Form["admin_id"].ToString();                                                      //管理员名
        string str_psw = Request.Form["admin_pwd"].ToString();                                                       //密码

        string new_psw = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str_psw, "MD5"); //加密

        myadmin.Password = new_psw;

        DataSet ds = adminbll.getAdmin(myadmin);

        if (ds.Tables[0].Rows.Count > 0)
        {
            Response.Write("success");
        }
        else
        {
            Response.Write("psw_fail");
        }
    }
Ejemplo n.º 9
0
        // sets parameters for insert/update
        private Dictionary<string, object> SetParams(Admin department)
        {
            Dictionary<string, object> result = new Dictionary<string, object>();

            result.Add("@userName", department.Username);
            result.Add("@userPassword", department.Password);
            result.Add("@userStatus", department.Status);
            result.Add("@userTypeID", department.RoleID);
            result.Add("@firstName", department.Firstname);
            result.Add("@lastName", department.Lastname);
            result.Add("@middleName", department.Middlename);
            return result;
        }
Ejemplo n.º 10
0
 public void Update(Admin department, int id)
 {
     ExecuteNonQuery(QueryBuilder.Update(_tableName, TargetFields, id, _pkField), SetParams(department));
 }
Ejemplo n.º 11
0
 public void Insert(Admin department)
 {
     ExecuteNonQuery(QueryBuilder.Insert(_tableName, TargetFields), SetParams(department));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 创建新的 Admin 对象。
 /// </summary>
 /// <param name="id">ID 属性的初始值。</param>
 /// <param name="name">Name 属性的初始值。</param>
 /// <param name="password">Password 属性的初始值。</param>
 public static Admin CreateAdmin(global::System.Int32 id, global::System.String name, global::System.String password)
 {
     Admin admin = new Admin();
     admin.ID = id;
     admin.Name = name;
     admin.Password = password;
     return admin;
 }
 partial void InsertAdmin(Admin instance);
Ejemplo n.º 14
0
 private void SetDropDown(Admin admin)
 {
     ViewBag.Select = new SelectList(dbRoles.GetAllRoles, "ID", "Name", admin.RoleID);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// 用于向 Admin EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToAdmin(Admin admin)
 {
     base.AddObject("Admin", admin);
 }
 partial void UpdateAdmin(Admin instance);
Ejemplo n.º 17
0
 public void AdminEdited(Admin admin)
 {
     db.Entry(admin).State = EntityState.Modified;
     db.SaveChanges();
 }
 partial void DeleteAdmin(Admin instance);