private void button2_Click(object sender, EventArgs e) { this.Hide(); FOOD_DETAILS FD = new FOOD_DETAILS(); FD.Show(); }
private void button1_Click(object sender, EventArgs e) { 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 ItemDetails WHERE ItemCode = @id", sqlcon); command.Parameters.AddWithValue("@id", empid); command.ExecuteNonQuery(); sqlcon.Close(); MessageBox.Show("Food Item Deleted Successfully!", "Successful", MessageBoxButtons.OK); FOOD_DETAILS M = new FOOD_DETAILS(); M.Show(); } else { MessageBox.Show("Enter Valid password and user id!", "Authorization Failed", MessageBoxButtons.OK); } } }
private void button1_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 ITEMDETAILS (itemCode,itemName,RATE) VALUES (@str1,@str2,@str3)", sqlcon); cmd.Parameters.AddWithValue("@str1", textBox1.Text); cmd.Parameters.AddWithValue("@str2", textBox2.Text); cmd.Parameters.AddWithValue("@str3", Convert.ToInt32(textBox3.Text)); cmd.ExecuteNonQuery(); sqlcon.Close(); MessageBox.Show("Food Item Added Successfully!", "Successful", MessageBoxButtons.OK); this.Hide(); FOOD_DETAILS FD = new FOOD_DETAILS(); FD.Show(); } catch { MessageBox.Show("Error Occured !", "Error", MessageBoxButtons.OK); } }