Beispiel #1
0
        protected void BtnOk_Click(object sender, EventArgs e)
        {
            string code = tbCode.Text;
            string ecp = tbEcp.Text;
            if (action != "modify")
            {
                task = new Model.Task();
                task.AddTime = DateTime.Now;
                task.UserName = RequestContext.Current.User.UserName;
            }

            task.Title = tbName.Text;
            task.Description = tbDescription.Text;
            task.Code = tbCode.Text;
            task.Customer = tbCustomer.Text;
            task.MobilePhone = tbMobilePhone.Text;
            task.TelePhone = tbTelephone.Text;

            task.Bigness = tbBigness.Text;
            task.Brand = tbBrand.Text;
            task.CarryPart = tbCarryPart.Text;
            task.Collapse = RblCollapse.SelectedValue == "1";
            task.Color = tbColor.Text;
            task.Ecp = tbEcp.Text;
            task.Fineness = tbFineness.Text;
            task.Hardness = tbHardness.Text;
            task.InternalStructure = tbInternalStructure.Text;
            task.Materail = tbMaterail.Text;
            task.Model = tbModel.Text;
            task.Pattern = tbPattern.Text;
            task.PopularElement = tbPopularElement.Text;
            task.Price = tbPrice.Text;
            task.Quality = tbQuality.Text;
            task.Situation = tbSituation.Text;
            task.Size = tbSize.Text;
            task.Style = tbStyle.Text;
            task.Texture = tbTexture.Text;
            task.Type = tbType.Text;

            bool result = action == "modify" ? TaskBll.UpdateTask(task) : TaskBll.AddTask(task);
            LinkCollection c = new LinkCollection();
            c.Add("~/task/addtask.aspx", "添加任务");

            if (result)
            {
                c.Add("~/task/addtask.aspx?action=modify&id=" + task.Id.ToString(), "修改当前任务");
            }

            WriteMessage(result ? "操作执行成功" : "当前操作失败,请选择下列操作", c, result);
        }
Beispiel #2
0
        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "Del")
            {
                int id = Util.DataConverter.ToLng(e.CommandArgument);
                if (RoleBll.RoleEnableDelete(id))
                {
                    bool flag = RoleBll.DeleteRole(id);
                    if (flag)
                    {
                        Repeater1.DataSource = RoleBll.GetAll();
                        Repeater1.DataBind();
                    }
                    else
                    {
                        LinkCollection c = new LinkCollection();
                        c.Add("~/security/rolemanage.aspx", "返回重试");

                        WriteMessage("删除角色失败,请重试", c, false);
                    }
                }
                else
                {
                    LinkCollection c = new LinkCollection();
                    c.Add("~/security/rolemanage.aspx", "角色管理");

                    WriteMessage("当前角色下已有用户,不能删除", c, false);
                }
            }
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            action = RequestString("action");
            if (action == "modify")
            {
                user = UserBll.GetUser(RequestInt32("id"));
                if (user == null)
                {
                    LinkCollection c = new LinkCollection();
                    c.Add("~/security/addrole.aspx", "添加用户");
                    c.Add("~/security/rolemanage.aspx", "用户管理");

                    WriteMessage("无法获取相关用户信息", c, false);
                }
            }
            if (!IsPostBack)
            {
                cbRoles.DataSource = RoleBll.GetAll();
                cbRoles.DataBind();

                Web.WebConfig config = ConfigFactory.GetWebConfig();

                tbPassword.MinTextLength = config.PasswordMinLength>0?config.PasswordMinLength:6;
                tbPassword.MaxTextLength = config.PasswordMaxLength>0?config.PasswordMaxLength:10;
                tbPassword.FormatErrorMessage = "密码长度为" + tbPassword.MinTextLength.ToString() + "到" + tbPassword.MaxTextLength.ToString() + "位";

                if (action == "modify")
                {
                    cbLocked.Checked = user.IsLocked;
                    tbUserName.Text = user.UserName;
                    tbEmial.Text = user.Email;
                    tbPhone.Text = user.Phone;
                    modifymsg.Visible = true;
                    tbUserName.Enabled = false;
                    tbPassword.IsRequired = false;
                    if (user.Roles != null)
                    {

                        for (int i = 0; i < cbRoles.Items.Count; ++i)
                        {
                            cbRoles.Items[i].Selected = user.Roles.Any(m => m.RoleId.ToString() == cbRoles.Items[i].Value);
                        }

                    }
                }
            }
        }
Beispiel #4
0
        protected void BtnOk_Click(object sender, EventArgs e)
        {
            if (action!="modify")
            {
                role = new Role();
            }

            role.Name = tbName.Text;
            role.Description = tbDescription.Text;
            role.Purview = Request.Form["purview"];

            bool result = action == "modify" ? RoleBll.UpdateRole(role) : RoleBll.AddRole(role);
            LinkCollection c = new LinkCollection();
            c.Add("~/security/addrole.aspx", "添加角色");
            c.Add("~/security/rolemanage.aspx", "角色管理");
            WriteMessage(result?"操作执行成功":"当前操作失败,请选择下列操作", c, result);
        }
Beispiel #5
0
        protected void BtnOk_Click(object sender, EventArgs e)
        {
            IList<Role> roles = RoleBll.GetAll();
            LinkCollection c = new LinkCollection();
            c.Add("~/security/adduser.aspx", "添加用户");
            c.Add("~/security/usermanage.aspx", "用户管理");
            if (action != "modify")
            {
                if (UserBll.UserNameInUse(tbUserName.Text))
                {
                    WriteMessage("当前用户名已被使用,请更换后重试", c, false);
                }
                user = new User();
                user.IsLocked = false;
                user.JoinTime = DateTime.Now;
                user.Roles = new List<Model.Role>();
            }
            else
            {
                user.Roles.Clear();
            }

            user.UserName = tbUserName.Text;
            user.Email = tbEmial.Text;
            user.Phone = tbPhone.Text;
            user.IsLocked = cbLocked.Checked;
            if (!string.IsNullOrEmpty(tbPassword.Text))
            {
                user.Password = Util.StringHelper.MD5(tbPassword.Text);
            }

            foreach (ListItem item in cbRoles.Items)
            {
                if (item.Selected)
                {
                    user.Roles.Add(roles.First(m=>m.RoleId== Util.DataConverter.ToLng(item.Value) ));
                }
            }

            bool result = action == "modify" ? UserBll.UpdateUser(user) : UserBll.AddUser(user);

            WriteMessage(result ? "操作执行成功" : "当前操作失败,请选择下列操作", c, result);
        }
Beispiel #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            action = RequestString("action");
            if (action == "modify")
            {
                role = RoleBll.GetRole(RequestInt32("id"));
                if (role == null)
                {
                    LinkCollection c = new LinkCollection();
                    c.Add("~/security/addrole.aspx", "添加角色");
                    c.Add("~/security/rolemanage.aspx", "角色管理");

                    WriteMessage("无法获取相关角色信息", c, false);
                }
            }
            if (!IsPostBack)
            {
                if (action == "modify")
                {
                    tbName.Text = role.Name;
                    tbDescription.Text = role.Description;
                    if (string.IsNullOrEmpty(role.Purview))
                    {
                        purviews = new string[0];
                    }
                    else
                    {
                        purviews = role.Purview.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    }
                }

                PageSecuritySection section = (PageSecuritySection)WebConfigurationManager.GetSection("PageSecurity");
                RptResource.DataSource = section.Resources.Resources;
                RptResource.DataBind();
            }
        }
Beispiel #7
0
        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "Del")
            {
                int id = Util.DataConverter.ToLng(e.CommandArgument);
                if (TaskBll.DeleteTask(id))
                {
                    BindData();
                }
                else
                {
                    LinkCollection cc = new LinkCollection();
                    cc.Add("javascript:history.goback();", "返回");

                    WriteMessage("删除失败", cc, false);
                }
            }
        }
Beispiel #8
0
        protected void BtnOk_Click(object sender, EventArgs e)
        {
            string old = oldPwd.Text;
            string newpassword = newPwd.Text;

            bool flag = UserBll.ChangePassword(RequestContext.Current.User.UserName, old, newpassword);
            if (flag)
            {
                LinkCollection c = new LinkCollection();
                c.Add("~/login.aspx", "登录",true);
                CookieManager.RemoveUserCookie();
                WriteMessage("密码修改成功,请点击下面的链接重新登录",c, true);
            }
            else
            {
                WriteMessage("您填写的旧密码错误,请重试", false);
            }
        }
Beispiel #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            action = RequestString("action");

            if (action == "modify")
            {
                task = TaskBll.GetTask(RequestInt32("id"));
                if (task == null)
                {
                    LinkCollection c = new LinkCollection();
                    c.Add("~/task/addtask.aspx", "添加新任务");

                    WriteMessage("无法获取当前任务相关信息", c, false);
                }
            }
            if (!IsPostBack)
            {
                if (action == "modify")
                {
                    tbName.Text = task.Title;
                    tbDescription.Text = task.Description;
                    tbCode.Text = task.Code;
                    tbCustomer.Text = task.Customer;
                    tbTelephone.Text = task.TelePhone;
                    tbMobilePhone.Text = task.MobilePhone;
                    tbBigness.Text = task.Bigness;
                    tbBrand.Text = task.Brand;
                    tbCarryPart.Text = task.CarryPart;
                    tbColor.Text = task.Color;
                    tbEcp.Text = task.Ecp;
                    tbFineness.Text = task.Fineness;
                    tbHardness.Text = task.Hardness;
                    tbInternalStructure.Text = task.InternalStructure;
                    tbMaterail.Text = task.Materail;
                    tbModel.Text = task.Model;
                    tbPattern.Text = task.Pattern;
                    tbPopularElement.Text = task.PopularElement;
                    tbPrice.Text = task.Price;
                    tbQuality.Text = task.Quality;
                    tbSituation.Text = task.Situation;
                    tbSize.Text = task.Size;
                    tbStyle.Text = task.Style;
                    tbTexture.Text = task.Texture;
                    tbType.Text = task.Type;
                    WebUtility.SetSelectedIndexByValue(RblCollapse, task.Collapse ? "1" : "0");
                }
                else
                {
                    int loop = 10;
                    string str = Util.StringHelper.GetRadomString("0123456789ABCDEF", 24);
                    while (loop>0)
                    {
                        if (!TaskBll.CheckEcpInUse(str))
                        {
                            tbEcp.Text = str;
                            break;
                        }

                        str = Util.StringHelper.GetRadomString("0123456789ABCDEF", 24);
                        loop--;
                    }

                    if (loop==0)
                    {
                        WriteMessage("无法生成Ecp", false);
                    }
                }
            }
        }
Beispiel #10
0
 protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "Del")
     {
         int userId = Util.DataConverter.ToLng(e.CommandArgument);
         if (UserBll.DeleteUser(userId))
         {
             BindData();
         }
         else
         {
             LinkCollection cc=new LinkCollection();
             cc.Add("~/security/adduser.aspx","增加新用户");
             cc.Add("~/security/usermanage.aspx?page="+RequestInt32("page"),"用户管理");
             this.WriteMessage("删除操作失败", cc, false);
         }
     }
 }