//public clsResize FormResize; public MainForm() { InitializeComponent(); SetStyle(ControlStyles.ResizeRedraw, true); SessionClass.Instance().Form = this; //this.AutoScaleMode = AutoScaleMode.Dpi; //FormResize = new clsResize(this); }
public static SessionClass Instance() { if (instance == null) { instance = new SessionClass(); } return(instance); }
private void buttonAuth_Click(object sender, EventArgs e) { try { var HashPass = Utilities.GenerateHash(textBoxPassword.Text); SessionClass.Instance().User = SessionClass.Instance().Context.Users.FirstOrDefault(u => u.Username == textBoxUsername.Text && u.Password == HashPass); var user = SessionClass.Instance().User; var form = SessionClass.Instance().Form; if (user == null) { MessageBox.Show("Неправильный логин или пароль"); return; } form.labelName.Text = $"{User.S_Access[(int)user.AccessLVL]} | " + $"{user.Employee.Name} " + $"{user.Employee.Surname[0]}." + $"{user.Employee.Patronymic[0]}."; form.panelMain.Controls.Clear(); form.panelMenu.Visible = true; form.labelTopPanel.Text = "Главное меню"; switch (SessionClass.Instance().User.AccessLVL) { case User.E_Access.Administrator: form.buttonMenu3.Enabled = true; form.buttonMenu4.Enabled = true; break; case User.E_Access.Moderator: form.buttonMenu3.Enabled = true; form.buttonMenu4.Enabled = false; break; case User.E_Access.SimpleUser: form.buttonMenu3.Enabled = false; form.buttonMenu4.Enabled = false; break; } form.pictureBoxBackGround.Visible = true; } catch (Exception er) { MessageBox.Show("Ошбика авторизации\nОшбика: " + er.Message); } }
private void buttonOrderAdd_Click(object sender, EventArgs e) { if (panelAddOrder.CheckFullnessOfContols()) { Order order = new Order(); order.Client = (Client)comboBoxClients.SelectedItem; order.Cost = Convert.ToDecimal(textBoxCost.Text); order.Currency = comboBoxCurrency.Text; order.Domen = textBoxDomen.Text; order.DateTime = DateTime.Now; order.Employee = SessionClass.Instance().User.Employee; order.DateOfEnd = dateTimePickerOrderEnd.Value; order.Server = (Server)comboBoxServers.SelectedItem; context.Orders.Add(order); context.SaveChanges(); UpdateTable(context.Orders.ToList()); } }
public static bool CheckConnection(string connStr) { SessionClass.Instance().Context.Database.Connection.ConnectionString = connStr; return(SessionClass.Instance().Context.Database.Exists()); }