コード例 #1
0
        protected void Btn_Register_Click(object sender, EventArgs e)
        {
            Model.Admin admin = new Model.Admin();
            admin.adminName     = txbUserName.Text;
            admin.adminPassword = txbPassword1.Text;
            admin.department    = txbDepartment.Text;
            admin.job           = txbJob.Text;
            admin.permission    = "0";

            BLL.AdminManager admin1 = new BLL.AdminManager();
            bool             bo     = admin1.Add(admin);


            if (bo == true)
            {
                string  str = "adminname='" + txbUserName.Text.Trim() + "'";
                DataSet ds  = admin1.GetList(str);
                Session["NadminID"]   = ds.Tables[0].Rows[0]["adminID"].ToString();
                Session["NadminName"] = txbUserName.Text.Trim();
                Response.Redirect("~/N_Admin/Apply_Permission.aspx");
            }
            else
            {
                Response.Write("<script language=javascript>alert('申请失败!请重试')");
            }
        }
コード例 #2
0
        protected void Btn_Register_Click(object sender, EventArgs e)
        {
            Model.Apply_Message apply_Message = new Model.Apply_Message();
            apply_Message.name       = txbUserName.Text;
            apply_Message.department = txbDepartment.Text;
            apply_Message.job        = txbJob.Text;
            apply_Message.permission = DropDownListPermission.SelectedItem.Text;
            apply_Message.isRead     = "0";

            Model.Admin admin = new Model.Admin();
            admin.adminName     = txbUserName.Text;
            admin.adminPassword = txbPassword1.Text;
            admin.department    = txbDepartment.Text;
            admin.job           = txbJob.Text;
            admin.permission    = DropDownListPermission.SelectedItem.Text;

            BLL.AdminManager admin1 = new BLL.AdminManager();
            bool             bo1    = admin1.Add(admin);

            BLL.Apply_MessageManager apply_Message1 = new BLL.Apply_MessageManager();
            bool bo = apply_Message1.Add(apply_Message);

            if ((bo == true) && (bo1 == true))
            {
                Response.Write("<script language=javascript>alert('申请成功!请耐心等待管理员同意')</script>");
            }
            else
            {
                Response.Write("<script language=javascript>alert('申请失败!请重试')");
            }

            //Model.Users users = new Model.Users();
            //users.userName = txbUserName.Text;
            //users.password = txbPassword1.Text;
            //users.gender = DropDownList1.SelectedItem.Text;
            //string date = DropDownListYear.SelectedItem.Text.Trim().ToString() + "/" + DropDownListMonth.SelectedItem.Text.Trim().ToString() + "/" + DropDownListDay.SelectedItem.Text.Trim().ToString();
            //DateTime time = Convert.ToDateTime(date);
            //users.birthDate = time;
            //BLL.UsersManager users1 = new UsersManager();
            //bool bo = users1.Add(users);
            //if (bo == true)
            //{
            //    Response.Redirect("~/Default.aspx");
            //}
            //else
            //{
            //    Response.Write("<script language=javascript>alert('注册失败!')");
            //}
        }
コード例 #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            BLL.AdminManager bll    = new BLL.AdminManager();
            string           action = context.Request["action"];

            // 获取分页
            if (action == "get")
            {
                int pageIndex, pageSize;
                try
                {
                    pageIndex = Convert.ToInt32(context.Request["pageIndex"]);
                    pageSize  = Convert.ToInt32(context.Request["pageSize"]);
                }
                catch
                {
                    return;
                }
                pageIndex = pageIndex < 1 ? 1 : pageIndex;
                pageSize  = pageSize <= 0 || pageSize > 10 ? 10 : pageSize;
                int pageCount           = (int)Math.Ceiling((double)bll.GetModelCount() / (double)pageSize);
                List <Model.Admin> list = bll.GetPageList(pageIndex, pageSize);
                object             obj  = new
                {
                    pageIndex,
                    pageSize,
                    pageCount,
                    data = list,
                };
                JavaScriptSerializer js = new JavaScriptSerializer();
                context.Response.Write(js.Serialize(obj));
            }
            //获得一个
            else if (action == "getById")
            {
                int id = 0;
                if (!int.TryParse(context.Request["id"], out id))
                {
                    context.Response.Write("error:非法的ID");
                    return;
                }
                var admin = bll.GetModel(id);
                if (admin == null)
                {
                    context.Response.Write("no:该用户不存在");
                    return;
                }
                JavaScriptSerializer js = new JavaScriptSerializer();
                context.Response.Write("ok:" + js.Serialize(admin));
            }
            // 删除
            else if (action == "delete")
            {
                int id = 0;
                if (!int.TryParse(context.Request["id"], out id))
                {
                    context.Response.Write("error:非法的ID");
                    return;
                }
                if (bll.Delete(id))
                {
                    context.Response.Write("ok:删除成功");
                }
                else
                {
                    context.Response.Write("no:删除失败");
                }
            }
            // 修改
            else if (action == "edit")
            {
                int    id        = 0;
                string adminName = context.Request["adminName"];
                string pwd       = context.Request["pwd"];
                if (!int.TryParse(context.Request["id"], out id))
                {
                    context.Response.Write("error:非法的ID");
                    return;
                }
                Model.Admin admin = bll.GetModel(id);
                if (admin == null)
                {
                    context.Response.Write("no:该用户不存在");
                    return;
                }
                admin.AdminName = adminName;
                if (!string.IsNullOrWhiteSpace(pwd))
                {
                    admin.Pwd = pwd;
                }
                if (bll.Update(admin))
                {
                    context.Response.Write("ok:修改成功");
                }
                else
                {
                    context.Response.Write("no:修改失败");
                }
            }
            // 添加
            else if (action == "add")
            {
                Model.Admin admin = new Model.Admin
                {
                    AdminName = context.Request["adminName"],
                    Pwd       = context.Request["pwd"]
                };
                if (bll.Add(admin))
                {
                    context.Response.Write("ok:添加成功");
                }
                else
                {
                    context.Response.Write("no:添加失败");
                }
            }
            else
            {
                context.Response.Write("error:非法的action");
            }
        }