Exemplo n.º 1
0
        private void btn_newUser_Click(object sender, EventArgs e)
        {
            FrmUserNew frmUserNew = new FrmUserNew();

            frmUserNew.StartPosition = FormStartPosition.CenterScreen;
            frmUserNew.ShowDialog();
            LoadUserInfo();
        }
Exemplo n.º 2
0
        private void btn_modifyUser_Click(object sender, EventArgs e)
        {
            FrmUserNew      frmUserNew = new FrmUserNew();
            DataGridViewRow item       = dataGridView.CurrentRow;

            if (item == null)
            {
                return;
            }
            frmUserNew.User.UserName    = item.Cells[0].Value.ToString();
            frmUserNew.User.PassWord    = item.Cells[1].Value.ToString();
            frmUserNew.User.Authority   = (EnumUserAutho)(Enum.Parse(typeof(EnumUserAutho), item.Cells[2].Value.ToString()));
            frmUserNew.User.Description = item.Cells[5].Value.ToString();
            frmUserNew.User.Contact     = item.Cells[4].Value.ToString();
            frmUserNew.User.TrueName    = item.Cells[3].Value.ToString();
            frmUserNew.User.UserID      = (int)item.Tag;
            frmUserNew.StartPosition    = FormStartPosition.CenterScreen;
            frmUserNew.ShowDialog();
            LoadUserInfo();
        }
Exemplo n.º 3
0
        private void btn_deleteUser_Click(object sender, EventArgs e)
        {
            DataTable  dt;
            FrmUserNew frmUserNew = new FrmUserNew();

            dt = ClsSQLMethod.SearchUser();
            DataGridViewRow item = dataGridView.CurrentRow;

            if (item == null || item.Tag == null)
            {
                return;
            }
            if (curUser.Authority != EnumUserAutho.管理员)
            {
                MessageBox.Show("你没有此权限!");
                return;
            }
            frmUserNew.User.UserID = (int)item.Tag;
            try
            {
                if (MessageBox.Show("确认删除用户:" + frmUserNew.User.UserID + "?", "删除用户", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        if (frmUserNew.User.UserID == int.Parse(row[0].ToString()))
                        {
                            break;
                        }
                    }
                    ClsSQLMethod.DeleteUser(frmUserNew.User);
                    LoadUserInfo();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("删除失败!");
            }
        }