private void pbBack_Click(object sender, EventArgs e) { FAdminCashier fac = new FAdminCashier(); fac.Show(); this.Hide(); }
private void pbAdd_Click(object sender, EventArgs e) { if (txtIdCashier.Text == "full") { MessageBox.Show("data already full"); FAdminCashier fac = new FAdminCashier(); fac.Show(); this.Hide(); } else if (txtPass.Text == "" || txtCoPass.Text == "") { MessageBox.Show("Please fill in the data"); } else if (txtPass.Text != txtCoPass.Text) { MessageBox.Show("Password and repassword not match"); } else { string info = ""; bool test = true; try { info = con.openconnection(); if (info == "OK") { string query = "select count(Username) as Username from AccessLogin where Username = '******'"; SqlCommand com = new SqlCommand(query, con.con); SqlDataReader dr = com.ExecuteReader(); while (dr.Read()) { //string idpay = dr["Id_Payment"].ToString(); string username = dr["Username"].ToString(); if (username == "0") { DialogResult result = MessageBox.Show("Do you want to save record " + txtUser.Text + "?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { test = false; } } else { MessageBox.Show("Username already available"); } } dr.Close(); } if (con.closeconnection() == "OK") { info = "OK"; } } catch (Exception xe) { MessageBox.Show(xe.Message); } if (test == false) { insertdata(); } } }