private void bt1_Click(object sender, EventArgs e) { if (Username.Text == "Username" || Nama.Text == "Nama" || Password.Text == "Password" || Email.Text == "NomorHP") { MessageBox.Show("PLEASE FILL THE BLANK"); } else { if (Retype.Text != Password.Text) { label2.Visible = true; } else { label2.Visible = false; String sql = "insert into ADMIN (USERNAME_ADMIN,PASSWORD_ADMIN,NAMA_ADMIN,EMAIL_ADMIN) values ('" + Username.Text + "','" + Password.Text + "','" + Nama.Text + "','" + Email.Text + "');"; MySqlCommand cmd = new MySqlCommand(sql, conn); int affected = cmd.ExecuteNonQuery(); if (affected >= 1) { ((Form)this.TopLevelControl).Hide(); MessageBox.Show("Mashok"); adminParent ap = new adminParent(); ap.Hide(); adminLogin f1 = new adminLogin(); f1.Show(); } } } }
private void login() { int count = 0; String sql = "select * from ADMIN where USERNAME_ADMIN='" + Username.Text + "' and PASSWORD_ADMIN='" + Password.Text + "';"; MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlDataReader reader = cmd.ExecuteReader(); this.admin = Username.Text; while (reader.Read()) { count += 1; this.idAdmin = reader["ID_ADMIN"].ToString(); this.idAdminInt = Convert.ToInt32(this.idAdmin); } //reader.Close(); if (count == 1) { //menuju ((Form)this.TopLevelControl).Hide(); adminChildDataView sg = new adminChildDataView(); adminParent f2 = new adminParent(sg, this.idAdmin); f2.Show(); } else if (Username.Text == "Username" || Password.Text == "Password" || Username.Text == "") { MessageBox.Show("Fill Username and Password"); } else { MessageBox.Show("Incorrect Username or Password"); } reader.Close(); }