protected void Calendar1_SelectionChanged(object sender, EventArgs e) { try { lb_grid.Visible = true; lb_grid.Text = Calendar1.SelectedDate.ToShortDateString() + " " + cb_dr.SelectedValue + " " + cb_dr.SelectedItem; DateTime fecha = Convert.ToDateTime(Calendar1.SelectedDate.ToShortDateString()); int idmedico = Convert.ToInt32(cb_dr.SelectedValue.ToString()); lbFecha.Text = fecha.ToShortDateString(); Clinica_integralEntities2 bd = new Clinica_integralEntities2(); var result = from r in bd.Reserva join p in bd.Paciente on r.id_paciente equals p.id_paciente into gj from aux in gj.DefaultIfEmpty() where r.id_medico == idmedico && r.fecha.Value == fecha select new { r.id_reserva, r.hora, nombre_paciente = aux.nombre_paciente, aux.telefono_paciente, aux.tipo, aux.medio_pago }; GridView1.DataSource = result.ToList(); GridView1.DataBind(); GridView1.Visible = true; } catch (Exception) { } }
//EDITAR UN PACIENTE DE LA BASE DE DATOS protected void agregar_editar_Click(object sender, EventArgs e) { try { Clinica_integralEntities2 bd = new Clinica_integralEntities2(); string nombre = txt_nombre_paciente.Text; string telefono = txt_telefono_paciente.Text; string medio_pago = txt_medio_pago.Text; string tipo = txt_tipo_paciente.Text; Paciente pa = new Paciente(); pa.nombre_paciente = nombre; pa.telefono_paciente = telefono; pa.medio_pago = medio_pago; pa.tipo = tipo; bd.Paciente.Add(pa); int auux = bd.SaveChanges(); int id_reserva = Convert.ToInt32(lbID_editar.Text); Reserva re = new Reserva(); re = bd.Reserva.Find(id_reserva); re.id_paciente = pa.id_paciente; bd.SaveChanges(); //lb_grid.Text = Calendar1.SelectedDate.ToShortDateString() + " " + cb_dr.SelectedValue + " " + cb_dr.SelectedItem; //DateTime fecha = Convert.ToDateTime(Calendar1.SelectedDate.ToShortDateString()); // lb_grid.Text = Calendar1.SelectedDate.ToShortDateString() + " " + cb_dr.SelectedValue + " " + cb_dr.SelectedItem; DateTime fecha = Convert.ToDateTime(lb_fecha_editar.Text); int idmedico = Convert.ToInt32(cb_dr.SelectedValue.ToString()); var result = from r in bd.Reserva join p in bd.Paciente on r.id_paciente equals p.id_paciente into gj from aux in gj.DefaultIfEmpty() where r.id_medico == idmedico && r.fecha.Value == fecha select new { r.id_reserva, r.hora, nombre_paciente = aux.nombre_paciente, aux.telefono_paciente, aux.tipo, aux.medio_pago }; GridView1.DataSource = result.ToList(); GridView1.DataBind(); GridView1.Visible = true; } catch (Exception) { } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Clinica_integralEntities2 bd = new Clinica_integralEntities2(); cb_dr.DataSource = bd.Medico.ToList(); cb_dr.DataTextField = "nombre_medico"; cb_dr.DataValueField = "id_medico"; cb_dr.DataBind(); // lb_grid.Visible = false; } Calendar1.SelectedDate = DateTime.Now; }