RUS_-_Karejev_-_Razrabotka_Windows-prilozhenij
.pdf//-----------------------------------------------------------------------
private void miPaste_Click(object sender, System.EventArgs e)
{
try
{
if(SelectingClient)
{
TransferClients(oldGroupNode, selectedNode);
miPaste.Enabled = false; miCopy.Enabled = false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.Source);
}
}
// Удаление записей
private void miDelete_Click(object sender, System.EventArgs e)
{
try
{
DialogResult dr = MessageBox.Show("Вы действительно желаете удалить запись?", "Удаление записи", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
if (dr == DialogResult.OK)
{
foreach (ListViewItem lvi in lvManager.SelectedItems)
{
if (!(selectedNode is GroupTreeNode))
{
CustomListItem item = (CustomListItem)lvi; selectedNode.Nodes.Remove(selectedNode.Nodes[item.Index]); item.BindedRow.Delete();
lvManager.Items.Remove(item);
}
else
{
CustomListItem item = (CustomListItem)lvi; item.BindedRow.Delete(); lvManager.Items.Remove(item);
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.Source);
}
}
//-----------------------------------------------------------------------
private void btnUpdateMain_Click(object sender, System.EventArgs e)
{
this.UpdateMainData();
}
//-----------------------------------------------------------------------
private void miContents_Click(object sender, System.EventArgs e)
{
Help.ShowHelp(this, hpManager.HelpNamespace);
}
//-----------------------------------------------------------------------
private void directions_RowDeleted(object sender, DataRowChangeEventArgs e)
{
MessageBox.Show(e.Row[1].ToString() + " is deleted");
}
//-----------------------------------------------------------------------
private void lnkToday_Click(object sender, System.EventArgs e)
{
if (currManagerTotal.Position == mainDataSet.data.Rows.Count - 2) currManagerTotal.Position += 1;
}
//-----------------------------------------------------------------------
private void btnCreateGroup_Click(object sender, System.EventArgs e)
{
this.AddNewGroupWaitingRoom();
}
//-----------------------------------------------------------------------
private void btnCreateClient_Click(object sender, System.EventArgs e)
{
this.AddNewClientWaitingRoom();
}
//-----------------------------------------------------------------------
private void btnShowGroups_Click(object sender, System.EventArgs e)
{
dgGroups.DataSource = null; dgClients.DataSource = null;
if (cmbDirections.SelectedIndex >= 0)
{
this.LoadCoursesDataGrid(cmbDirections.SelectedIndex + 1);
}
btnCreateGroup.Enabled = false; btnCreateClient.Enabled = false; btnShowGroups.Enabled = false; btnDeleteClient.Enabled = false; btnDeleteGroup.Enabled = false;
}
// Показать клиентов
//-----------------------------------------------------------------------
internal void dgGroups_Click(object sender, System.EventArgs e)
{
try
{
if (dgGroups.DataSource != null)
{
DataGrid dg = (DataGrid)sender;
int rowID = dg.CurrentRowIndex; if (rowID >= 0)
{
DataView dvGroups = (DataView)dg.DataSource; DataRow group = dvGroups[rowID].Row;
int groupID = (int)group["groupID"];
btnDeleteGroup.Enabled = true; btnDeleteGroup.Tag = groupID;
DataView dvGroupClients = new DataView(mainDataSet.group_clients); dvGroupClients.RowFilter = "groupID = " + groupID.ToString();
DataRow[] clients = new DataRow[dvGroupClients.Count];
//Получаем записи клиентов int i = 0;
foreach (DataRowView drv in dvGroupClients)
clients[i++] = drv.Row.GetParentRow("clientsgroup_clients");
//Помещаем полученные записи в таблицу dtClients
if (clients.Length > 0)
{
DataTable dtClients = clients[0].Table.Clone();
foreach (DataRow client in clients) dtClients.Rows.Add(client.ItemArray);
dgClients.DataSource = dtClients; dtClients.RowChanged+=new DataRowChangeEventHandler(dtClients_RowChanged); cmClientsTable = (CurrencyManager)this.BindingContext[dtClients, null];
}
else
dgClients.DataSource = null;
btnCreateClient.Enabled = true; btnFindPasteClient.Enabled = true;
}
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, ex.Source);
}
}
// Показать группы
private void dgCourses_Click(object sender, System.EventArgs e)
{
DataGrid dg = (DataGrid)sender;
int rowID = dg.CurrentRowIndex; if (rowID >= 0)
{
DataView dvCourses = (DataView)dg.DataSource;
DataRow course = dvCourses[rowID].Row;
int courseID = (int)course["courseID"];
int statusID = cmbGroupStatus.SelectedIndex + 1;
DataView dvGroups = new DataView(mainDataSet.groups);
dvGroups.RowFilter = "courseID = " + courseID.ToString() + " AND StatusID = " + statusID.ToString
();
cmGroupsTable = (CurrencyManager)this.BindingContext[dvGroups, null]; dgGroups.DataSource = dvGroups;
btnCreateGroup.Enabled = true; btnCreateClient.Enabled = false; btnFindPasteClient.Enabled = false; btnDeleteClient.Enabled = false; btnDeleteGroup.Enabled = false; dgClients.DataSource = null;
}
}
//-----------------------------------------------------------------------
private void cmiClientPersonData_Click(object sender, System.EventArgs e)
{
try
{
int rowID = dgClients.CurrentRowIndex;
if (rowID >= 0)
{
DataView dvGroups = (DataView)dgGroups.DataSource;
int selectedGroupRowID = (int)dvGroups[dgGroups.CurrentRowIndex].Row["groupID"]; DataRow selectedGroupRow = dvGroups[dgGroups.CurrentRowIndex].Row;
DataTable dtClients = (DataTable)dgClients.DataSource;
DataRow clientRow = dtClients.Rows[rowID];
frmClient client = new frmClient(clientRow, this.mainDataSet);
// Определяем данные по умолчанию на форме клиента int clientID = (int)clientRow["clientID"]; client.ClientID = clientID;
client.txtFirstName.Text = clientRow["fname"].ToString(); client.txtLastName.Text = clientRow["lname"].ToString(); client.txtFatherName.Text = clientRow["fathName"].ToString();
DataView dvIncome = new DataView(mainDataSet.income); dvIncome.RowFilter = "clientID = " + clientID.ToString(); client.Text += selectedGroupRowID.ToString(); client.dgPayments.DataSource = dvIncome;
DataView dvRealizedTable = new DataView(mainDataSet.RealizedTable); dvRealizedTable.RowFilter = "clientID = " + clientID.ToString(); client.dgClientsRealization.DataSource = dvRealizedTable;
client.GroupID = selectedGroupRowID; client.MainForm = this;
if (client.ShowDialog() == DialogResult.OK)
{
//Обновление оригинальной записи клиента,
//т.к. источником у таблицы клиентов является копия таблицы
MainDataSet.clientsRow originalClientRow = mainDataSet.clients.FindByclientID(clientID); originalClientRow["fname"] = client.txtFirstName.Text;
originalClientRow["lname"] = client.txtLastName.Text; originalClientRow["fathName"] = client.txtFatherName.Text; originalClientRow["linkData"] = client.txtPhones.Text; originalClientRow["recorddate"] = client.dtpRecordDate.Value; originalClientRow["note"] = client.txtNotes.Text;
// Обновление копии записи клиента clientRow["fname"] = client.txtFirstName.Text; clientRow["lname"] = client.txtLastName.Text; clientRow["fathName"] = client.txtFatherName.Text; clientRow["linkData"] = client.txtPhones.Text; clientRow["recorddate"] = client.dtpRecordDate.Value; clientRow["note"] = client.txtNotes.Text;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.Source);
}
}
//-----------------------------------------------------------------------
private void dgGroups_DoubleClick(object sender, System.EventArgs e)
{
try
{
int selectedGroupRowID = dgGroups.CurrentRowIndex;
if (selectedGroupRowID >= 0)
{
int selectedCourseID = dgCourses.CurrentRowIndex; DataView dvCourses = (DataView)dgCourses.DataSource;
DataRow selectedCourseRow = dvCourses[selectedCourseID].Row;
DataView dvGroups = (DataView)dgGroups.DataSource;
DataRow selectedGroupRow = dvGroups[selectedGroupRowID].Row; frmGroup group = new frmGroup(mainDataSet, selectedGroupRow);
group.Text += selectedCourseRow["courseName"].ToString(); if (group.ShowDialog() == DialogResult.OK)
{
dgCourses_Click(dgCourses, new EventArgs());
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.Source);
}
}
//-----------------------------------------------------------------------
private void cmbDirections_Validated(object sender, System.EventArgs e)
{
if (cmbDirections.SelectedIndex >= 0 && cmbGroupStatus.SelectedIndex >= 0) btnShowGroups.Enabled = true;
else
btnShowGroups.Enabled = false;
}
//-----------------------------------------------------------------------
private void cmbGroupStatus_Validated(object sender, System.EventArgs e)
{
if (cmbDirections.SelectedIndex >= 0 && cmbGroupStatus.SelectedIndex >= 0) btnShowGroups.Enabled = true;
else
btnShowGroups.Enabled = false;
}
//-----------------------------------------------------------------------
private void frmManager_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
DataSet ds = mainDataSet.GetChanges();
if (ds != null)
if (MessageBox.Show("Были произведены изменения в таблицах.\nВы желаете обновить данные в базе данных
?", "Внимание", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
UpdateMainData();
if (MessageBox.Show("Вы действительно желаете выйти из программы ?", "Внимание", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
== DialogResult.No) e.Cancel = true;
}
//-----------------------------------------------------------------------
private void btnPrevDate_Click(object sender, System.EventArgs e)
{
int dataID = 0;
if (currManagerTotal.Position > 0)
{
currManagerTotal.Position -= 1;
DataRowView drvDataRow = (DataRowView)currManagerTotal.Current; dataID = (int)drvDataRow.Row["dataID"];
DateTime date = (DateTime)drvDataRow.Row["currentDate"]; lblDateTime.Text = date.ToString("dd MMMM yyyy");
}
DataRowView drvData = (DataRowView)currManagerTotal.Current;
CalculateTotalPage(drvData.Row);
currentDataID = dataID; switch (userGroup)
{
case frmAuthorization.UserGroup.PManagers: if (dataID == DataID)
dgIncome.ReadOnly = false; else
dgIncome.ReadOnly = true; break;
}
}
//-----------------------------------------------------------------------
private void btnNextDate_Click(object sender, System.EventArgs e)
{
int dataID = 0;
if (currManagerTotal.Position < mainDataSet.data.Rows.Count)
{
currManagerTotal.Position += 1;
DataRowView drvDataRow = (DataRowView)currManagerTotal.Current; dataID = (int)drvDataRow.Row["dataID"];
DateTime date = (DateTime)drvDataRow.Row["currentDate"]; lblDateTime.Text = date.ToString("dd MMMM yyyy");
}
DataRowView drvData = (DataRowView)currManagerTotal.Current;
CalculateTotalPage(drvData.Row);
currentDataID = dataID; switch (userGroup)
{
case frmAuthorization.UserGroup.PManagers: if (dataID == DataID)
dgIncome.ReadOnly = false; else
dgIncome.ReadOnly = true; break;
}
}
//-----------------------------------------------------------------------
private void cmbFilteringDirection_SelectionChangeCommitted(object sender, EventArgs e)
{
btnCalculateOwe.Enabled = true;
}
//-----------------------------------------------------------------------
private void btnCalculateOwe_Click(object sender, EventArgs e)
{
this.GetOweStatistic();
}
//-----------------------------------------------------------------------
private void cmiFindIncomeOutClient_Click(object sender, EventArgs e)
{
try
{
frmSearchClient f = new frmSearchClient(this.mainDataSet);
if ((f.ShowDialog() == DialogResult.OK) && (f.SelectedRow != null) && (dgIncome.CurrentCell.ColumnNumber == 0))
{
MainDataSet.dataRow totalRow = mainDataSet.data.FindBydataID(currentDataID);
DataView dvIncome = new DataView(mainDataSet.income); dvIncome.RowFilter = "dataID = " + currentDataID.ToString();
DataRow incomeRow = dvIncome[dgIncome.CurrentRowIndex].Row;
incomeRow["clientID"] = (int)f.SelectedRow["clientID"];
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.Source);
}
}
//-----------------------------------------------------------------------
private void income_RowChanging(object sender, DataRowChangeEventArgs e)
{
MessageBox.Show("OK");
}
//-----------------------------------------------------------------------
private void dgClients_MouseUp(object sender, MouseEventArgs e)
{
try
{
Point point = new Point(e.X, e.Y); System.Windows.Forms.DataGrid.HitTestInfo hti = dgClients.HitTest(point);
dgClients.ContextMenu = null; if (hti.Row >= 0)
{
if (e.Button == MouseButtons.Right)
{
cmiFindClientsClientID.Visible = false;
if (hti.Column == 0) cmiFindClientsClientID.Visible = true;
dgClients.CurrentRowIndex = hti.Row; cmClients.Show(dgClients, point);
}
btnDeleteClient.Enabled = true;
DataTable table = (DataTable)dgClients.DataSource;
if (hti.Row <= table.Rows.Count - 1)
btnDeleteClient.Tag = table.Rows[hti.Row]["clientID"];
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.Source);
}
}
//-----------------------------------------------------------------------
private void cmiFindClientsClientID_Click(object sender, EventArgs e)
{
try
{
frmSearchClient f = new frmSearchClient(this.mainDataSet);
if ((f.ShowDialog() == DialogResult.OK) && (f.SelectedRow != null) && (dgClients.CurrentCell.ColumnNumber == 0))
{
DataTable dtClients = (DataTable)dgClients.DataSource; DataRow clientRow = dtClients.Rows[dgClients.CurrentRowIndex];
DataGridColumnStyle column = dgClients.TableStyles["clients"].GridColumnStyles[0]; column.ReadOnly = false;
clientRow["clientID"] = (int)f.SelectedRow["clientID"];
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.Source);
}
}
//-----------------------------------------------------------------------
private void btnFindPasteClient_Click(object sender, EventArgs e)
{
frmSearchClient f = new frmSearchClient(this.mainDataSet);
if (f.ShowDialog() == DialogResult.OK)
{
DataRow newClient = mainDataSet.clients.NewRow();
int intClientIDToTableClientGroups; intClientIDToTableClientGroups = (int)f.SelectedRow["clientID"];
// Добавляем данные в таблицу Group_Clients
DataRow newGroupClientRow = mainDataSet.group_clients.NewRow();
newGroupClientRow["clientID"] = intClientIDToTableClientGroups;
DataView dvGroups = (DataView)dgGroups.DataSource; DataRow group = dvGroups[dgGroups.CurrentRowIndex].Row; int groupID = (int)group["groupID"]; newGroupClientRow["groupID"] = groupID;
mainDataSet.group_clients.Rows.Add(newGroupClientRow);
dgGroups_Click(dgGroups, new EventArgs());
}
}
//-----------------------------------------------------------------------
private void menuItem8_Click(object sender, System.EventArgs e)
{
this.LoadPaymentDataBase();
}
//-----------------------------------------------------------------------
private void frmManager_Closed(object sender, EventArgs e)
{
System.Environment.Exit(1);
}
//-----------------------------------------------------------------------
private void miChangePassword_Click(object sender, EventArgs e)
{
frmPassword pass = new frmPassword();
if (pass.ShowDialog() == DialogResult.OK)
{
}
}
//-----------------------------------------------------------------------
private void dgIncome_MouseUp(object sender, MouseEventArgs e)
{
try
{
this.RemoveTempFindControl();
if (e.Button == MouseButtons.Right)
{
int delta = 0;
DataGrid dg = (DataGrid)sender; DataGrid.HitTestInfo hti = dg.HitTest(e.X, e.Y); DataView dv = (DataView)currManagerIncome.List;
FindControl.FindControl fc = null;
int columnIndex = hti.Column; int rowIndex = hti.Row;
if ((columnIndex == -1) || (rowIndex == -1)) return;
else
{
fc = new FindControl.FindControl(); fc.Visible = true;
fc.Tag = "Temp";
string tableName = dg.Tag.ToString();
delta = (tableName == "income") ? 0 : 60 ; fc.Table = mainDataSet.Tables[tableName];
fc.TargetRow = (tableName == "income") ? this.GetTablesRow(fc.Table, rowIndex, currManagerIncome)
:
this.GetTablesRow(fc.Table, rowIndex, currManagerOut);
if (fc.TargetRow == null)
{
Exception ex = new Exception("Ошибка получения записи.");
throw ex;
}
// Выбрано поле ClientID в таблице expenses или income
if (((tableName == "income") || (tableName == "expenses")) && (columnIndex == 3))
{
fc.SelectingForm = new frmSearchClient(this.mainDataSet); int objectID = (int)fc.TargetRow["ClientID"];
DataRow personRow = (DataRow)mainDataSet.clients.FindByclientID(objectID); //fc.PersonForm = new frmClient(personRow, this.mainDataSet); fc.PersonForm = new frmClient(this.mainDataSet);
fc.ColumnName = "clientID"; fc.Text = "Client";
}
// Выбрано поле PaymentTypeID в таблице expenses или income
else if (((tableName == "income") || (tableName == "expenses")) && (columnIndex == 1))
{
fc.SelectingForm = new frmPaymentType(this.mainDataSet); fc.PersonForm = new frmPaymentType(this.mainDataSet); fc.ColumnName = "payment_typeID";
fc.Text = "Payment";
}
// Выбрано поле EmployeeID в таблице expenses
else if ((tableName == "expenses") && (columnIndex == 4))
{
fc.SelectingForm = new frmEmployee(this.mainDataSet); fc.PersonForm = new frmEmployee(this.mainDataSet); fc.ColumnName = "employeeID";
fc.Text = "Employee";
}
else return;
// Добавляем пользовательский элемент управления поиска this.tcManager.TabPages[2].Controls.Add(fc);
Point worldPoint = dg.PointToScreen(new Point(e.X - delta, e.Y));
Point controlPoint = tcManager.PointToClient(worldPoint);
fc.Location = controlPoint; fc.BringToFront();
fc.RowSelected += new FindControl.RowSelectedDelegate(fc_RowSelected);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.Source);
}
}
//-----------------------------------------------------------------------
private void fc_RowSelected(FindControl.FindControl findControl, DataTable table)
{
try
{
SelectingFormInterface.ISelectingForm selectingForm = findControl.SelectingForm;
if (selectingForm.SelectedRow == null)
{
MessageBox.Show("Не выбрана запись", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
}
else
{
findControl.TargetRow[findControl.ColumnName] = selectingForm.SelectedRow[findControl.ColumnName];
if (findControl.TargetRow.RowState == DataRowState.Detached) table.Rows.Add(findControl.TargetRow);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.Source);
}
}
//-----------------------------------------------------------------------
private void btnShowPaymentTypeForm_Click(object sender, EventArgs e)
{
frmPaymentType fpt = new frmPaymentType(this.mainDataSet);
fpt.ShowDialog();
}
//-----------------------------------------------------------------------
private void frmManager_Load(object sender, EventArgs e)
{
this.SetWitdhForDataGrids();
}
//-----------------------------------------------------------------------
private void dtClients_RowChanged(object sender, DataRowChangeEventArgs e)
{
DataRow clientRow = mainDataSet.clients.FindByclientID((int)e.Row["clientID"]);
clientRow["fname"] = e.Row["fname"]; clientRow["lname"] = e.Row["lname"]; clientRow["fathName"] = e.Row["fathName"]; clientRow["linkData"] = e.Row["linkData"]; clientRow["recorddate"] = e.Row["recorddate"]; clientRow["note"] = e.Row["note"]; clientRow["paymentType"] = e.Row["paymentType"]; clientRow["isRinged"] = e.Row["isRinged"];
}
private void menuItem12_Click(object sender, System.EventArgs e)
{
this.UpdateMainData();
}
private void mnuUpdateMainDataBase_Click(object sender, System.EventArgs e)
{
this.UpdateMainData();
}
// Удаление клиента со страницы 'Приемная'
private void btnDeleteClient_Click(object sender, EventArgs e)
{
try
{
if (btnDeleteClient.Tag == null)
{
MessageBox.Show("Нельзя удалить клиента!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
}
int clientID = (int)btnDeleteClient.Tag;
MainDataSet.clientsRow clientRow = mainDataSet.clients.FindByclientID(clientID); btnDeleteClient.Enabled = false;
clientRow.Delete(); dgGroups_Click(dgGroups, new EventArgs());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.Source);
}
}
#endregion
#region Переопределяемые методы
protected override void Dispose( bool disposing )
{
// Описание метода
}
//-----------------------------------------------------------------------
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint (e);
}
#endregion
}
}
Листинг 11.2.
Форма frmAuthorization — форма авторизациипользователей
При запуске программы пользователь вводит свой логин в домене и пароль (см. рис. 11.1). К примеру, мы рассматриваем домен SomeDomain. Пользователь вводит свою учетную запись в домене, например SomeDomain\someUser, и пароль. Далее проверяется принадлежность пользователя группам Administrators, Managers, Recipients. Эти группы пользователей должны быть предварительно созданы администратором, в противном случае пользователь будет иметь группу FailGroup и не сможет запустить программу. Если пользователь авторизован, то, в зависимости от принадлежности к группе, интерфейс программы будет выглядеть по-разному, т.е. какие-то функции доступны, а какие-то — нет.
Приступим к созданию этой формы. Помещаем на форму из панели ToolBox следующие элементы управления:
Два элемента TextBox: txtUserName и txtPassword и две надписи Label со свойствами Text "User name:" и "Password:" соответственно. Для элементов TextBox создаем обработчики события TextChanged (см. код программы).
Добавляем на форму две кнопки btnOK и btnCancel со свойствами Text "OK" и "Cancel" соответственно. Для них создаем обработчиков события Click (см. код программы). Также устанавливаем свойства DialogResult для этих кнопок "OK" и "Cancel" соответственно.
Устанавливаем следующие свойства формы:
frmAuthorization, Свойство Значение
Text |
Authorization |
AcceptButton |
btnOK |
CancelButton |
btnCancel |
Добавляем в класс формы frmAuthorization следующие методы:
Сигнатура методов |
Описание методов |
private void OpenMainForm(UserGroup userGroup, Label |
Открытие главной формы для пользователя с данной группой |
label) |
прав |
private void CheckLogin() |
Авторизация пользователя |
private void InitialDefaultSettings() |
Настройки по умолчанию |
private void CheckTextBoxes() |
Проверка полей ввода |
Создаем обработчик события Activate для формы (см. код программы).
Также в класс формы добавим перечисление с константами групп пользователей:
internal enum UserGroup
{
Administrators,
Managers,
Recipients,
FailGroup
}
Листинг формы frmAuthorization:
using System;
using System.Drawing; using System.Collections;
using System.ComponentModel; using System.Security.Principal; using System.Windows.Forms; using System.DirectoryServices; using System.Management;
using Manager.Schemas; using Manager.Forms;
using System.Globalization;
using System.Security.Permissions; using System.Threading;
namespace Manager
{
public class frmAuthorization : System.Windows.Forms.Form
{
// Объявление элементов управления.
internal enum UserGroup
{
Administrators,
Managers,
Recipients, FailGroup
}
public frmAuthorization()
{
InitializeComponent();
this.InitialDefaultSettings();
}
// Открытие главной формы для пользователя с определенной группой доступа. private void OpenMainForm(UserGroup userGroup, Label label)
{
frmManager mainForm = new frmManager();
mainForm.userGroup = userGroup; switch (userGroup)
{
case UserGroup.Administrators: mainForm.panel12.Visible = true; mainForm.gbPaymentDB.Visible = true; mainForm.tbMain.Buttons[3].Visible = true; mainForm.rbDataMain.Visible = true; mainForm.rbIncomeMain.Visible = true; mainForm.rbOutMain.Visible = true; mainForm.dgWorkTable.ReadOnly = false;
mainForm.tcManager.SelectedTab = mainForm.tcManager.TabPages[1]; mainForm.mnuSecurity.Visible = false; mainForm.btnShowPaymentTypeForm.Visible = true;
break;
case UserGroup.Managers: mainForm.panel12.Visible = false; mainForm.panel16.Dock = DockStyle.Fill; mainForm.panel18.Visible = false; mainForm.gbPaymentDB.Visible = false; mainForm.tbMain.Buttons[3].Visible = false; mainForm.rbDataMain.Visible = false; mainForm.dgOut.Visible = false; mainForm.splitter2.Visible = false; mainForm.rbIncomeMain.Visible = true; mainForm.rbOutMain.Visible = false; mainForm.dgWorkTable.ReadOnly = false;
mainForm.tcManager.SelectedTab = mainForm.tcManager.TabPages[0]; mainForm.mnuSecurity.Visible = false; mainForm.btnShowPaymentTypeForm.Visible = false;
break;
case UserGroup.Recipients: mainForm.panel12.Visible = false; mainForm.panel16.Dock = DockStyle.Fill; mainForm.panel18.Visible = false; mainForm.gbPaymentDB.Visible = false; mainForm.tbMain.Buttons[3].Visible = false; mainForm.rbDataMain.Visible = false; mainForm.dgOut.Visible = false; mainForm.splitter2.Visible = false; mainForm.rbIncomeMain.Visible = false; mainForm.rbOutMain.Visible = false; mainForm.dgWorkTable.ReadOnly = false;
mainForm.tcManager.SelectedTab = mainForm.tcManager.TabPages[0]; mainForm.gbBaseTables.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; mainForm.mnuSecurity.Visible = false; mainForm.btnShowPaymentTypeForm.Visible = false;
break;
case UserGroup.FailGroup:
MessageBox.Show("Вы не имеете полномочий запускать данное приложение.\n\n" + "Чтобы запустить, приложение вам необходимо принадлежать группам:\n" +
"Administrators, Managers или Recipients.\n\n" +
"Проверьте учетную запись или обратитесь к администратору.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
System.Environment.Exit(1);
break;
}
label.Text = "Loading database ..."; mainForm.LoadMainDataBase();
