예제 #1
0
        private void dgv_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                string userID = dgv.Rows[e.RowIndex].Cells[1].Value.ToString();
                Users  user   = userBLL.GetUserWithID(userID);
                if (user != null)
                {
                    txtUserId.Text = user.UserId;
                    txtPwd.Text    = user.Pwd;
                    txtObject.Text = user.ObjectId;
                    lblMaDT.Text   = user.ObjectId;
                    if (!string.IsNullOrEmpty(user.Status))
                    {
                        cboStatus.SelectedValue = user.Status;
                    }



                    if (!string.IsNullOrEmpty(user.RoleId))
                    {
                        //check trong cbo
                        //cboRoleId.SelectedIndex = 0;
                        foreach (var item in cboRoleId.Items)
                        {
                            KeyValuePair <string, string> itm = (KeyValuePair <string, string>)item;
                            if (itm.Key == user.RoleId)
                            {
                                cboRoleId.SelectedValue = user.RoleId.ToString();
                                break;
                            }
                        }
                        //cboPosition.SelectedIndex = 0;
                    }
                }

                //// Xóa
                if (e.ColumnIndex == 8)
                {
                    if (CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("KhoaNv"),
                                                                         Common.clsLanguages.GetResource("Information"),
                                                                         Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                         Common.Config.CUSTOM_MESSAGEBOX_BUTTON.YESNO) == DialogResult.Yes)
                    {
                        int Xoa = userBLL.DeleteNV(userID);
                        if (Xoa == 1) // xóa thành côg
                        {
                            CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("KhoaTCong"),
                                                                             Common.clsLanguages.GetResource("Information"),
                                                                             Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                             Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                            dgv.Rows.RemoveAt(e.RowIndex);
                            foreach (Control c in this.pInput.Controls)
                            {
                                if (c is TextBox)
                                {
                                    ((TextBox)c).Text = String.Empty;
                                }
                                if (c is RichTextBox)
                                {
                                    ((RichTextBox)c).Text = String.Empty;
                                }
                                if (c is ComboBox)
                                {
                                    ((ComboBox)c).SelectedIndex = 0;
                                }
                                if (c is CheckBox)
                                {
                                    ((CheckBox)c).Checked = false;
                                }
                                lblMaDT.Text   = "";
                                txtObject.Text = "";
                                lblTB.Text     = "...";
                            }
                            DanhLaiSTT();
                        }
                    }
                }
            }
        }