private void btadd_Click(object sender, EventArgs e) { Medicine medicine = new Medicine(); medicine.Name = txtMName.Text; medicine.ConcentrationOfTheDrug = Convert.ToInt32(txtMConceration.Text); medicine.FinishDate = txtMEnd.Text; medicine.Quantity = Convert.ToInt32(txtMQuantity.Text); medicine.TimesPerDay = Convert.ToInt32(txtMTimesPerDay.Text); MedicineRepository medicineRepository = new MedicineRepository(); medicineRepository.Add(medicine); medicineRepository.save(); FillDataGridView(); }
private void btadd_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtMedcineName.Text) || txtMedcineName.Text.Length < 3) { return; } Medicine medicine = new Medicine(); medicine.Name = txtMedcineName.Text; medicine.ConcentrationOfTheDrug = Convert.ToInt32(txtMedcineConceration.Text); medicine.Quantity = 3; medicine.TimesPerDay = 4; MedicineRepository medicineRepository = new MedicineRepository(); medicineRepository.Add(medicine); medicineRepository.save(); FillDataGridView(); txtMedcineName.Clear(); txtMedcineConceration.Clear(); }