protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
 {
     string username = Request["username"];
     string password = Request["password"];
     BLL.Admin adminbll = new BLL.Admin();
     if (adminbll.login(username,password)==true)
     {
         Response.Redirect("index.aspx");
         Session["username"] = username;
         Session["password"] = password;
     }
     if (adminbll.login(username, password)==false)
     {
         Response.Write("<script>alert('用户名或者密码有错!')</script>");
     }
 }
        //初始化
        private void FormAdminUpdate_Load(object sender, EventArgs e)
        {
            textId.Text = id.ToString();
            BLL.Admin   bll   = new BLL.Admin();
            Model.Admin model = bll.getModel(id.ToString());

            if (model == null)
            {
                MessageBox.Show("数据查询出错");
                return;
            }
            else
            {
                textId.Text        = model.Id;
                textAdminname.Text = model.Name;
                textOldPwd.Text    = model.Pass;
            }
        }
Exemple #3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Model.Admin model = new Model.Admin();
            model.AdminID  = IDText.Text;
            model.AdminPwd = PwdText.Text;
            BLL.Admin bll = new BLL.Admin();
            int       str = bll.SelectAdmin(model);

            if (str != 0)
            {
                Response.Write("<script language='javascript'>alert('登陆成功!');</script>");

                //Response.Redirect("UserEdit.aspx?UserID=" + model.UserID);
            }
            else
            {
                Response.Write("<script language='javascript'>alert('用户名或密码错误');</script>");
            }
        }
Exemple #4
0
        protected void BtnLogin_Click(object sender, EventArgs e)
        {
            BLL.Admin bllAdmin = new BLL.Admin();
            if (Session["SSVC"] != null)
            {
                if (this.txtCode.Text.Trim().ToLower() != Session["SSVC"].ToString().ToLower())
                {
                    PageFunc.AjaxAlert(this.Page, "错误的验证码,请重新输入!");
                    this.txtCode.Text = "";
                }
                else
                {
                    var uModel = bllAdmin.AdminLogin(this.txtUserName.Text.Trim(), PageFunc.Encrypt(this.txtPassWd.Text, 1));
                    if (uModel != null)
                    {
                        if (!uModel.Enabled)
                        {
                            PageFunc.AjaxAlert(this.Page, "该帐号已被停用!");
                            this.txtCode.Text = "";
                        }
                        else
                        {
                            AdminPage basePage = new AdminPage();
                            Session[basePage.sessionAdminModel] = uModel;

                            Response.Redirect("TljList.aspx");
                        }
                    }
                    else
                    {
                        PageFunc.AjaxAlert(this.Page, "用户名或密码有误!");
                        this.txtCode.Text = "";
                    }
                }
            }
            else
            {
                PageFunc.AjaxAlert(this.Page, "验证码无效,请重新刷新!");
                this.txtCode.Text = "";
            }
        }
Exemple #5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string json = "{'info':'登录失败','ID':-1}";

            //获取GET方法传递参数:Request.QueryString["参数名称"];
            //获取POST方法传递参数:Request.Form["参数名称"];
            string txtUserName = context.Request.Form["UserName"]; //保存文本框对象,提高效率
            string txtPassWord = context.Request.Form["PassWord"];

            BLL.Admin bll = new BLL.Admin();
            int       n   = bll.Login(txtUserName, txtPassWord);

            //返回单个文字信息
            if (n > 0)
            {
                json = "{'info':'登录成功!','ID':" + n + "}";
                context.Session["ID"] = n;
            }
            context.Response.Write(json);
        }
Exemple #6
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string strErr = "";

            BLL.Admin bll = new BLL.Admin();
            int       aaa = bll.GetRecordCount("adminName='" + txtUsername.Text + "'and adminPass='******'");

            if (aaa >= 1)
            {
                Session["role"] = txtUsername.Text;
                Response.Redirect("index.aspx");
            }
            else
            {
                strErr += "所输入的帐号或密码不正确!\\n";
            }
            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            User loggedInUser = (User)Session["currentUser"];

            if (loggedInUser != null)
            {
                if (BLL.Admin.RetrieveAdmin(loggedInUser) == null)
                {
                    if (loggedInUser.Username.Equals("Admin"))
                    {
                        BLL.Admin admin = new BLL.Admin();
                        admin.UserId = loggedInUser.Id;
                        admin.Add();
                        System.Diagnostics.Debug.WriteLine("Making admin");
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine("Not an admin");
                        Response.Redirect("/Redirect.aspx");
                    }
                }
            }
        }
Exemple #8
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string json   = "{}";
            string action = context.Request.Form["Action"];

            if (action == "Show")
            {
                BLL.Admin bll = new BLL.Admin();
                DataSet   ds  = bll.GetList(20);                         //调用业务逻辑层的方法
                ds.Tables[0].TableName = "Admin";                        //为数据表改名
                                                                         //返回列表
                json = WEB.DataConvertJson.DataTable2Json(ds.Tables[0]); //调用把datatable转为json的方法
                context.Response.Write(json);
            }
            else if (action == "Load")//检查是否已经登录
            {
                if (context.Session["ID"] == null)
                {
                    json = "{'info':'no'}";
                }
                context.Response.Write(json);
            }
        }
Exemple #9
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string json   = "";
            string action = context.Request.Form["Action"];

            if (action == "Show")//显示
            {
                if (context.Session["ID"] == null)
                {
                    json = "{}";//未登录
                }
                else
                {
                    BLL.Admin bll = new BLL.Admin();
                    DataSet   ds  = bll.GetList("");
                    ds.Tables[0].TableName = "AdminTable";
                    //返回列表
                    json = WEB.DataConvertJson.DataTable2Json(ds.Tables[0]);
                }
            }
            else if (action == "Del")                                //删除操作
            {
                string    DelNumS = context.Request.Form["DelNumS"]; //获取批量删除的编号
                BLL.Admin bll     = new BLL.Admin();
                if (bll.DeleteList(DelNumS))
                {
                    json = "{'info':'删除成功'}";
                }
                else
                {
                    json = "{'info':'删除失败'}";
                }
            }
            context.Response.Write(json);
        }
Exemple #10
0
        private void but_ok_Click(object sender, EventArgs e)
        {
            userName   = text_userName.Text.Trim();
            passwd     = text_passwd.Text.Trim();
            ensureCode = text_ensureCode.Text.Trim();

            if (ensureCode == string.Empty || passwd == string.Empty || userName == string.Empty)
            {
                MessageBox.Show("请完善信息", "糟糕", MessageBoxButtons.OK, MessageBoxIcon.Error);
                form_Shake();
                checkCode_Random();

                if (ensureCode == string.Empty)
                {
                    text_ensureCode.Focus();
                }
                if (passwd == string.Empty)
                {
                    text_ensureCode.Text = string.Empty;
                    text_passwd.Focus();
                }
                if (userName == string.Empty)
                {
                    text_ensureCode.Text = string.Empty;
                    text_passwd.Text     = string.Empty;
                    text_userName.Focus();
                }
            }
            else
            {
                if (text_ensureCode.Text == checkCode.Text)
                {
                    string strWhere = string.Empty,
                           name     = "";
                    int count       = 0;
                    if (combox_power.Text == "管理员")
                    {
                        BLL.Admin bllAdmin = new BLL.Admin();
                        strWhere = string.Format("userID = '{0}' and passwd = '{1}'", userName, passwd);
                        count    = bllAdmin.GetRecordCount(strWhere);

                        name = new BLL.Admin().GetModel(userName).userName;
                    }
                    else
                    {
                        BLL.Manager bllManager = new BLL.Manager();
                        strWhere = string.Format("manID = '{0}' and passwd = '{1}'", userName, passwd);
                        count    = bllManager.GetRecordCount(strWhere);

                        name = new BLL.Manager().GetModel(userName).manName;
                    }

                    if (count == 1)
                    {
                        MessageBox.Show("登录成功", "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        Common.StaticClass.userType = combox_power.Text.ToString();
                        Common.StaticClass.userName = name;
                        Common.StaticClass.userID   = userName;

                        this.Hide();

                        new Main_Admin().ShowDialog(this);

                        text_passwd.Text = text_ensureCode.Text = string.Empty;
                        checkCode_Random();
                    }
                    else
                    {
                        errorTime -= 1;
                        if (errorTime > 0)
                        {
                            MessageBox.Show("用户名或密码错误,还有" + errorTime.ToString() + "次机会", "糟糕", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            checkCode_Random();
                            form_Shake();

                            text_userName.Text = text_passwd.Text = text_ensureCode.Text = string.Empty;
                            text_userName.Focus();
                        }
                        else
                        {
                            MessageBox.Show("用户名或密码错误三次,请稍后登录", "糟糕", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            this.Close();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("验证码不正确", "糟糕", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    checkCode_Random();
                    form_Shake();
                }
            }
        }
Exemple #11
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            string json = "{'info':'增加数据失败'}";
            //获取动作的类型
            string action = context.Request.Form["Action"];

            if (action == "add")
            {
                //获取GET方法传递参数:Request.QueryString["参数名称"];
                //获取POST方法传递参数:Request.Form["参数名称"];
                string txtUserName  = context.Request.Form["Name"]; //保存文本框对象,提高效率
                string txtPassWord  = context.Request.Form["pwd"];
                string txtemail     = context.Request.Form["email"];
                string adminSex     = context.Request.Form["sex"];
                string txtbirthday  = context.Request.Form["birthday"];
                string txtstatement = context.Request.Form["Statement"];
                string ustate       = context.Request.Form["Ustate"];


                Model.Admin model = new Model.Admin();
                model.Uname     = txtUserName; //用户姓名
                model.UPassword = txtPassWord; //用户密码
                model.UEmail    = txtemail;    //用户邮箱
                model.UState    = int.Parse(ustate);
                //用户生日
                string y = txtbirthday.Substring(0, 4);
                string m = txtbirthday.Substring(4, 2);
                string d = txtbirthday.Substring(6, 2);
                txtbirthday     = y + "-" + m + "-" + d;
                model.UBirthday = txtbirthday;   //用户生日

                model.UStatement = txtstatement; //用户描述
                model.URegDate   = DateTime.Now; //用户注册时间
                model.Usex       = false;        //用户性别
                if (adminSex == "true")
                {
                    model.Usex = true;
                }

                BLL.Admin bll = new BLL.Admin();
                int       n   = bll.add(model);
                //返回单个文字信息
                if (n > 0)
                {
                    json = "{'info':'增加数据成功,编号是:" + n + "'}";
                }
            }
            //else if (action == "Load")
            //{
            //    if (context.Session["ID"] == null)
            //    {
            //        json = "{'info':'no'}";
            //    }
            //    else
            //        json = "{'info':'yes'}";

            //}
            context.Response.Write(json);
        }