private void button1_Click(object sender, EventArgs e) { this.Hide(); Manage_Users MU = new Manage_Users(); MU.Show(); }
private void button2_Click(object sender, EventArgs e) { try { SqlConnection sqlcon = new SqlConnection(@"Data Source=SELVAH\SQLSERVER;Initial Catalog=master;Integrated Security=True;"); sqlcon.Open(); SqlCommand cmd = new SqlCommand("insert into EmployeeDB ( LoginType, EmpID, Name, Date_Of_Joining, Gender,Contact_No, AddressInfo, Passcode) values (@str0,@str1,@str2,@str3,@str4,@str5,@str6,@str7)", sqlcon); cmd.Parameters.AddWithValue("@str0", comboBox1.SelectedItem.ToString()); cmd.Parameters.AddWithValue("@str1", textBox1.Text); cmd.Parameters.AddWithValue("@str2", textBox2.Text); cmd.Parameters.AddWithValue("@str3", textBox3.Text); cmd.Parameters.AddWithValue("@str4", gender); cmd.Parameters.AddWithValue("@str5", textBox4.Text); cmd.Parameters.AddWithValue("@str6", textBox6.Text); cmd.Parameters.AddWithValue("@str7", textBox5.Text); cmd.ExecuteNonQuery(); this.Hide(); MessageBox.Show("Profile Created Successfully!", "Successful", MessageBoxButtons.OK); Manage_Users MU = new Manage_Users(); MU.Show(); } catch { MessageBox.Show("Error Occured !", "Error", MessageBoxButtons.OK); } }
private void button1_Click(object sender, EventArgs e) { try { if (textBox1.Text == "" || textBox2.Text == "") { MessageBox.Show("ADMIN ID or Password must not be empty !", "Authorization Failed", MessageBoxButtons.OK); } else { SqlConnection sqlcon = new SqlConnection(@"Data Source=SELVAH\SQLSERVER;Initial Catalog=master;Integrated Security=True;"); sqlcon.Open(); string type = "Admin"; string try1 = "Select * from EmployeeDB where ((LoginType='" + type + "') and (empid='" + this.textBox1.Text + "')and (passcode='" + this.textBox2.Text + "'))"; SqlDataAdapter sda = new SqlDataAdapter(try1, sqlcon); DataTable dtc = new DataTable(); sda.Fill(dtc); if (dtc.Rows.Count.ToString() == "1") { this.Hide(); SqlCommand command = new SqlCommand("DELETE FROM EmployeeDB WHERE empid = @id", sqlcon); command.Parameters.AddWithValue("@id", empid); command.ExecuteNonQuery(); sqlcon.Close(); MessageBox.Show("Profile Deleted Successfully!", "Successful", MessageBoxButtons.OK); Manage_Users M = new Manage_Users(); M.Show(); } else { MessageBox.Show("Enter Valid password and user id!", "Authorization Failed", MessageBoxButtons.OK); } } } catch { MessageBox.Show("Error Occured !", "Error", MessageBoxButtons.OK); } }