private void btnDelete_Click(object sender, EventArgs e) { try { if (dgvUsers.CurrentRow != null) { if ((Int64)dgvUsers.CurrentRow.Cells["UserID"].Value == CurrentUser.UserID) { MessageBox.Show("You can not delete this user.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (dgvUsers.SortedColumn != null) { sortedColumn = dgvUsers.SortedColumn; sortDirection = dgvUsers.SortOrder; } frmUserEntry fUser = new frmUserEntry((int)Constant.Mode.Delete, (Int64)dgvUsers.CurrentRow.Cells["UserID"].Value, CurrentCompany.CompId); fUser.ShowInTaskbar = false; fUser.ShowDialog(); LoadList(); btnApply_Click(sender, e); if (sortedColumn != null) { ListSortDirection LSD; if (sortDirection == SortOrder.Ascending) { LSD = System.ComponentModel.ListSortDirection.Ascending; } else { LSD = System.ComponentModel.ListSortDirection.Descending; } dgvUsers.Sort(dgvUsers.Columns[sortedColumn.Name], LSD); } if (dgvUsers.CurrentRow != null && idgvPosition <= dgvUsers.RowCount) { if (dgvUsers.Rows.Count - 1 < idgvPosition) { dgvUsers.CurrentCell = dgvUsers.Rows[idgvPosition - 1].Cells[0]; } else { dgvUsers.CurrentCell = dgvUsers.Rows[idgvPosition].Cells[0]; } } dgvUsers_SelectionChanged(sender, e); } } } catch (Exception exc) { Utill.Common.ExceptionLogger.writeException("User", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } }
private void btnNew_Click(object sender, EventArgs e) { try { frmUserEntry fUser = new frmUserEntry((int)Constant.Mode.Insert, 0, CurrentCompany.CompId); fUser.ShowInTaskbar = false; fUser.ShowDialog(); LoadList(); btnClear_Click(sender, e); dgvUsers_SelectionChanged(sender, e); } catch (Exception exc) { Utill.Common.ExceptionLogger.writeException("User", exc.StackTrace); } }