예제 #1
0
        private void dgvUsers_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == 6)
                {
                    Int32 userID = Convert.ToInt32("0" + dgvUsers.Rows[e.RowIndex].Cells[0].Value);

                    UpdateUserCtl objUpdateUser = new UpdateUserCtl(userID);
                    objUpdateUser.Parent = this.ParentForm;
                    UserControlManager.UserControls.Push(this);
                    Panel pnl = (Panel)this.ParentForm.Controls["pnlContext"];

                    string s = pnl.Name;

                    objUpdateUser.ParentForm.Controls[s].Controls.Clear();
                    objUpdateUser.ParentForm.Controls[s].Controls.Add(objUpdateUser);
                }

                else if (e.ColumnIndex == 7)
                {
                    if (MessageBox.Show("Are you sure you want to delete the selected user?", RMSGlobal.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        Int32 userID = 0;

                        bool bTempBool = Int32.TryParse(dgvUsers.Rows[e.RowIndex].Cells[0].Value.ToString(), out userID);

                        if (bTempBool)
                        {
                            CUserInfo objUserInfo = new CUserInfo();

                            objUserInfo.UserID = userID;
                            CUserManager oManager = new CUserManager();

                            CResult oResult = oManager.DeleteUser(objUserInfo);

                            if (oResult.IsSuccess)
                            {
                                dgvUsers.Rows.RemoveAt(e.RowIndex);
                            }
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }