private void Insert() { using (var context = new MediPlusSysContext()) { if (TxtNombres.Text.Length == 0 || TxtApellidosD.Text.Length == 0) { MessageBox.Show("DEBE LLENAR SUS CREDENCIALES"); } else if (CbEspecialidade.SelectedIndex == 0) { MessageBox.Show("DEBE DE SELECCIONAR SU ESPECIALIDAD"); return; } else { var doc = new Doctore() { Nombres = TxtNombres.Text, Apellidos = TxtApellidosD.Text, Telefono = MaskTelefono.Text, Celular = MaskCelular.Text, IdEspecialidad = (int?)Convert.ToUInt32(CbEspecialidade.SelectedValue), Iddia = (int?)Convert.ToUInt32(CBDiasLabor.SelectedValue), IdCargo = (int)Convert.ToUInt32(CbTipoUsuario.SelectedValue), Sexo = RbMasculino.Checked == true ? "M" : "F", }; context.Doctores.Add(doc); context.SaveChanges(); MessageBox.Show("El Usuario y su contraseña para acceder al sistema se le envio a su correo", "Doctor Creado Con Exito", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
public IActionResult Create(CrearFacturasViewModel model) { if (model.command == "ADD") { if (model.Details == null) { model.Details = new List <FacturaDetalleDTO>(); } bool addItem = true; if (string.IsNullOrEmpty(Convert.ToString(model.newdetail.IdDoctor))) { addItem = false; ModelState.AddModelError("newdetail.IdDoctor", "Type product Code."); } if (model.newdetail.Precio < 1) { addItem = false; ModelState.AddModelError("newdetail.Precio", "Type Quantity < 1."); } if (addItem) { model.Details.Add(model.newdetail); model.newdetail = new FacturaDetalleDTO(); } } if (model.command == "Save" && ModelState.IsValid) { Factura Fact = new Factura(); Fact.IdPaciente = model.factura.IdPaciente; Fact.Fecha = model.factura.Fecha; Fact.IdEstado = model.factura.IdEstado; Fact.FacturasDetalles = new List <FacturasDetalle>(); foreach (var item in model.Details) { Fact.FacturasDetalles.Add(new FacturasDetalle { IdDoctor = item.IdDoctor, Precio = item.Precio, Comentario = item.Comentario }); } _context.Facturas.Add(Fact); _context.SaveChanges(); return(RedirectToAction("Index")); } ViewData["IdDoctor"] = new SelectList(_context.Facturas, "IdDoctor", "Nombres"); return(View(model)); }
private void InsertarCita() { using (var context = new MediPlusSysContext()) { if (CbPaciente.SelectedIndex == 0 || CbDoctor.SelectedIndex == 0) { MessageBox.Show("AUN NO SE HA SELECCIONADO UN PACIENTE O DOCTOR", "Operacion Erronea", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (LbBoxInicio.Text == lbboxFin.Text) { MessageBox.Show("LA FECHA DE INICIO ES IGUAL A LA DE FIN", "Operacion Erronea", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { var Cidb = new Cita() { IdPaciente = (int)Convert.ToUInt32(CbPaciente.SelectedValue), IdDoctor = (int)Convert.ToUInt32(CbDoctor.SelectedValue), FechaCita = DateFechaCita.Value.Date, HoraInicio = LbBoxInicio.Text, HoraFin = lbboxFin.Text, Comentario = TxtComentario.Text, Motivo = TxtMotivo.Text, IdEstado = (int)Convert.ToUInt32(CBEstado.SelectedValue), Tanda = RbManana.Checked == true ? "Mañana" : "Tarde", }; var query = from o in context.Citas where o.FechaCita == DateFechaCita.Value.Date && o.HoraInicio == LbBoxInicio.Text select o; if (query.SingleOrDefault() != null) { MessageBox.Show("NO SE PUEDE REGISTRAR UNA CITA A ESTA HORA", "Operacion Erronea", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { context.Citas.Add(Cidb); context.SaveChanges(); MessageBox.Show("CITA AGREGADA", "Operacion Exitosa", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }
private void Eliminar() { if (MessageBox.Show(@"Esta seguro que desea eliminar el Doctor?", @"Atención", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (MessageBox.Show(@"EN REALIDAD ESTAS SEGURO?", @"Atención", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { using (var db = new MediPlusSysContext()) { var Doc = db.Doctores.ToList().Find(e => e.IdDoctor == iddoctores); db.Doctores.Remove(Doc); db.SaveChanges(); } } } }
private void Eliminar() { if (MessageBox.Show(@"¿QUIERES ELIMINAR ESTA CITA?", @"Atención", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (MessageBox.Show(@"¿EN REALIDAD ESTAS LO QUIERES HACER?", @"Atención", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { using (var db = new MediPlusSysContext()) { var cit = db.Citas.ToList().Find(e => e.IdCita == idcitas); db.Citas.Remove(cit); db.SaveChanges(); } } } }
private void Eliminar() { if (MessageBox.Show(@"¿QUIERES ELIMINAR ESTE PACIENTE?", @"Atención", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (MessageBox.Show(@"¿EN REALIDAD ESTAS LO QUIERES HACER?", @"Atención", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { using (var db = new MediPlusSysContext()) { var Pac = db.Pacientes.ToList().Find(e => e.IdPaciente == Idpacientes); db.Pacientes.Remove(Pac); db.SaveChanges(); } } } }
private void Actualizar() { using (var context = new MediPlusSysContext()) { var Doc = context.Citas.ToList().Find(e => e.IdCita == idcitas); Doc.IdPaciente = (int)(CbPaciente.SelectedValue); Doc.IdDoctor = (int)(CbDoctor.SelectedValue); Doc.FechaCita = (DateTime)DateFechaCita.Value; Doc.Tanda = RbManana.Checked == true ? "Mañana" : "Tarde"; Doc.Comentario = TxtComentario.Text; Doc.Motivo = TxtMotivo.Text; Doc.IdEstado = (int?)(CBEstado.SelectedValue); context.SaveChanges(); MessageBox.Show("CITA ACTUALIZADA", "Operacion Exitosa", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void InsertPacientes() { using (var context = new MediPlusSysContext()) { if (TxtNombresP.Text.Length == 0 || TxtApellidosP.Text.Length == 0) { MessageBox.Show("AUN NO SE HA LLENADO LOS DATOS PERSONALES"); return; } else if (MaskCedula.Text.Length == 0) { MessageBox.Show("AUN NO SE HA LLENADO EL CAMPO CEDULA"); } else { var Cidb = new Paciente() { Nombres = TxtNombresP.Text, Apellidos = TxtApellidosP.Text, Sexo = RbMasculino.Checked == true ? "M" : "F", CorreoElectronico = TxtCorreo.Text, FechaDeNacimiento = dateTimeNacimiento.Value.Date, Cedula = MaskCedula.Text, Provincia = txtProvincia.Text, Ciudad = TxtCiudad.Text, Sector = TxtSector.Text, Calle = TxtCalle.Text, Celular = MaskCelular.Text, Telefono = MaskTelefono.Text, IdCargo = (int)Convert.ToUInt32(CbtipodeUsuario.SelectedValue), }; context.Pacientes.Add(Cidb); context.SaveChanges(); MessageBox.Show("PACIENTE AGREGADO", "Operacion Exitosa", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
private void Actualizar() { using (var context = new MediPlusSysContext()) { //iddoctores =Convert.ToInt32(dataGridActuali.SelectedCells[0].Value); var Doc = context.Doctores.ToList().Find(e => e.IdDoctor == iddoctores); Doc.Nombres = TxtNombres.Text; Doc.Apellidos = TxtApellidosD.Text; Doc.Telefono = MaskTelefono.Text; Doc.Celular = MaskCelular.Text; Doc.IdEspecialidad = (int?)Convert.ToUInt32(CbEspecialidade.SelectedValue); Doc.Iddia = (int?)Convert.ToUInt32(CBDiasLabor.SelectedValue); Doc.IdCargo = (int)Convert.ToUInt32(CbCargo.SelectedValue); Doc.Sexo = RbMasculino.Checked == true ? "M" : "F"; // context.Doctores.Update(Doc); context.SaveChanges(); MessageBox.Show("DOCTOR ACTUALIZADO", "Operacion Exitosa", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void Actualizar() { using (var context = new MediPlusSysContext()) { var Doc = context.Pacientes.ToList().Find(e => e.IdPaciente == Idpacientes); Doc.Nombres = TxtNombresP.Text; Doc.Apellidos = TxtApellidosP.Text; Doc.Sexo = RbMasculino.Checked == true ? "M" : "F"; Doc.CorreoElectronico = TxtCorreo.Text; Doc.Cedula = MaskCedula.Text; Doc.Telefono = MaskTelefono.Text; Doc.Celular = MaskCelular.Text; Doc.Provincia = txtProvincia.Text; Doc.Ciudad = TxtCiudad.Text; Doc.Sector = TxtSector.Text; Doc.Calle = TxtCalle.Text; Doc.IdCargo = (int?)Convert.ToUInt32(CbtipodeUsuario.SelectedValue); context.SaveChanges(); MessageBox.Show("PACIENTE ACTUALIZADO", "Operacion Exitosa", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }