static void Main() { #region Check Process running Process[] PatpedhiProcess; PatpedhiProcess = Process.GetProcessesByName("Patpedhi"); if (PatpedhiProcess.Length > 1) { MessageBox.Show("Petpedhi Application is already Running."); throw new Exception("Petpedhi Application is already Running."); } #endregion #region Change System Date Time Settings CheckDateSettings(); #endregion IDataProvider _IDataProvider = new DataProvider(); Assembly UIAssembly; UIAssembly = Assembly.LoadFrom("UI.dll"); Form LoginForm = (Form)UIAssembly.CreateInstance("Patpedhi.UI.MainLoginForm"); ((IDataProviderConsumer)LoginForm).IDataProvider = _IDataProvider; DialogResult dr = LoginForm.ShowDialog(); if (dr == DialogResult.OK) { } }
static void Main() { try { #region Change System Date Time Settings CheckDateSettings(); #endregion IDataProvider _IDataProvider = new DataProvider(); Assembly UIAssembly; UIAssembly = Assembly.LoadFrom("UI.dll"); Form LoginForm = (Form)UIAssembly.CreateInstance("Patpedhi.UI.MainLoginForm"); ((IDataProviderConsumer)LoginForm).IDataProvider = _IDataProvider; DialogResult dr = LoginForm.ShowDialog(); if (dr == DialogResult.Cancel) { Environment.Exit(Environment.ExitCode); } if (dr == DialogResult.OK) { LoginForm.Close(); Form ActivatedForm = null; ActivatedForm = (Form)UIAssembly.CreateInstance("Patpedhi.UI.MainForm"); if (LoginInfo.YearId != 0) { ((Form)ActivatedForm).Text = "MainForm Financial Year - " + LoginInfo.YearCode; } ((IDataProviderConsumer)ActivatedForm).IDataProvider = _IDataProvider; ActivatedForm.Show(); } //else if (dr != DialogResult.Retry) //{ // Environment.Exit(Environment.ExitCode); //} Application.Run(); } catch (Exception ex) { CustomException.CustomExceptionLog(ex); } }