Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (adminyes.Checked == true || adminno.Checked == true && textBox1.Text != null && textBox2.Text != null && textBox3.Text != null)
- {
- admin = "Yes";
- if (mode == "a")
- {
- x = 0;
- connect.Close();
- connect.ConnectionString = inventorydb;
- connect.Open();
- sqlcommand.CommandText = "SELECT * FROM Users WHERE Username ='" +textBox2.Text+ "' Or User_ID ='" +textBox1.Text+ "' ";
- sqlcommand.Connection = connect;
- OleDbDataReader reader = sqlcommand.ExecuteReader();
- while (reader.Read())
- {
- x++;
- }
- if (x != 0)
- {
- MessageBox.Show("", "",MessageBoxButtons.OK);
- }
- else
- {
- DialogResult res = MessageBox.Show("Are you sure?", "Save User", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
- if (DialogResult.Yes == res)
- {
- connect.Close();
- connect.ConnectionString = inventorydb;
- connect.Open();
- sqlcommand.CommandText = "INSERT INTO Users (User_ID, Username, Password, Admin) VALUES ('" + textBox1.Text + "','" + textBox2.Text + "', '" + textBox3.Text + "', '" + admin + "') ";
- sqlcommand.Connection = connect;
- reader = sqlcommand.ExecuteReader();
- MessageBox.Show("Record(s) Saved", "Sample");
- }
- reset();
- }
- }
- else if (mode == "e")
- {
- DialogResult res = MessageBox.Show("Are you sure?", "Update User", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
- if (DialogResult.Yes == res)
- {
- connect.Close();
- connect.ConnectionString = inventorydb;
- connect.Open();
- sqlcommand.CommandText = "UPDATE Users SET User_ID = '" + textBox1.Text + "', Username = '" + textBox2.Text + "', Password = '" + textBox3.Text + "',Admin = '" + admin + "' WHERE SerialID = '" + idholder + "' ";
- sqlcommand.Connection = connect;
- OleDbDataReader reader = sqlcommand.ExecuteReader();
- reader.Read();
- MessageBox.Show("Record(s) Updated", "Sample");
- }
- reset();
- }
- }
- else
- {
- MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement