Example #1
0
        protected void Button1_Click1(object sender, EventArgs e)
        {
            int    USER_ID       = Convert.ToInt32(Request.Params["user_id"]);
            string USER_NAME     = this.textname.Text;
            string USER_PASSWORD = this.textpass.Text;

            Admin_Model model = new Admin_Model();

            model.USER_ID       = USER_ID;
            model.USER_NAME     = USER_NAME;
            model.USER_PASSWORD = EncryptHelper.Encrypt(USER_PASSWORD);
            model.CREATE_TIME   = DateTime.Now;


            //更改选择状态,如果添加,则此设备状态改为,已经使用

            bool i = bll.Update(model);

            if (i)
            {
                Response.Write("<script>alert('保存成功!');window.location.href='com_admin-list.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert(保存失败!');window.location.href='com_admin-list.aspx';</script>");
            }
        }
Example #2
0
 // GET: Admin
 public ActionResult Home()
 {
     if (Session["User_Id"] != null)
     {
         model = new Admin_Model();
         return(View(model));
     }
     return(RedirectToAction("Login", "Account"));
 }
Example #3
0
        public void ProcessRequest(HttpContext context)
        {
            //添加
            string funcName = context.Request.QueryString["funName"].ToString();

            if (funcName == "AddUser")
            {
                string    name     = context.Request.QueryString["name"].ToString();
                string    password = context.Request.QueryString["password"].ToString();
                Admin_Bll bll      = new Admin_Bll();
                DataSet   ds       = bll.GetList("");
                DataTable dt       = ds.Tables[0];
                bool      validate = false;
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i]["USER_NAME"].ToString() == name)
                        {
                            validate = true;
                            break;
                        }
                    }
                }
                if (validate == true)
                {
                    context.Response.Write("UserExists");
                }
                else
                {
                    Admin_Model model = new Admin_Model();
                    model.USER_NAME     = name;
                    model.USER_PASSWORD = EncryptHelper.Encrypt(password);
                    model.CREATE_TIME   = DateTime.Now;

                    int j = bll.Add(model);
                    if (j > 0)
                    {
                        context.Response.Write("OK");
                    }
                    else
                    {
                        context.Response.Write("error");
                    }
                }
            }
        }
Example #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Admin_Model model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update COM_USER set ");
            if (model.USER_NAME != null)
            {
                strSql.Append("USER_NAME='" + model.USER_NAME + "',");
            }
            else
            {
                strSql.Append("USER_NAME= null ,");
            }
            if (model.USER_PASSWORD != null)
            {
                strSql.Append("USER_PASSWORD='******',");
            }
            else
            {
                strSql.Append("USER_PASSWORD= null ,");
            }
            if (model.CREATE_TIME != null)
            {
                strSql.Append("CREATE_TIME='" + model.CREATE_TIME + "',");
            }
            else
            {
                strSql.Append("CREATE_TIME= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where USER_ID=" + model.USER_ID + "");
            int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #5
0
 public ActionResult Index(Admin_Model model)
 {
     if (ModelState.IsValid)
     {
         var  dao   = new UserDao();
         bool check = dao.Check_exist(model.user_name, model.password);
         if (check) // Account is exist
         {
             return(RedirectToAction("Error", "Admin_"));
         }
         else
         {
             dao.Add(model.user_name, model.password);
             SetAlert("Số di động hoặc email bạn nhập không khớp với bất kì tài khoản nào", "danger");
             //ModelState.AddModelError("", "Số di động hoặc email bạn nhập không khớp với bất kì tài khoản nào ");
         }
     }
     return(View("Index"));
 }
Example #6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Admin_Model model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.USER_NAME != null)
            {
                strSql1.Append("USER_NAME,");
                strSql2.Append("'" + model.USER_NAME + "',");
            }
            if (model.USER_PASSWORD != null)
            {
                strSql1.Append("USER_PASSWORD,");
                strSql2.Append("'" + model.USER_PASSWORD + "',");
            }
            if (model.CREATE_TIME != null)
            {
                strSql1.Append("CREATE_TIME,");
                strSql2.Append("'" + model.CREATE_TIME + "',");
            }
            strSql.Append("insert into COM_USER(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            strSql.Append(";select @@IDENTITY");
            object obj = DbHelperSQL.GetSingle(strSql.ToString());

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Admin_Model model)
 {
     return(dal.Update(model));
 }
Example #8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Admin_Model model)
 {
     return(dal.Add(model));
 }