private void ClosingTheForm() { DialogResult dialogResult = MessageBox.Show("Are you sure you want to exit?", "Logout", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { string query = "UPDATE users SET login_status=0 WHERE userID='" + user.GetUserID() + "'"; dbcon.ManipulateData(query); string uid = user.GetUserID(); log.userLogout(uid, date, "Logged Out"); Close(); } else if (dialogResult == DialogResult.No) { //do something else } }
public void RemoveZero() { try { string query = "DELETE FROM stock WHERE stock_quantity=0"; dbcon.ManipulateData(query); } catch (Exception) { throw; } }
private void btnDelete_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this viscosity?", "Inventory", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { query = "DELETE FROM viscosity WHERE viscosity_ID='" + txtViscNum.Text + "'"; dbcon.ManipulateData(query); MessageBox.Show("Deleted a viscosity", "Inventory"); btnClear.PerformClick(); } else if (dialogResult == DialogResult.No) { //do something else } }
private void btnOK_Click(object sender, EventArgs e) { string un = txtUN.Text; string pw = txtPW.Text; string[] result; //to do: filter the input //to do: byte[] data = System.Text.Encoding.UTF8.GetBytes ("stRhong%pword"); // byte[] hash = SHA256.Create().ComputeHash(data); //The GetBytes method on an Encoding object converts a string to a byte array; the GetString method converts it back. An Encoding object cannot, however, convert an encrypted or hashed byte array to a string, because scrambled data usually violates text encoding rules.Instead, use Convert .ToBase64String and Convert.FromBase64String : these convert between any byte array and a legal(and XML - friendly) string. //byte[] data = System.Text.Encoding.UTF8.GetBytes(pw); //byte[] hash = SHA256.Create().ComputeHash(data); classDatabaseConnect dbConnObj = new classDatabaseConnect(); result = dbConnObj.authenticate(un, pw); if (result == null) { MessageBox.Show("Please provide a valid credential", "Login", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (result[3] == "True") { MessageBox.Show("User is logged-in in other computer", "Login", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { user.SetUserID(result[0]); user.SetGName(result[1]); user.SetPrivelge(result[2]); user.SetLoginStatus(result[3]); string q = "UPDATE users SET login_status=1 WHERE userID='" + user.GetUserID() + "'"; dbConnObj.ManipulateData(q); MessageBox.Show("Welcome " + user.GetGName(), "Login", MessageBoxButtons.OK, MessageBoxIcon.Information); string uid = user.GetUserID(); log.userLogin(uid, dt, "Logged In"); Close(); } }
private void btnDelete_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this employee?", "Manage Employee", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { query = "DELETE FROM employee WHERE emp_ID='" + txtEmpNo.Text + "'"; dbcon.ManipulateData(query); MessageBox.Show("Deleted an employee", "Manage Employee"); btnClear.PerformClick(); } else if (dialogResult == DialogResult.No) { //do something else } }
private void btnSDelete_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this service?", "Services", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { query = "DELETE FROM service WHERE service_ID='" + txtServiceID.Text + "'"; dbcon.ManipulateData(query); MessageBox.Show("Deleted a service", "Service"); btnSClear.PerformClick(); } else if (dialogResult == DialogResult.No) { //do something else } }