private void loadConsultationProductData(ConsultationProduct consultationProduct) { txtIdConsultationProduct.Text = Convert.ToString(consultationProduct.ConsultationProductId); cbPrescribedProducts.SelectedValue = Convert.ToInt64(consultationProduct.ProductId); txtDose.Text = consultationProduct.Dose; txtFrequency.Text = consultationProduct.Frequency; }
private void btnPrescribeProduct_Click(object sender, EventArgs e) { if (txtId.Text.Equals(String.Empty)) { MessageBox.Show("É necessário selecionar uma consulta já marcada para prescrever um remédio."); return; } if (allFullfilledProductPrescription()) { Product product = productService.GetById(Convert.ToInt64(cbPrescribedProducts.SelectedValue)); ConsultationProduct newEntry; if (!txtIdConsultationProduct.Text.Equals(String.Empty)) { newEntry = new ConsultationProduct(txtDose.Text, txtFrequency.Text, Convert.ToInt64(txtId.Text), product.ProductId) { ConsultationProductId = Convert.ToInt64(txtIdConsultationProduct.Text) }; } else { newEntry = new ConsultationProduct(txtDose.Text, txtFrequency.Text, Convert.ToInt64(txtId.Text), product.ProductId); } consultationProductService.Insert(newEntry); refreshDataGridViewPrescriptedProducts(); } }
private void btnInsert_Click(object sender, EventArgs e) { if (!txtId.Text.Equals("")) { MessageBox.Show("A caixa de Id deve estar vazia, aperte em resetar para limpa-la."); return; } else if (allFullfilled()) { var vetId = Convert.ToInt64(cbVet.SelectedValue); var ownerId = Convert.ToInt64(cbOwner.SelectedValue); var petId = Convert.ToInt64(cbPet.SelectedValue); Vet vet = (Vet)vetService.GetById(vetId); Owner owner = (Owner)ownerService.GetById(ownerId); Pet pet = (Pet)petService.GetById(petId); Composition.AddSlice <Owner, Pet>(owner, pet); List <ConsultationProduct> consultationProducts = new List <ConsultationProduct>(); List <ConsultationExam> consultationExams = new List <ConsultationExam>(); currentlyBeingRegistered = new MedicalConsultation(dtScheduleDate.Value, vetId, ownerId, petId, consultationProducts, consultationExams); medicalConsultationService.Insert(currentlyBeingRegistered); long?medicalConsultationId = medicalConsultationService.GetId(currentlyBeingRegistered); if (currentlyBeingPrescribedProducts != null) { foreach (ConsultationProduct prescribedProduct in currentlyBeingPrescribedProducts) { ConsultationProduct newEntry = prescribedProduct; newEntry.MedicalConsultationId = medicalConsultationId; consultationProductService.Insert(newEntry); } } if (currentlyBeingPrescribedExams != null) { foreach (ConsultationExam prescribedExam in currentlyBeingPrescribedExams) { ConsultationExam newEntry = prescribedExam; newEntry.MedicalConsultationId = medicalConsultationId; consultationExamService.Insert(newEntry); } } resetForm(); refreshDataGridView(); refreshDataGridViewPrescriptedExams(); refreshDataGridViewPrescriptedProducts(); } }
private void btnAlter_Click(object sender, EventArgs e) { if (txtId.Text.Trim().Equals(String.Empty)) { MessageBox.Show("A caixa de Id não deve estar vazia, selecione uma consulta antes de alterar."); return; } else if (allFullfilled()) { currentlyBeingRegistered = new MedicalConsultation(); var vetId = Convert.ToInt64(cbVet.SelectedValue); var ownerId = Convert.ToInt64(cbOwner.SelectedValue); var petId = Convert.ToInt64(cbPet.SelectedValue); Vet vet = (Vet)vetService.GetById(vetId); Owner owner = (Owner)ownerService.GetById(ownerId); Pet pet = (Pet)petService.GetById(petId); long?medicalConsultationId = Convert.ToInt64(txtId.Text); Composition.AddSlice <Owner, Pet>(owner, pet); List <ConsultationProduct> consultationProducts = new List <ConsultationProduct>(); List <ConsultationExam> consultationExams = new List <ConsultationExam>(); currentlyBeingRegistered = new MedicalConsultation(dtScheduleDate.Value, vetId, ownerId, petId, consultationProducts, consultationExams) { MedicalConsultationId = medicalConsultationId }; if (currentlyBeingPrescribedProducts != null) { foreach (ConsultationProduct prescribedProduct in currentlyBeingPrescribedProducts) { ConsultationProduct newEntry = prescribedProduct; newEntry.MedicalConsultationId = medicalConsultationId; //se já não estiver registrado if (newEntry.ConsultationProductId == null) { consultationProductService.Insert(newEntry); } } } if (currentlyBeingPrescribedExams != null) { foreach (ConsultationExam prescribedExam in currentlyBeingPrescribedExams) { ConsultationExam newEntry = prescribedExam; newEntry.MedicalConsultationId = medicalConsultationId; //se já não estiver registrado if (newEntry.ConsultationExamId == null) { consultationExamService.Insert(newEntry); } } } medicalConsultationService.Alter(currentlyBeingRegistered); refreshDataGridView(); refreshDataGridViewPrescriptedExams(); refreshDataGridViewPrescriptedProducts(); resetForm(); } }