static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var mainForm = new frmMain(); mainForm.trayMenu = new ContextMenu(); mainForm.trayMenu.MenuItems.Add("Hide", (sender, e) => { if (mainForm.trayMenu.MenuItems[0].Text == "Show") { mainForm.Show(); mainForm.trayMenu.MenuItems[0].Text = "Hide"; } else { mainForm.Hide(); mainForm.trayMenu.MenuItems[0].Text = "Show"; } }); mainForm.trayMenu.MenuItems.Add("Exit", (sender, e) => { mainForm.Close(); Application.Exit(); }); mainForm.trayIcon = new NotifyIcon(); mainForm.trayIcon.Text = "Esperantilo"; mainForm.trayIcon.Icon = mainForm.Icon; mainForm.trayIcon.ContextMenu = mainForm.trayMenu; mainForm.trayIcon.Visible = true; Application.Run(mainForm); }
private void btnLogin_Click(object sender, EventArgs e) { DBConnString.strConn = "Data Source=192.168.1.13;Initial Catalog=ASSET; Persist Security Info=True;User ID=sa;Password=Ye11@wwin9"; DBConnString.clsDB = new clsDatabase(DBConnString.strConn, DBConnString.sServer); string strConn; strConn = DBConnString.strConn; Conn = new SqlConnection(); if (Conn.State == ConnectionState.Open) { Conn.Close(); } Conn.ConnectionString = strConn; Conn.Open(); if (!DBConnString.clsDB.IsConnected()) { return; } if ((txtUserName.Text.Trim() == "") || (txtPassword.Text.Trim() == "")) { txtUserName.Focus(); return; } bool CurrentLogin = false; CurrentLogin = EmpLogin(txtUserName.Text, txtPassword.Text); if (CurrentLogin == true) { DBConnString.UserName = txtUserName.Text.Trim(); DBConnString.UserAuthentication = CurrentAuthentication; //Close(); this.Hide(); frmMain frm = new frmMain(); frm.Show(); } else { MessageBox.Show("Invalid Login Credentials", "Pilot Training Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); CurrentAuthentication = ""; txtUserName.Text = ""; txtUserName.Focus(); txtPassword.Text = ""; } }
protected override void OnFormClosing(FormClosingEventArgs e) { frmMain fm = new frmMain(); if (!CheckForm(fm)) { fm.Show(); } else { fm.WindowState = FormWindowState.Normal; fm.BringToFront(); fm.Activate(); } base.OnFormClosing(e); }
public void Getshow() { string Email = this.txtEmail.Text; string Pwd = this.txtPwd.Text; foreach (LoginInfo a in array) { if (a != null) { if (a.Email == Email && a.Password == Pwd) { frmMain f = new frmMain(); f.lblName.Text = "欢迎你:" + a.Name; f.Show(); } } } }
private void button3_Click(object sender, EventArgs e) { frmMain f = new frmMain(); f.Show(); }