Esempio n. 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (setU == null || setU.IsDisposed)
            {
                setU = new SetUser();
            }
            setU.ShowDialog();

            dgvUsers.DataSource = Users.SelectByConditon(txtId.Text.Trim(), txtName.Text.Trim(), Login.deptId).Tables[0];
            if (dgvUsers.Rows.Count > 0)
            {
                dgvUsers.CurrentCell = dgvUsers.Rows[DbAccess.SelectStringInDGV(setU.UserID, dgvUsers, 0)].Cells[0];
            }
        }
Esempio n. 2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (!btnUpdate.Enabled)
            {
                return;
            }
            if (dgvUsers.SelectedRows.Count > 0)
            {
                DataGridViewCellCollection dgvCells = dgvUsers.CurrentRow.Cells;
                if (setU == null || setU.IsDisposed)
                {
                    setU = new SetUser(dgvCells[0].Value.ToString(), dgvCells[1].Value.ToString(), dgvCells[2].Value.ToString(), dgvCells[6].Value.ToString(), dgvCells[7].Value.ToString(), dgvCells[4].Value.ToString(), dgvCells[8].Value.ToString());
                }
                setU.ShowDialog();

                dgvUsers.DataSource = Users.SelectByConditon(txtId.Text.Trim(), txtName.Text.Trim(), Login.deptId).Tables[0];
                if (dgvUsers.Rows.Count > 0)
                {
                    dgvUsers.CurrentCell = dgvUsers.Rows[DbAccess.SelectStringInDGV(setU.UserID, dgvUsers, 0)].Cells[0];
                }
            }
        }