public void CreateCitaEvent(Int32 curCita) { DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); //DataTable TempData = datos1.GetEvents(); DataTable TempData = datos1.LoadData("select * from Citas where Id=" + curCita.ToString()); DataTable TablaColores = datos1.LoadData("select * from Colores order by Id"); string NombrePaciente = ""; Int16 StatusPaciente = 0; Int32 CurColor = 0; int CurPaciente = 0; string ColorPaciente = "#000000"; foreach (DataRow c in TempData.Rows) { Int32 IdEvento = (Int32)c["Id"]; Int32 IdPaciente = (Int32)c["IdPaciente"]; Int16 Duracion = (Int16)c["Duracion"]; Int16 IdTerapueta = (Int16)c["IdTerapeuta"]; DateTime AFecha = (DateTime)c["Fecha"]; if (CurPaciente == 0 || IdPaciente != CurPaciente) { CurPaciente = IdPaciente; DataTable DatosPaciente = datos1.LoadData("select * from pacientes where IdPaciente=" + IdPaciente.ToString()); NombrePaciente = DatosPaciente.Rows[0]["Nombre"].ToString(); StatusPaciente = (Int16)DatosPaciente.Rows[0]["estatus"]; CurColor = IdPaciente % 55; ColorPaciente = "#" + TablaColores.Rows[CurColor]["Color"].ToString(); } DateTime EventoFechaStart = AFecha; DateTime EventoFechaEnd = EventoFechaStart.AddMinutes(Duracion); ArrayList valores = new ArrayList(); valores.Add(new Registro("IdEvento", IdEvento)); valores.Add(new Registro("Title", NombrePaciente)); valores.Add(new Registro("start_event", EventoFechaStart.ToString("yyyy-MM-dd HH:mm:ss"))); valores.Add(new Registro("end_event", EventoFechaEnd.ToString("yyyy-MM-dd HH:mm:ss"))); valores.Add(new Registro("Color", ColorPaciente)); valores.Add(new Registro("status1", 0)); valores.Add(new Registro("status2", 0)); valores.Add(new Registro("IdTipo", 2)); datos1.InsertData(valores, "Eventos"); } }
private void Window_Initialized(object sender, EventArgs e) { DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); this.dataGrid.ItemsSource = datos1.LoadData("Select IdPaciente,Nombre from pacientes order by Nombre").DefaultView; }
///////////////// public string getJsonEvents(DateTime startDate, DateTime endDate, string criterio) { DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); string query = ""; if (criterio.Length == 0) { query = "select * from Eventos"; } else { query = "select * from Eventos where " + criterio; } DataTable Eventos = datos1.LoadData(query); StringBuilder json = new StringBuilder(); char[] caracter1 = { '"' }; string quotes = new string(caracter1); json.Append("["); if (Eventos.Rows.Count == 0) { json.Append("]"); return(json.ToString()); } foreach (DataRow c in Eventos.Rows) { DateTime startFecha = (DateTime)c["start_event"]; DateTime endFecha = (DateTime)c["end_event"]; json.Append("{"); json.Append(quotes + "id" + quotes + ":" + c["IdEvento"].ToString() + ","); json.Append(quotes + "title" + quotes + ":" + quotes + c["Title"].ToString() + quotes + ","); json.Append(quotes + "start" + quotes + ":" + quotes + startFecha.ToString("o") + quotes + ","); json.Append(quotes + "end" + quotes + ":" + quotes + endFecha.ToString("o") + quotes + ","); json.Append(quotes + "color" + quotes + ":" + quotes + c["Color"].ToString() + quotes + ","); json.Append(quotes + "allday" + quotes + ":" + "false" + ","); json.Append(quotes + "editable" + quotes + ":" + "false"); json.Append("}"); json.Append(","); } json.Remove(json.Length - 1, 1); json.Append("]"); return(json.ToString()); }
private void CargaDatos() { string[] Dias = { "Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado" }; DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); datos1.CargaComboBoxData(this.comboBoxTerapeutas, "select Id,Nombre from terapeutas order by Nombre"); /* * DataTable DatosTerapuetas = datos1.LoadData("select Id, Nombre from terapeutas order by Nombre"); * this.comboBoxTerapeutas.ItemsSource = DatosTerapuetas.DefaultView; * this.comboBoxTerapeutas.DisplayMemberPath = DatosTerapuetas.Columns["Nombre"].ToString(); * this.comboBoxTerapeutas.SelectedValuePath = DatosTerapuetas.Columns["Id"].ToString(); */ datos1.CargaComboBoxData(this.Repeticion, "select Id,Nombre from repeticion"); if (this.curTerapia == 0) { this.textBox.Text = "45"; this.Repeticion.SelectedValue = 1; this.comboBoxTerapeutas.SelectedValue = 1; } else { DataTable datosTerapia = datos1.LoadData("select Fecha, Duracion, IdTerapeuta, Fecha2, Dia, Hora, Periodo from terapias where Id=" + this.curTerapia.ToString()); Byte Dia = (Byte)datosTerapia.Rows[0]["Dia"]; Int16 Duracion = (Int16)datosTerapia.Rows[0]["Duracion"]; Int16 IdTerapueta = (Int16)datosTerapia.Rows[0]["IdTerapeuta"]; Int16 Periodo = (Int16)datosTerapia.Rows[0]["Periodo"]; // Byte Hora = (Byte)datosTerapia.Rows[0]["Hora"]; // Byte Minuto = (Byte)datosTerapia.Rows[0]["Minuto"]; DateTime curFecha = (DateTime)datosTerapia.Rows[0]["Fecha"]; DateTime endFecha = (DateTime)datosTerapia.Rows[0]["Fecha2"]; DateTime Hora = (DateTime)datosTerapia.Rows[0]["Hora"]; this.Repeticion.SelectedValue = Periodo; this.comboBoxTerapeutas.SelectedValue = IdTerapueta; this.textBox.Text = Duracion.ToString(); //this.Repeticion.SelectedValue = 1; this.Fecha.Text = Dias[Dia]; this.Hora.Text = Hora.ToShortTimeString(); //this.Fecha.Text = curFecha.ToString("yyyy-MM-dd HH:mm:ss"); this.datePicker0.SelectedDate = curFecha; this.datePicker1.SelectedDate = endFecha; } }
private void CargaTerapias() { //return; DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); string[] Dias = { "Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado" }; DataTable TerapiasTemp = datos1.LoadData("select Id, Fecha, Fecha2,Dia, Hora, Duracion, IdTerapeuta, Periodo from terapias where IdPaciente=" + this.CurPaciente); if (TerapiasTemp == null) { return; } this.DatosTerapias = new DataTable("Terapias"); this.DatosTerapias.Columns.Add("IdTerapia", Type.GetType("System.Int32")); this.DatosTerapias.Columns.Add("Inicio", Type.GetType("System.String")); this.DatosTerapias.Columns.Add("Dia", Type.GetType("System.String")); this.DatosTerapias.Columns.Add("Hora", Type.GetType("System.String")); this.DatosTerapias.Columns.Add("Duracion", Type.GetType("System.Int16")); this.DatosTerapias.Columns.Add("Periodo", Type.GetType("System.String")); this.DatosTerapias.Columns.Add("Terapeuta", Type.GetType("System.String")); this.DatosTerapias.Columns.Add("Fin", Type.GetType("System.String")); foreach (DataRow c in TerapiasTemp.Rows) { string tipoA = c["Fecha"].GetType().ToString(); Int32 IdTerapia = (Int32)c["Id"]; Int16 IdTerapueta = (Int16)c["IdTerapeuta"]; DateTime startFecha = (DateTime)c["Fecha"]; DateTime endFecha = (DateTime)c["Fecha2"]; DateTime Hora = (DateTime)c["Hora"]; Int16 Periodo = (Int16)c["Periodo"]; Int16 Duracion = (Int16)c["Duracion"]; Byte curDia = (Byte)c["Dia"]; string NombreTerapeuta = datos1.GetNombreTabla(IdTerapueta, "Terapeutas", "Id", "Nombre"); string NombrePeriodo = datos1.GetNombreTabla(Periodo, "repeticion", "Id", "Nombre"); // string horario = string.Format("{0:D2}", Hora) + ":" + string.Format("{0:D2}", Minuto); this.DatosTerapias.Rows.Add(IdTerapia, startFecha.ToShortDateString(), Dias[curDia], Hora.ToShortTimeString(), Duracion.ToString(), NombrePeriodo, NombreTerapeuta, endFecha.ToShortDateString()); } this.dataGrid.ItemsSource = this.DatosTerapias.DefaultView; }
private void CargaDatos() { DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); this.curDataTable = datos1.LoadData("Select " + this.IndexName + "," + NameIndex + " from " + curTable + " order by " + NameIndex); this.dataGrid.ItemsSource = this.curDataTable.DefaultView; //this.dataGrid.ItemsSource = datos1.LoadData("Select " + this.IndexName + "," + NameIndex + " from " + curTable + " order by " + NameIndex).DefaultView; }
private void CargaCitas() { //return; DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); string[] Dias = { "Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado" }; DataTable CitasTemp = datos1.LoadData("select Id, Fecha, Duracion, IdTerapeuta from Citas where IdPaciente=" + this.CurPaciente); if (CitasTemp == null) { return; } if (CitasTemp.Rows.Count == 0) { return; } this.DatosCitas = new DataTable("Citas"); this.DatosCitas.Columns.Add("IdCita", Type.GetType("System.Int32")); this.DatosCitas.Columns.Add("Dia", Type.GetType("System.String")); this.DatosCitas.Columns.Add("Hora", Type.GetType("System.String")); this.DatosCitas.Columns.Add("Duracion", Type.GetType("System.Int16")); this.DatosCitas.Columns.Add("Terapeuta", Type.GetType("System.String")); foreach (DataRow c in CitasTemp.Rows) { string tipoA = c["IdTerapeuta"].GetType().ToString(); Int32 IdTerapia = (Int32)c["Id"]; Int16 IdTerapueta = (Int16)c["IdTerapeuta"]; DateTime FechaCita = (DateTime)c["Fecha"]; Int16 Duracion = (Int16)c["Duracion"]; string NombreTerapeuta = datos1.GetNombreTabla(IdTerapueta, "Terapeutas", "Id", "Nombre"); // string horario = string.Format("{0:D2}", Hora) + ":" + string.Format("{0:D2}", Minuto); this.DatosCitas.Rows.Add(IdTerapia, FechaCita.ToShortDateString(), FechaCita.ToShortTimeString(), Duracion.ToString(), NombreTerapeuta); } this.dataGrid.ItemsSource = this.DatosCitas.DefaultView; }
private void CargaDatos() { string[] Dias = { "Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado" }; DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); datos1.CargaComboBoxData(this.comboBoxTerapeutas, "select Id,Nombre from terapeutas order by Nombre"); if (this.curCita == 0) { this.textBox.Text = "45"; this.comboBoxTerapeutas.SelectedValue = 1; this.comentarios.Text = ""; } else { DataTable datosCita = datos1.LoadData("select Fecha, Duracion, IdTerapeuta from Citas where Id=" + this.curCita.ToString()); Int16 Duracion = (Int16)datosCita.Rows[0]["Duracion"]; Int16 IdTerapueta = (Int16)datosCita.Rows[0]["IdTerapeuta"]; DateTime FechaCita = (DateTime)datosCita.Rows[0]["Fecha"]; string comentarios = (string)datosCita.Rows[0]["comentarios"]; this.comboBoxTerapeutas.SelectedValue = IdTerapueta; this.textBox.Text = Duracion.ToString(); this.comentarios.Text = comentarios; this.Fecha.Text = FechaCita.ToShortDateString(); this.Hora.Text = FechaCita.ToShortTimeString(); //this.Fecha.Text = curFecha.ToString("yyyy-MM-dd HH:mm:ss"); } }
/* * * * * * * * * * public DataTable GetCurretEvents(DateTime StartDate, DateTime EndDate) * { * DataTable DatosEventos = new DataTable("Eventos"); * * DatosCehavi datos1 = new DatosCehavi(); * datos1.Connect(); * * DataTable TempData = datos1.GetEvents(); * * string NombrePaciente = ""; * Int16 StatusPaciente = 0; * int CurPaciente = 0; * * DatosEventos.Columns.Add("IdEvento", Type.GetType("System.Int32")); * DatosEventos.Columns.Add("Fecha", Type.GetType("System.DateTime")); * DatosEventos.Columns.Add("Duracion", Type.GetType("System.Int16")); * DatosEventos.Columns.Add("Title", Type.GetType("System.String")); * * * foreach (DataRow c in TempData.Rows) * { * Int32 IdEvento = (Int32)c["Id"]; * Int32 IdPaciente = (Int32)c["IdPaciente"]; * Int16 Duracion = (Int16)c["Duracion"]; * Int16 IdTerapueta = (Int16)c["IdTerapeuta"]; * Int16 Periodo = (Int16)c["Periodo"]; * DateTime AFecha = (DateTime)c["Fecha"]; * DateTime BFecha = (DateTime)c["Fecha2"]; * Byte Dia = (Byte)c["Dia"]; * * * if (CurPaciente == 0 || IdPaciente != CurPaciente) * { * CurPaciente = IdPaciente; * DataTable DatosPaciente = datos1.LoadData("select * from pacientes where IdPaciente=" + IdPaciente.ToString()); * NombrePaciente = DatosPaciente.Rows[0]["Nombre"].ToString(); * StatusPaciente = (Int16)DatosPaciente.Rows[0]["estatus"]; * } * * * if (DateTime.Compare(BFecha, StartDate) <= 0) continue; * if (DateTime.Compare(AFecha, EndDate) >= 0) continue; * * //if (DateTime.Compare(AFecha, StartDate) > 0) AFecha = StartDate; * if (DateTime.Compare(BFecha, EndDate) > 0) BFecha = EndDate; * * * * while (DateTime.Compare(AFecha,BFecha)<0) * { * int curDia = (int)AFecha.DayOfWeek; * int diasadd = 0; * if (curDia > Dia) diasadd = (6 - curDia) + Dia; * if (curDia < Dia) diasadd = Dia - curDia; * DateTime EventoFecha = AFecha.AddDays(diasadd); * * DatosEventos.Rows.Add(IdEvento, AFecha.ToString("yyyy-MM-dd HH:mm:ss"),Duracion,NombrePaciente); * * if (Periodo == 2) AFecha = AFecha.AddDays(1); * if (Periodo == 3) AFecha = AFecha.AddDays(7); * if (Periodo == 4) AFecha = AFecha.AddMonths(1); * * * * } * * * * * * * } * * return DatosEventos; * * } * */ public void CreateCurrentEvents(Int32 curTerapia) { DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); //DataTable TempData = datos1.GetEvents(); DataTable TempData = datos1.LoadData("select * from Terapias where Id=" + curTerapia.ToString()); DataTable TablaColores = datos1.LoadData("select * from Colores order by Id"); string NombrePaciente = ""; Int16 StatusPaciente = 0; Int32 CurColor = 0; int CurPaciente = 0; string ColorPaciente = "#000000"; foreach (DataRow c in TempData.Rows) { Int32 IdEvento = (Int32)c["Id"]; Int32 IdPaciente = (Int32)c["IdPaciente"]; Int16 Duracion = (Int16)c["Duracion"]; Int16 IdTerapueta = (Int16)c["IdTerapeuta"]; Int16 Periodo = (Int16)c["Periodo"]; DateTime AFecha = (DateTime)c["Fecha"]; DateTime BFecha = (DateTime)c["Fecha2"]; DateTime Hora = (DateTime)c["Hora"]; Byte Dia = (Byte)c["Dia"]; if (CurPaciente == 0 || IdPaciente != CurPaciente) { CurPaciente = IdPaciente; DataTable DatosPaciente = datos1.LoadData("select * from pacientes where IdPaciente=" + IdPaciente.ToString()); NombrePaciente = DatosPaciente.Rows[0]["Nombre"].ToString(); StatusPaciente = (Int16)DatosPaciente.Rows[0]["estatus"]; CurColor = IdPaciente % 55; ColorPaciente = "#" + TablaColores.Rows[CurColor]["Color"].ToString(); } int curDia = (int)AFecha.DayOfWeek; int diasadd = 0; if (curDia > Dia) { diasadd = (7 - curDia) + Dia; } if (curDia < Dia) { diasadd = Dia - curDia; } DateTime EventoFecha = AFecha.AddDays(diasadd); DateTime EventoFechaStart = new DateTime(AFecha.Year, AFecha.Month, EventoFecha.Day, Hora.Hour, Hora.Minute, 0); DateTime EventoFechaEnd = EventoFechaStart.AddMinutes(Duracion); while (DateTime.Compare(EventoFechaStart, BFecha) < 0) { ArrayList valores = new ArrayList(); valores.Add(new Registro("IdEvento", IdEvento)); valores.Add(new Registro("Title", NombrePaciente)); valores.Add(new Registro("start_event", EventoFechaStart.ToString("yyyy-MM-dd HH:mm:ss"))); valores.Add(new Registro("end_event", EventoFechaEnd.ToString("yyyy-MM-dd HH:mm:ss"))); valores.Add(new Registro("Color", ColorPaciente)); valores.Add(new Registro("status1", 0)); valores.Add(new Registro("status2", 0)); valores.Add(new Registro("IdTipo", 1)); datos1.InsertData(valores, "Eventos"); if (Periodo == 2) { EventoFechaStart = EventoFechaStart.AddDays(1); EventoFechaEnd = EventoFechaEnd.AddDays(1); } if (Periodo == 3) { EventoFechaStart = EventoFechaStart.AddDays(7); EventoFechaEnd = EventoFechaEnd.AddDays(7); } if (Periodo == 4) { EventoFechaStart = EventoFechaStart.AddMonths(1); EventoFechaEnd = EventoFechaEnd.AddMonths(1); } } } }
private void CargaDatos() { //////// DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); ComboGrados = datos1.LoadData("select * from Grados"); this.comboBox1.ItemsSource = ComboGrados.DefaultView; this.comboBox1.DisplayMemberPath = ComboGrados.Columns[1].ToString(); this.comboBox1.SelectedValuePath = ComboGrados.Columns[0].ToString(); ComboEscuelas = datos1.LoadData("select * from Escuelas"); this.comboBox2.ItemsSource = ComboEscuelas.DefaultView; this.comboBox2.DisplayMemberPath = ComboEscuelas.Columns[1].ToString(); this.comboBox2.SelectedValuePath = ComboEscuelas.Columns[0].ToString(); ComboEstado = datos1.LoadData("select * from estado_paciente"); this.comboBox3.ItemsSource = ComboEstado.DefaultView; this.comboBox3.DisplayMemberPath = ComboEstado.Columns[1].ToString(); this.comboBox3.SelectedValuePath = ComboEstado.Columns[0].ToString(); ComboEstadosRepublica = datos1.LoadData("select * from Estados"); this.comboBox4.ItemsSource = ComboEstadosRepublica.DefaultView; this.comboBox4.DisplayMemberPath = ComboEstadosRepublica.Columns[1].ToString(); this.comboBox4.SelectedValuePath = ComboEstadosRepublica.Columns[0].ToString(); if (this.curPaciente != 0) { this.DatosPaciente = datos1.LoadData("select Nombre,Comentarios,Sexo,IdEscuela,IdGradoEscuela, Datepart('yyyy',FechaNac),DatePart('m',FechaNac),Datepart('d',FechaNac),estatus, calle, exterior, interior,cp,telefonocasa,telefonorecados,telefonocel,idciudad,idmunicipio,idcolonia, idestado, email from pacientes where IdPaciente=" + this.curPaciente.ToString()); this.comboBox1.SelectedValue = Convert.ToInt32(DatosPaciente.Rows[0]["IdGradoEscuela"].ToString()); // ComboBoxZone.SelectedValue.ToString()); this.comboBox2.SelectedValue = Convert.ToInt32(DatosPaciente.Rows[0]["IdEscuela"].ToString()); this.comboBox3.SelectedValue = Convert.ToInt32(DatosPaciente.Rows[0]["estatus"].ToString()); this.comboBox4.SelectedValue = Convert.ToInt32(DatosPaciente.Rows[0]["idestado"].ToString()); String NombrePaciente = DatosPaciente.Rows[0]["Nombre"].ToString(); Int32 AnoNac = Convert.ToInt32(DatosPaciente.Rows[0][5].ToString()); Int32 MesNac = Convert.ToInt32(DatosPaciente.Rows[0][6].ToString()); Int32 DiaNac = Convert.ToInt32(DatosPaciente.Rows[0][7].ToString()); Int32 Sexo = Convert.ToInt32(DatosPaciente.Rows[0]["Sexo"].ToString()); string Dato1 = ""; // DatosPaciente.Rows[0]["idestado"].GetType().ToString(); Dato1 = DatosPaciente.Rows[0]["idmunicipio"].ToString(); Int32 curMunicipio = 0; if (Dato1.Length != 0) { curMunicipio = Convert.ToInt32(Dato1); } Dato1 = DatosPaciente.Rows[0]["idcolonia"].ToString(); Int32 curColonia = 0; if (Dato1.Length != 0) { curColonia = Convert.ToInt32(Dato1); } Dato1 = DatosPaciente.Rows[0]["idciudad"].ToString(); Int32 curCiudad = 0; if (Dato1.Length != 0) { curCiudad = Convert.ToInt32(Dato1); } this.Colonia.Text = datos1.GetNombreTabla(curColonia, "colonia", "Id", "Nombre"); this.Ciudad.Text = datos1.GetNombreTabla(curCiudad, "ciudad", "Id", "Nombre"); this.Municipio.Text = datos1.GetNombreTabla(curMunicipio, "municipio", "Id", "Nombre"); this.FechaNac_DatePicker.SelectedDate = new DateTime(AnoNac, MesNac, DiaNac); this.NombrePaciente.Text = NombrePaciente; this.Calle.Text = DatosPaciente.Rows[0]["calle"].ToString(); this.exterior.Text = DatosPaciente.Rows[0]["exterior"].ToString(); this.interior.Text = DatosPaciente.Rows[0]["interior"].ToString(); this.CodigoPostal.Text = DatosPaciente.Rows[0]["cp"].ToString(); this.telefonocasa.Text = DatosPaciente.Rows[0]["telefonocasa"].ToString(); this.telefonomovil.Text = DatosPaciente.Rows[0]["telefonocel"].ToString(); this.telefonorecados.Text = DatosPaciente.Rows[0]["telefonorecados"].ToString(); this.email.Text = DatosPaciente.Rows[0]["email"].ToString(); if (Sexo == 1) { this.radioButton1.IsChecked = true; this.radioButton2.IsChecked = false; } else { this.radioButton2.IsChecked = true; this.radioButton1.IsChecked = false; } String photolocation = "C:\\Datos\\images\\" + this.curPaciente.ToString() + ".jpg"; //file name if (File.Exists(photolocation)) { try { BitmapImage bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.UriSource = new Uri(photolocation); bitmap.EndInit(); this.image.Source = bitmap; this.personPhoto = bitmap; } catch (System.IO.FileNotFoundException) { MessageBox.Show("There was an error opening the bitmap." + "Please check the path."); } } } else { this.comboBox1.SelectedValue = 1; this.comboBox2.SelectedValue = 1; this.comboBox3.SelectedValue = 1; this.comboBox4.SelectedValue = 14; this.FechaNac_DatePicker.SelectedDate = DateTime.Today; this.NombrePaciente.Text = ""; this.radioButton1.IsChecked = true; this.radioButton2.IsChecked = false; } ///////// }
private void loadDatos() { DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); DateTime CurTime = (DateTime)this.datepicker1.SelectedDate; string query = "select * from eventos where datepart('m', start_event) =" + CurTime.Month.ToString() + " and datepart('yyyy', start_event)=" + CurTime.Year.ToString() + " and datepart('d', start_event)=" + CurTime.Day.ToString() + " order by start_event"; //MessageBox.Show(query); DataTable EventosTemp = datos1.LoadData(query); if (EventosTemp == null) { this.listView.ItemsSource = null; return; } DataTable DatosAsistencias = new DataTable("Terapias"); DatosAsistencias.Columns.Add("IdEvento", Type.GetType("System.Int32")); DatosAsistencias.Columns.Add("Nombre", Type.GetType("System.String")); DatosAsistencias.Columns.Add("Hora", Type.GetType("System.String")); DatosAsistencias.Columns.Add("Estado", Type.GetType("System.String")); DatosAsistencias.Columns.Add("Tipo", Type.GetType("System.String")); DatosAsistencias.Columns.Add("ImagePath", Type.GetType("System.String")); foreach (DataRow c in EventosTemp.Rows) { string tipoA = c["IdTipo"].GetType().ToString(); Int32 Id = (Int32)c["Id"]; Int32 IdEvento = (Int32)c["IdEvento"]; Byte IdTipo = (Byte)c["IdTipo"]; Byte Estatus1 = (Byte)c["status1"]; Byte Estatus2 = (Byte)c["status2"]; DateTime startFecha = (DateTime)c["start_event"]; Int32 IdPaciente = 0; string NombrePaciente; string ImagePath = ""; string TipoEvento = "Terapia"; if (IdTipo == 1) { DataTable DatosTerapia = datos1.LoadData("select * from Terapias where Id=" + IdEvento.ToString()); IdPaciente = (Int32)DatosTerapia.Rows[0]["IdPaciente"]; } if (IdTipo == 2) { DataTable DatosCita = datos1.LoadData("select * from Citas where Id=" + IdEvento.ToString()); IdPaciente = (Int32)DatosCita.Rows[0]["IdPaciente"]; TipoEvento = "Cita"; } DataTable DatosPaciente = datos1.LoadData("select * from pacientes where IdPaciente=" + IdPaciente.ToString()); NombrePaciente = DatosPaciente.Rows[0]["Nombre"].ToString(); Int16 Sexo = (Int16)DatosPaciente.Rows[0]["Sexo"]; string EstadoEvento = datos1.GetNombreTabla(Estatus1, "EstadoEventos1", "Id", "Nombre"); String photolocation = "C:\\Datos\\images\\" + IdPaciente.ToString() + ".jpg"; //file name if (File.Exists(photolocation)) { ImagePath = photolocation; } else { if (Sexo == 1) { ImagePath = "C:\\Datos\\res\\child1.jpg"; } if (Sexo == 2) { ImagePath = "C:\\Datos\\res\\child2.jpg"; } } DatosAsistencias.Rows.Add(Id, NombrePaciente, startFecha.ToShortTimeString(), EstadoEvento, TipoEvento, ImagePath); } this.listView.ItemsSource = DatosAsistencias.DefaultView; }