void lf_OnLogin(LoginForm sender, string login, string password, out bool success)
        {
            try
            {
                refreshEvents(login);

                Account.tryLogin(login, password);

                if (Account.Current != null)
                {
                    //15 minutes
                    var timer = new System.Timers.Timer(900000);

                    timer.Elapsed += timer_Elapsed;
                    timer.Enabled = true;
                }

            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            success = (Account.Current != null);

            DataHelper.CustomFormulas = new List<CalcFormula>();
            DataHelper.CustomFormulas.Add(new QGasCalculation());

            using (var con = DataHelper.OpenOrCreateDb())
            {
                foreach (var d in DataHelper.CustomFormulas)
                {
                    foreach (var p in d.InitPredicates()) DataHelper.GetParameter(p, con, true);
                    DataHelper.GetParameter(d.Name, con, true);
                }
            }
        }
 void lf_OnCancel(LoginForm sender)
 {
     Close();
 }
        private void OnFormLoad(object sender, EventArgs e)
        {
            var lf = new LoginForm();
            lf.OnLogin += lf_OnLogin;
            lf.OnCancel += lf_OnCancel;

            lf.ShowDialog();
        }
 private void changePasswordMenuClick(object sender, EventArgs e)
 {
     int row = accountsView.FocusedRowHandle;
     Account selected = users[row];
     var dialog = new LoginForm("Смена пароля", selected.Login, false);
     dialog.OnLogin += OnChangePassword;
     dialog.ShowDialog();
 }
 private void addAccountMenuClick(object sender, EventArgs e)
 {
     var dialog = new LoginForm("Создание нового пользователя");
     dialog.OnLogin += OnAddUser;
     dialog.ShowDialog();
 }
 void OnChangePassword(LoginForm sender, string login, string password, out bool success)
 {
     try
     {
         int row = accountsView.FocusedRowHandle;
         Account selected = users[row];
         Account.changePassword(selected, password);
         success = true;
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Ошибка");
         success = false;
     }
 }
 void OnAddUser(LoginForm sender, string login, string password, out bool success)
 {
     try {
         success = Account.createAccount(login, password, Account.Roles.User) != null;
         refreshUserList();
     } catch (Exception e) {
         MessageBox.Show(e.Message, "Ошибка");
         success = false;
     }
 }