示例#1
0
        private void btnButton_Click(object sender, EventArgs e)
        {
            medHisGuid = Guid.Parse(MedicHistoryViewModel.Id);
            try
            {
                var historial = context.MedicHistory
                                .Where(x => x.MedicHistoryId.Equals
                                           (medHisGuid))
                                .SingleOrDefault();
                if (historial != null)
                {
                    historial.Description = txtEnfermedades.Text;
                    historial.Reason      = txtmotivo.Text;
                    historial.Height      = Convert.ToDecimal(txtAltura.Text);
                    historial.Weight      = Convert.ToDecimal(txtPeso.Text);
                    historial.Diagnosis   = txtdiagnostico.Text;
                    historial.temperature = Convert.ToDecimal(txtTemperatura.Text);
                    context.SaveChanges();

                    MessageBox.Show("Historial se actualizó correctamente.");
                }
                frmmFather.updateDGVMedicHistory();
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ocurró un ´Problema en el Sistema. " + ex);
            }
        }
        private void btnButton_Click(object sender, EventArgs e)
        {
            patIdGuid = Guid.Parse(patmed.Id);
            try
            {
                patIdGuid = Guid.Parse(patmed.Id);
                var pat = (from pats in context.Patients
                           where pats.UserId == patIdGuid
                           select pats)
                          .Select(x => new PatientShowViewModel
                {
                    Id = x.PacienteId.ToString()
                }).ToList();

                foreach (var item in pat)
                {
                    patId = Guid.Parse(item.Id);
                }


                Guid guid   = Guid.NewGuid();
                var  medHis = context.MedicHistory
                              .Add(new MedicHistory
                {
                    MedicHistoryId = guid,
                    Description    = txtEnfermedades.Text,
                    Height         = Convert.ToDecimal(txtAltura.Text),
                    Weight         = Convert.ToDecimal(txtPeso.Text),
                    temperature    = Convert.ToDecimal(txtTemperatura.Text),
                    Reason         = txtmotivo.Text,
                    Diagnosis      = txtdiagnostico.Text,
                    PatiendId      = patId
                });
                context.SaveChanges();
                frmmFather.updateDGVMedicHistory();
                MessageBox.Show("Se registró satisfactoriamente. ");
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ocurrió un error en el Sistema. " + ex);
            }
        }