private void insertBotton_Click(object sender, EventArgs e) { if (isEmpty()) { if (isUpdateP) { updateRecordMethod(); } else { SaveRecordMethod(); } this.Close(); PurchaseShowForm p = new PurchaseShowForm(); p.Show(); } }
private void deleteBotton_Click(object sender, EventArgs e) { string connectionstring1 = ConfigurationManager.ConnectionStrings["edb"].ConnectionString; SqlConnection conn1 = new SqlConnection(connectionstring1); SqlCommand cm = new SqlCommand("select * from PurchaseTbl where DressName='" + dressnametextBox.Text.Trim() + "'", conn1); SqlDataAdapter adapter = new SqlDataAdapter(cm); adapter.Fill(ds); int i = ds.Tables[0].Rows.Count; if (i > 0) { string connectionstring = ConfigurationManager.ConnectionStrings["edb"].ConnectionString; SqlConnection conn = new SqlConnection(connectionstring); SqlCommand cmd = new SqlCommand("spDel", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@DName", dressizetextBox.Text.Trim()); cmd.Parameters.AddWithValue("@DSize", dressizetextBox.Text.Trim()); cmd.Parameters.AddWithValue("@ppi", pricePerItemtextBox.Text.Trim()); cmd.Parameters.AddWithValue("@q", QuantitytextBox.Text.Trim()); cmd.Parameters.AddWithValue("@desc", descriptionrichTextBox.Text.Trim()); cmd.Parameters.AddWithValue("@purchaseD", datepurchasedatetime.Value.Date); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); MessageBox.Show("Delete Record Successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); PurchaseShowForm p = new PurchaseShowForm(); p.Show(); } else { MessageBox.Show("Employee Name " + dressnametextBox.Text + " is Not Exist", "ERROR!!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }