private void button1_Click(object sender, EventArgs e) { int x = source; if (x == 1) { if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "")//validation part { MessageBox.Show("Please, insert all values"); } else { int r = controllerObj.AddStore(textBox1.Text.ToString(), textBox2.Text.ToString(), textBox3.Text.ToString(), textBox4.Text.ToString()); if (r > 0) { MessageBox.Show("Store inserted successfully"); DataTable dt = controllerObj.GetStores(); dataGridView1.DataSource = dt; dataGridView1.Refresh(); } else { MessageBox.Show("Insertion Failed"); } } } if (x == 2) { if (textBox1.Text == "") //validation part { MessageBox.Show("Please, insert all values"); } else { int r = controllerObj.RemoveStore(textBox1.Text.ToString()); if (r > 0) { MessageBox.Show("Store Removed successfully"); DataTable dt = controllerObj.GetStores(); dataGridView1.DataSource = dt; dataGridView1.Refresh(); } else { MessageBox.Show("Removal Failed"); } } } if (x == 3) { if (textBox1.Text == "")//validation part { MessageBox.Show("Please, insert all values"); } else { int cv, cvv, cvvv; int.TryParse(textBox1.Text, out cv); int.TryParse(textBox3.Text, out cvv); int.TryParse(textBox4.Text, out cvvv); if (cv != 0 && cvv != 0 && cvvv != 0) { int r = controllerObj.AssignPrint(textBox1.Text.ToString(), textBox3.Text.ToString(), textBox4.Text.ToString()); if (r > 0) { MessageBox.Show("Price Assigned successfully"); DataTable dt = controllerObj.GetPrintOrders(); dataGridView1.DataSource = dt; dataGridView1.Refresh(); } else { MessageBox.Show("Assigning Failed"); } } else { MessageBox.Show("Please enter correct values"); } } } if (x == 4) { if (textBox1.Text == "" || textBox2.Text == "") //validation part { MessageBox.Show("Please, insert all values"); } else { string passhashedold = CheckPassword_Hash(textBox2.Text); int r = controllerObj.AddAdmin(textBox1.Text.ToString(), passhashedold); if (r > 0) { MessageBox.Show("Admin inserted successfully"); DataTable dt = controllerObj.GetAdmins(); dataGridView1.DataSource = dt; dataGridView1.Refresh(); } else { MessageBox.Show("Insertion Failed"); } } } if (x == 5) { if (textBox1.Text == "")//validation part { MessageBox.Show("Please, insert all values"); } else if (textBox1.Text == "Admin1") { MessageBox.Show("You Can't Remove Main Admin"); } else { int r = controllerObj.RemoveAdmin(textBox1.Text.ToString()); if (r > 0) { MessageBox.Show("Admin Removed successfully"); DataTable dt = controllerObj.GetAdmins(); dataGridView1.DataSource = dt; dataGridView1.Refresh(); } else { MessageBox.Show("Removal Failed"); } } } if (x == 6) { string passhashedold = CheckPassword_Hash(textBox1.Text); if (textBox1.Text == "" || textBox2.Text == "") //validation part { MessageBox.Show("Please, insert all values"); } else { string query; query = "SELECT username from Admin where username = '******' and password='******';"; int privlg = controllerObj.CheckPassword_Basic(query); if (privlg > 0) { string passhashed = CheckPassword_Hash(textBox2.Text); int r = controllerObj.UpdateAdminPass(username, passhashed); if (r > 0) { MessageBox.Show("Password updated successfully"); } } else { MessageBox.Show("Please make sure you entered right OldPassward"); } } } }