private void OnAddUser(object sender, EventArgs e) { using (var form = new CreateUserForm()) { form.ShowDialog(); } }
static void Main() { log4net.Config.XmlConfigurator.Configure(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!File.Exists("WriteLines.txt")) { PassSQL SqlForm = new PassSQL(); SqlForm.ShowDialog(); if (SqlForm.DialogResult == DialogResult.Cancel) { return; } } try { string[] lines = System.IO.File.ReadAllLines("WriteLines.txt"); DatabaseFactory.CreateNewDatabase("", GetConnectionString(lines[0], lines[1])); } catch (Exception e) { File.Delete("WriteLines.txt"); MessageBox.Show("Lỗi database! Xin chạy lại chương trình!"); Log.Error(e.Message, e); } try { if (!Helper.checkAdminExists(DatabaseContants.tables.clinicuser)) { CreateUserForm createUserForm = new CreateUserForm(); if (createUserForm.ShowDialog() == DialogResult.OK) { LoginForm login = new LoginForm(); if (login.ShowDialog() == DialogResult.OK) { Application.Run(new Form1(LoginForm.Authority, LoginForm.Name1)); } } } else { LoginForm login = new LoginForm(); if (login.ShowDialog() == DialogResult.OK) { Application.Run(new Form1(LoginForm.Authority, LoginForm.Name1)); } } } catch (Exception ex) { Log.Error(ex.Message, ex); } }
private void CreateFirstUser(EventArgs args) { NoUsersDetected?.Invoke(this, args); var res = MessageBox.Show("There are no users now, do you want to create new one?", "No users yet", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (res == DialogResult.Yes) { using (var form = new CreateUserForm()) { form.ShowDialog(); } } else { ClosingFormInvoked?.Invoke(this, args); } }