static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Order_From()); if (false) { var Login = new Login_Form(); var User = new Main_Form(); DialogResult result = Login.ShowDialog(); if (result == DialogResult.OK) { Application.Run(new Main_Form()); } else { MessageBox.Show("Cencel"); } } }
private void ButtonLogin_Click(object sender, EventArgs e) { CONNECT conn = new CONNECT(); DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand command = new MySqlCommand(); String query = "SELECT * FROM `user` WHERE `username`=@usn AND `username`=@pass"; command.CommandText = query; command.Connection = conn.getConnection(); command.Parameters.Add("@usn", MySqlDbType.VarChar).Value = textBoxUsername.Text; command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = textBoxPassword.Text; adapter.SelectCommand = command; adapter.Fill(table); if (table.Rows.Count > 0) { this.Hide(); Main_Form mform = new Main_Form(); mform.Show(); } else { if (textBoxUsername.Text.Trim().Equals("")) { MessageBox.Show("Enter Your Username to Login", "Empty Username", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (textBoxPassword.Text.Trim().Equals("")) { MessageBox.Show("Enter Your Password to Login", "Empty Password", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("This Username Or Password Doesn't Exists", "Wrong Data", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }