private void loginbutton1_Click(object sender, EventArgs e) { bool isusername, ispassword; getLogin(out isusername, out ispassword); if (isusername && ispassword) { this.Hide(); //MessageBox.Show("successfully login"); showDataForm sdf = new showDataForm(); sdf.Show(); } else { if (!isusername) { MessageBox.Show("UserName is not Correct", "ERROR!!", MessageBoxButtons.OK, MessageBoxIcon.Error); usernametextBox2.Clear(); usernametextBox2.Focus(); } else { MessageBox.Show("Password is not Correct", "ERROR!!", MessageBoxButtons.OK, MessageBoxIcon.Error); passwordtextBox1.Clear(); passwordtextBox1.Focus(); } } }
private void deletebutton2_Click(object sender, EventArgs e) { if (isEmpty()) { DialogResult result = MessageBox.Show("Do You Want To Delete Records ???", "WARNING", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { string c = ConfigurationManager.ConnectionStrings["db"].ConnectionString; SqlConnection conn = new SqlConnection(c); SqlCommand cmd = new SqlCommand("del", conn); cmd.CommandType = CommandType.StoredProcedure; conn.Open(); cmd.Parameters.AddWithValue("@itemname", itemnametextBox1.Text.Trim()); cmd.Parameters.AddWithValue("@price", pricetextBox2.Text.Trim()); cmd.Parameters.AddWithValue("@quantity", quantitytextBox3.Text.Trim()); cmd.Parameters.AddWithValue("@companyname", companynametextBox4.Text.Trim()); cmd.Parameters.AddWithValue("@date", dateTimePicker1.Value.Date); cmd.ExecuteNonQuery(); MessageBox.Show("Delete Data Successfully", "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); showDataForm obj = new showDataForm(); obj.ShowDialog(); } } }
private void button1_Click(object sender, EventArgs e) { if (isEmpty()) { string c = ConfigurationManager.ConnectionStrings["db"].ConnectionString; SqlConnection conn = new SqlConnection(c); cm = new SqlCommand("select * from itbl where ItemName='" + itemnametextBox1.Text.Trim() + "'", conn); SqlDataAdapter ad = new SqlDataAdapter(cm); ad.Fill(ds); int i = ds.Tables[0].Rows.Count; if (i > 0) { MessageBox.Show("Item Name " + itemnametextBox1.Text + " is Already Exist", "ERROR!!", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); showDataForm s = new showDataForm(); s.Show(); } else { cm = new SqlCommand("i", conn); cm.CommandType = CommandType.StoredProcedure; conn.Open(); cm.Parameters.AddWithValue("@itemname", itemnametextBox1.Text.Trim()); cm.Parameters.AddWithValue("@price", pricetextBox2.Text.Trim()); cm.Parameters.AddWithValue("@quantity", quantitytextBox3.Text.Trim()); cm.Parameters.AddWithValue("@companyname", companynametextBox4.Text.Trim()); cm.Parameters.AddWithValue("@date", dateTimePicker1.Value.Date); cm.ExecuteNonQuery(); MessageBox.Show("Enter Data Successfully", "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); showDataForm obj = new showDataForm(); obj.ShowDialog(); } } }