Ejemplo n.º 1
0
 private void ModifyUser_Click()
 {
     try
     {
         Expression <Func <RoleInfo, bool> > p = n => n.Role_Id == Convert.ToInt32(lblId.Text);
         Action <RoleInfo> ap = n =>
         {
             n.Role_Name   = txtRoleName.Text.Trim();
             n.Role_State  = comboxState.Text.Trim();
             n.Role_Remark = txtRemark.Text.Trim();
         };
         if (!RoleInfoAdd.UpdateOneRoleInfo(p, ap))//用户是否修改失败
         {
             MessageBox.Show(" 修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             string Log_Content = String.Format("用户名称:{0} ", lblId.Text.Trim());
             CommonalityEntity.WriteLogData("修改", "修改" + Log_Content + "的信息", CommonalityEntity.USERNAME);
         }
     }
     catch
     {
         CommonalityEntity.WriteTextLog("用户管理 bntUpUser_Click()");
     }
     finally
     {
         page = new PageControl();
         LoadData();
         userContext();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 修改事件
        /// </summary>
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtRoleName.Text))
            {
                MessageBox.Show(this, "角色名称不能为空!");
                return;
            }
            if (comboxState.SelectedIndex < 0)
            {
                MessageBox.Show(this, "请选择状态!");
                return;
            }
            string            name   = txtRoleName.Text;                    //姓名
            string            remark = txtRemark.Text;                      //备注
            string            state  = comboxState.SelectedItem.ToString(); //状态
            string            id     = lblId.Text;                          //id
            int               j      = 0;
            Action <RoleInfo> action = n =>
            {
                n.Role_Name       = name;
                n.Role_Remark     = remark;
                n.Role_State      = state;
                n.Role_Permission = "";
            };

            try
            {
                Expression <Func <RoleInfo, bool> > funroleinfo = n => n.Role_Id.ToString() == id;
                if (!RoleInfoAdd.UpdateOneRoleInfo(funroleinfo, action))//角色是否修改失败
                {
                    j++;
                }
                if (j == 0)
                {
                    MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    string Log_Content = String.Format("角色名称:{0}", name);
                    CommonalityEntity.WriteLogData("修改", "修改" + Log_Content + "的信息", CommonalityEntity.USERNAME);
                }
                else
                {
                    MessageBox.Show(" 修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch
            {
                CommonalityEntity.WriteTextLog("角色管理 btnUpdate_Click");
            }
            finally
            {
                page = new PageControl();
                LoadData();
                userContext();
                lblId.Text       = "";
                txtRemark.Text   = "";
                txtRoleName.Text = "";
                comboxState.Text = "";
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///删除用户信息
        /// </summary>
        private void tbtnDelUser_delete()
        {
            try
            {
                int j = 0;
                UserIDSearch = lvwUserList.SelectedRows.Count;
                if (UserIDSearch > 0)//选中删除
                {
                    if (MessageBox.Show("确定要删除吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        //选中数量
                        //遍历
                        for (int i = 0; i < UserIDSearch; i++)
                        {
                            Expression <Func <RoleInfo, bool> > funuserinfo = n => n.Role_Id == Convert.ToInt32(lvwUserList.SelectedRows[i].Cells["Role_Id"].Value);;

                            if (!RoleInfoAdd.DeleteToMany(funuserinfo))
                            {
                                j++;
                            }
                            else
                            {
                                CommonalityEntity.WriteLogData("删除", "删除角色名称为:" + lvwUserList.SelectedRows[i].Cells["Role_Name"].Value + "的信息", CommonalityEntity.USERNAME);
                            }
                        }
                        if (j == 0)
                        {
                            MessageBox.Show("成功删除", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("删除失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                else//没有选中
                {
                    MessageBox.Show("请选择要删除的行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch
            {
                CommonalityEntity.WriteTextLog("用户管理 tbtnDelUser_delete()+");
            }
            finally
            {
                page = new PageControl();
                //page.PageMaxCount = tscbxPageSize2.SelectedItem.ToString();
                LoadData();//更新
            }
        }
Ejemplo n.º 4
0
 private void lvwUserList_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     label3.Visible    = false;
     btnAdd.Visible    = false;
     btnUpdate.Enabled = true;
     if (this.lvwUserList.SelectedRows.Count > 0)//选中行
     {
         if (lvwUserList.SelectedRows.Count > 1)
         {
             MessageBox.Show("修改只能选中一行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             //修改的值
             int ID = int.Parse(this.lvwUserList.SelectedRows[0].Cells["Role_Id"].Value.ToString());
             Expression <Func <RoleInfo, bool> > funviewinto = n => n.Role_Id == ID;
             foreach (var n in RoleInfoAdd.Query(funviewinto))
             {
                 if (n.Role_Id != 0)
                 {
                     this.lblId.Text = n.Role_Id.ToString();
                 }
                 if (n.Role_Name != null)
                 {
                     // IC卡类型状态
                     this.txtRoleName.Text = n.Role_Name;
                 }
                 if (n.Role_State != null)
                 {
                     // IC卡类型权限
                     this.comboxState.Text = n.Role_State;
                 }
                 if (n.Role_Remark != null)
                 {
                     // IC卡类型描述
                     this.txtRemark.Text = n.Role_Remark;
                 }
                 break;
             }
         }
     }
     else
     {
         MessageBox.Show("请选择要修改的行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 添加事件
        /// </summary>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            #region --验证用户名是否重复--
            DataTable table = LinQBaseDao.Query(" SELECT * FROM [RoleInfo] where Role_Name='" + txtRoleName.Text.Trim() + "'").Tables[0];
            if (table.Rows.Count > 0)
            {
                MessageBox.Show("角色名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (comboxState.SelectedItem == null)
            {
                MessageBox.Show("请选择状态!");
                return;
            }

            #endregion
            int j    = 0;
            int rint = 0;

            if (string.IsNullOrEmpty(txtRoleName.Text))
            {
                MessageBox.Show(this, "角色名称不能为空!");
                return;
            }
            if (comboxState.SelectedIndex < 0)
            {
                MessageBox.Show(this, "请选择状态!");
                return;
            }
            string name   = txtRoleName.Text; //角色名
            string remark = txtRemark.Text;   //备注
            try
            {
                if (!btnCheck())
                {
                    return;
                }
                var rf = new RoleInfo
                {
                    Role_Name       = name,
                    Role_Remark     = remark,
                    Role_State      = comboxState.SelectedItem.ToString(),
                    Role_Permission = ""
                };
                if (!RoleInfoAdd.InsertOneRoleInfo(rf, out rint))
                {
                    j++;
                }

                if (j == 0)
                {
                    MessageBox.Show("成功增加", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    string Log_Content = String.Format("角色名称:{0}", name);
                    CommonalityEntity.WriteLogData("新增", "新增" + Log_Content + "的信息", CommonalityEntity.USERNAME);
                }
                else
                {
                    MessageBox.Show("成功失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch
            {
                CommonalityEntity.WriteTextLog("角色管理 btnAdd_Click()");
            }
            finally
            {
                page = new PageControl();
                LoadData();//更新数据
            }
        }