Exemplo n.º 1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            context = new HotelContext();
            AuthorizationForm authorizationForm = new AuthorizationForm(context);

            try
            {
                if (authorizationForm.ShowDialog() == DialogResult.OK)
                {
                    var roomQuery      = from roomItem in context.Rooms select roomItem;
                    var employeesQuery = from employeeItem in context.Employees select employeeItem;
                    roomsCount.Text                    = roomQuery.Count().ToString();
                    employeesCount.Text                = employeesQuery.Count().ToString();
                    UserName                           = authorizationForm.UserName;
                    AdminRights                        = authorizationForm.AdminRights;
                    toolStripStatusLabel.Text          = "Текущий пользователь: " + UserName;
                    usersDataToolStripMenuItem.Enabled = AdminRights;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Ошибка чтения данных!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
            }
        }
Exemplo n.º 2
0
        private void changeUserToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Visible = false;
            AuthorizationForm authorizationForm = new AuthorizationForm(context);

            if (authorizationForm.ShowDialog() == DialogResult.OK)
            {
                Visible     = true;
                UserName    = authorizationForm.UserName;
                AdminRights = authorizationForm.AdminRights;
                toolStripStatusLabel.Text          = "Текущий пользователь: " + UserName;
                usersDataToolStripMenuItem.Enabled = AdminRights;
            }
        }