static void Main(string[] args) { LogHelper.Initialize($@"{Application.StartupPath}\log4net.config"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (args.Length == 0) { Application.Run(new LoginForm()); } else { string userId = ""; string passWd = ""; int i = 0; while (i < args.Length) { if (args[i] == "-user") { userId = args[i + 1]; i++; } else if (args[i] == "-password") { passWd = args[i + 1]; i++; } else { Application.Exit(); } i++; } string error; bool rslt = ConnectInfo.Login(userId, passWd, out error); if (rslt) { BonusSkins.Register(); SkinManager.EnableFormSkins(); UserLookAndFeel.Default.SetSkinStyle("DevExpress Style"); SqlClientForm form = new SqlClientForm(); form.LoginUser = userId; form.Password = passWd; Application.Run(form); } else { Application.Exit(); } } }
private void btnLogin_Click(object sender, EventArgs e) { try { string error; bool rslt = ConnectInfo.Login(this.txtUser.Text, this.txtPassword.Text, out error); if (!rslt) { this.tipMsg.Show(error, this.txtUser); } else { string args = $"-user {this.txtUser.Text} -password {this.txtPassword.Text}"; string fileName = Application.ExecutablePath; Process proc = Process.Start(fileName, args); proc.WaitForInputIdle(); Application.Exit(); } } catch (Exception ex) { LogHelper.Error(ex); } }