Esempio n. 1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (checkinput())
            {
                Entity.Base_User entity = GetEntity();
                if (entity.UserId < 0)
                {
                    //添加
                    if (user.Add(entity) > 0)
                    {
                        //设定角色和功能模块权限
                        //DataTable dt = new DataTable();
                        //dt = user.GetList(string.Format("UserName='******' AND Userpwd='{1}'", entity.UserName, entity.Userpwd)).Tables[0];
                        //BLL.Base_UserRole userRole = new BLL.Base_UserRole();
                        //for (int i = 0; i < chkFunctionList.Items.Count; i++)
                        //{
                        //    if (chkFunctionList.Items[i].Selected)
                        //    {
                        //        Entity.Base_UserRole model = new Entity.Base_UserRole();
                        //        model.NewsTypeId = Convert.ToInt32(chkFunctionList.Items[i].Value);
                        //        model.RoleId = Convert.ToInt32(rdoRoles.SelectedValue);
                        //        model.UserId = Convert.ToInt32(dt.Rows[0]["UserId"].ToString());

                        //        BLL.Base_UserRole bllRole = new BLL.Base_UserRole();
                        //        bllRole.Add(model);
                        //    }
                        //}

                        //成功
                        Response.Redirect("userList.aspx");
                    }
                    else
                    {
                        //失败
                        lblmsg.Text = "添加失败";
                    }
                }
                else
                {
                    //修改
                    if (user.Update(entity))
                    {
                        //设定角色和功能模块权限
                        //BLL.Base_UserRole userRole = new BLL.Base_UserRole();
                        //for (int i = 0; i < chkFunctionList.Items.Count; i++)
                        //{
                        //    if (chkFunctionList.Items[i].Selected)
                        //    {
                        //        Entity.Base_UserRole model = new Entity.Base_UserRole();
                        //        model.NewsTypeId = Convert.ToInt32(chkFunctionList.Items[i].Value);
                        //        model.RoleId = Convert.ToInt32(rdoRoles.SelectedValue);
                        //        model.UserId = entity.UserId;

                        //        BLL.Base_UserRole bllRole = new BLL.Base_UserRole();
                        //        bllRole.Update(model);
                        //    }
                        //}

                        //成功
                        Response.Redirect("userList.aspx");
                    }
                    else
                    {
                        //失败
                        lblmsg.Text = "修改失败";
                    }
                }
            }
        }