private void pictureBox3_Click(object sender, EventArgs e) { MedicineIdTextBox.Clear(); SellingPriceTextBox.Clear(); MedicineNameTextBox.Clear(); QuantityTextBox.Clear(); BuyingPriceTextBox.Clear(); ManufacturerTextBox.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(); }
private void PrescriptionSaveButton_Click(object sender, EventArgs e) { Medicine medicine = null; DateTime dateTime = DateTime.Now; //string time = dateTime.ToShortTimeString(); string date = dateTime.ToShortDateString(); //MessageBox.Show(); int morningDose = 0, afternoonDose = 0, nightDose = 0; string morningGroupBoxValue = "", afternoonGroupBoxValue = "", nightGroupBoxValue = "", patientID = "", medicineName = ""; try { medicineName = MedicineNameTextBox.Text.ToString(); morningGroupBoxValue = MorningDoseGroupBox.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked).Name; afternoonGroupBoxValue = AfternoonGroupBox.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked).Name.Split('_')[1]; nightGroupBoxValue = NightDoseGroupBox.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked).Name.Split('_')[1]; patientID = ToPatientTextBox.Text.ToString().Split('(', ')')[1]; UserInfo.TempPatientIDForDoctor = patientID; UserInfo.medicineIDHelper = patientID + RandNumber + date; } catch (System.IndexOutOfRangeException) { MessageBox.Show("Please enter the patient name in respective field and the patient name should be from the dropdown box.", "ValidationError", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception) { } //MessageBox.Show(afternoonGroupBoxValue); //switch(morningGroupBoxValue) //{ // case "one": // morningDose = 1; // break; // case "two": // morningDose = 2; // break; // case "three": // morningDose = 3; // break; // case "four": // morningDose = 4; // break; // default: // morningDose = 0; // break; //} Hashtable hashtable = new Hashtable(); hashtable.Add("zero", 0); hashtable.Add("one", 1); hashtable.Add("two", 2); hashtable.Add("three", 3); hashtable.Add("four", 4); foreach (DictionaryEntry item in hashtable) { if (morningGroupBoxValue == item.Key.ToString()) { morningDose = (int)item.Value; } if (afternoonGroupBoxValue == item.Key.ToString()) { afternoonDose = (int)item.Value; } if (nightGroupBoxValue == item.Key.ToString()) { nightDose = (int)item.Value; } } //MessageBox.Show(morningDose.ToString() + " " + afternoonDose.ToString() + " " + nightDose.ToString()); try { using (DatabaseContext databaseContext = new DatabaseContext()) { var medObject = databaseContext.MedNames.Where(m => m.MedicineName == medicineName).FirstOrDefault <MedName>(); if (medObject == null) { MedName medName = new MedName() { MedicineName = medicineName, AddedBy = UserInfo.UserEmail }; databaseContext.MedNames.Add(medName); } medicine = new Medicine(); medicine.AfterNoonDose = afternoonDose; medicine.Days = Convert.ToInt32(DaysTextBox.Text); medicine.UniqueMedicineID = UserInfo.medicineIDHelper; medicine.MorningDose = morningDose; medicine.NightDose = nightDose; medicine.MedicineName = MedicineNameTextBox.Text.ToString(); databaseContext.Medicines.Add(medicine); databaseContext.SaveChanges(); } MessageBox.Show("Medicine " + MedicineNameTextBox.Text.ToString() + " stored in current prescription", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); MedicineNameTextBox.Clear(); DaysTextBox.Clear(); MedicineNameTextBox.Focus(); } catch (Exception ex) { MessageBox.Show("Exception Occured" + ex.ToString()); } }