public void SaveMedicine(AppointMedicineModel medicine) { using (var context = new MCContext()) { context.AppointMedicineModels.Add(medicine); context.SaveChanges(); } }
private void SaveMedicine() { try { for (int i = 0; i < DgvMedicine.Rows.Count - 1; i++) { AppointMedicineModel medicineModel = new AppointMedicineModel { PatientId = Convert.ToInt32(TextBoxId.Text), Name = DgvMedicine.Rows[i].Cells[0].Value.ToString(), InaDay = DgvMedicine.Rows[i].Cells[1].Value.ToString(), }; appointment.SaveMedicine(medicineModel); } }catch (Exception) { } }