private void Clear() { ProductIdTextBox.Clear(); ProductNameTextBox.Clear(); DescriptionTextBox.Clear(); ProductPriceTextBox.Clear(); NewProductArrivedTextBox.Clear(); onHandCount.Clear(); }
private void ConfirmButonForInsert_Click(object sender, EventArgs e) { String productId = ProductIdTextBox.Text; String productName = MedicineNameTextBox.Text; String genericName = GenericNameTextBox.Text; String mgfDate = MgfdateTextBox.Text; String expDate = ExprDateTextBox.Text; String productAmmount = ProductAmmountTextBox.Text; String description = DescriptionTextBox.Text; byte[] file_byte = ImageToByteArray(pictureBox1.Image); SqlConnection conn = new SqlConnection(connection); conn.Open(); if (conn.State == System.Data.ConnectionState.Open) { if (ConfirmButonForInsert.Text == "Confirm") { String q = "INSERT INTO Product (ProductId,ProductName,GenericName, MgfDate,ExpDate, ProductAmmount,Description,MedicineImage )VALUES ('" + productId + "','" + productName + "','" + genericName + "','" + mgfDate + "','" + expDate + "','" + productAmmount + "','" + description + "','" + file_byte + "')"; SqlCommand cmd = new SqlCommand(q, conn); cmd.ExecuteNonQuery(); MessageBox.Show("tamak"); } else if (ConfirmButonForInsert.Text == "Update") { try { String q = "UPDATE Product SET ProductName='" + ProductName + "' WHERE ProductId='" + productId + "'"; SqlCommand cmd = new SqlCommand(q, conn); cmd.ExecuteNonQuery(); conn.Close(); MessageBox.Show("Update Success"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { try { String q = "DELETE from Product WHERE ProductId='" + productId + "'"; SqlCommand cmd = new SqlCommand(q, conn); cmd.ExecuteNonQuery(); conn.Close(); MessageBox.Show("Delete Success"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } ProductIdTextBox.Clear(); MedicineNameTextBox.Clear(); GenericNameTextBox.Clear(); MgfdateTextBox.Clear(); ExprDateTextBox.Clear(); ProductAmmountTextBox.Clear(); DescriptionTextBox.Clear(); conn.Close(); }