private void button12_Click(object sender, RoutedEventArgs e) { DataGridCellInfo curcell = dataGrid.CurrentCell; object item = dataGrid.SelectedItem; if (item == null) { return; } string ID = (dataGrid.SelectedCells[1].Column.GetCellContent(item) as TextBlock).Text; //MessageBox.Show(ID); MessageBoxResult result = MessageBox.Show("Esta seguro que desea elimiar esta Cita", "Advertencia", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation); if (result == MessageBoxResult.OK) { object curType = ((DataRowView)dataGrid.SelectedItem).Row[0]; // string curObject = curType.GetType().ToString(); Int32 curId = (Int32)((DataRowView)dataGrid.SelectedItem).Row["IdCita"]; DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); datos1.executeQuery("delete from Citas where Id=" + curId.ToString()); datos1.executeQuery("delete from eventos where IdTipo=2 and IdEvento=" + curId.ToString()); MessageBox.Show("Se elimino el registro", "Información"); CargaCitas(); } }
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 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 CargaDatos() { DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); datos1.CargaComboBoxData(this.comboBox_Estado, "select Id,Nombre from EstadoEventos1 order by Id"); this.comboBox_Estado.SelectedValue = 1; }
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; } }
///////////////// 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 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 button_Click(object sender, RoutedEventArgs e) { DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); string CurEstado = this.comboBox_Estado.SelectedValue.ToString(); datos1.executeQuery("update Eventos set status1=" + CurEstado + " where Id=" + this.curEvento.ToString()); this.estado_cambio = true; this.Close(); }
private void button10_Click(object sender, RoutedEventArgs e) { DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); cita dlg1 = new cita(); dlg1.CurPaciente = this.curPaciente; //dlg1.NombrePaciente = this.NombrePaciente.Text; dlg1.ShowDialog(); MessageBox.Show("Operación realizada", "Información"); CargaCitas(); }
private void button10_Click(object sender, RoutedEventArgs e) { DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); if (this.curPaciente == 0) { MessageBox.Show("Por favor primero, guarde el paciente y luego proceda a dar de alta las terapias", "Advertencia"); return; } Terapia dlg1 = new Terapia(); dlg1.SetCurPaciente(this.curPaciente); //dlg1.NombrePaciente = this.NombrePaciente.Text; dlg1.ShowDialog(); MessageBox.Show("Operación realizada", "Información"); CargaTerapias(); }
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"); } }
private void createFile() { StreamWriter file = new System.IO.StreamWriter(@"C:\Datos\Web\getevents.js"); DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); StringBuilder jsonData = new StringBuilder(); //file.WriteLine("var curEvents = "); DateTime CurTime = DateTime.Now; DateTime EndTime = CurTime.AddMonths(1); string json = datos1.getJsonEvents(CurTime, EndTime, "IdEvento in (select Id from Terapias where IdTerapeuta=" + this.curTerapeuta.ToString() + ") or IdEvento in (select Id from Citas where IdTerapeuta=" + this.curTerapeuta.ToString() + ")"); if (json.Length != 0) { jsonData.Append("var curEvents = "); jsonData.Append(json); jsonData.Append(";"); } else { jsonData.Append("var curEvent = [];"); } file.WriteLine(jsonData.ToString()); file.Close(); }
private void save_Click(object sender, RoutedEventArgs e) { DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); ArrayList valores = new ArrayList(); if (this.CitaFecha == null) { MessageBox.Show("Selecciona una fecha", "Advertencia"); return; } if (this.CitaFecha.Length == 0) { MessageBox.Show("Selecciona una fecha", "Advertencia"); return; } DateTime curFecha = System.Convert.ToDateTime(this.CitaFecha); Int32 Duracion = System.Convert.ToInt32(this.textBox.Text); Int32 Terapeuta = System.Convert.ToInt32(this.comboBoxTerapeutas.SelectedValue); // Int32 Minuto = System.Convert.ToInt32(this.comboBoxMinutos.SelectedValue); valores.Add(new Registro("Duracion", Duracion)); valores.Add(new Registro("IdPaciente", this.curPaciente)); valores.Add(new Registro("IdTerapeuta", Terapeuta)); valores.Add(new Registro("comentarios", this.comentarios.Text)); valores.Add(new Registro("Fecha", curFecha.ToString("yyyy-MM-dd HH:mm:ss"))); if (this.curCita != 0) { datos1.UpdateData(valores, this.curCita, "Id", "Citas"); } else { this.curCita = datos1.InsertData(valores, "Citas"); } if (this.curCita != 0) { datos1.executeQuery("delete from eventos where IdTipo=2 and IdEvento=" + this.curCita.ToString()); datos1.CreateCitaEvent(this.CurCita); } else { this.curCita = datos1.InsertData(valores, "Citas"); } this.Close(); }
/* * * * * * * * * * 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 guardaPaciente(object sender, RoutedEventArgs e) { ArrayList valores = new ArrayList(); int Sexo = 1; if (this.radioButton2.IsChecked.Value) { Sexo = 2; } DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); string NombrePaciente = this.NombrePaciente.Text; if (NombrePaciente.Length < 5) { MessageBox.Show("El nombre es invalido!", "Advertencia:"); return; } if (this.FechaNac_DatePicker.SelectedDate == null) { MessageBox.Show("La Fecha de naciemiento es invalida!", "Advertencia:"); return; } valores.Add(new Registro("Nombre", NombrePaciente)); valores.Add(new Registro("FechaNac", this.FechaNac_DatePicker.SelectedDate)); valores.Add(new Registro("Sexo", Sexo)); valores.Add(new Registro("IdGradoEscuela", this.comboBox1.SelectedValue)); valores.Add(new Registro("IdEscuela", this.comboBox2.SelectedValue)); valores.Add(new Registro("terapias", 1)); valores.Add(new Registro("estatus", this.comboBox3.SelectedValue)); valores.Add(new Registro("calle", this.Calle.Text)); valores.Add(new Registro("cp", this.CodigoPostal.Text)); valores.Add(new Registro("idestado", this.comboBox4.SelectedValue)); valores.Add(new Registro("exterior", this.exterior.Text)); valores.Add(new Registro("interior", this.interior.Text)); valores.Add(new Registro("telefonocasa", this.telefonocasa.Text)); valores.Add(new Registro("telefonocel", this.telefonomovil.Text)); valores.Add(new Registro("telefonorecados", this.telefonorecados.Text)); valores.Add(new Registro("email", this.email.Text)); Int32 CurCiudad = datos1.BuscaNombreTabla(this.Ciudad.Text, "Ciudad", "Id", "Nombre"); if (CurCiudad == 0) { CurCiudad = datos1.InsertaNombreCampo(this.Ciudad.Text, "Ciudad", "Nombre"); } Int32 CurMunicipio = datos1.BuscaNombreTabla(this.Municipio.Text, "Municipio", "Id", "Nombre"); if (CurMunicipio == 0) { CurMunicipio = datos1.InsertaNombreCampo(this.Ciudad.Text, "Municipio", "Nombre"); } Int32 CurColonia = datos1.BuscaNombreTabla(this.Colonia.Text, "Colonia", "Id", "Nombre"); if (CurColonia == 0) { CurColonia = datos1.InsertaNombreCampo(this.Colonia.Text, "Colonia", "Nombre"); } valores.Add(new Registro("idciudad", CurCiudad)); valores.Add(new Registro("idmunicipio", CurMunicipio)); valores.Add(new Registro("idcolonia", CurColonia)); if (this.curPaciente != 0) { datos1.UpdateData(valores, this.curPaciente, "IdPaciente", "pacientes"); } else { this.curPaciente = datos1.InsertData(valores, "pacientes"); } if (this.newLoadedImage) { try { JpegBitmapEncoder encoder = new JpegBitmapEncoder(); String photolocation = "C:\\Datos\\images\\" + this.curPaciente.ToString() + ".jpg"; //file name //encoder.Frames.Add(BitmapFrame.Create(this.personPhoto)); encoder.Frames.Add(BitmapFrame.Create((BitmapImage)this.image.Source)); using (var filestream = new FileStream(photolocation, FileMode.Create)) encoder.Save(filestream); } catch (Exception ex) { MessageBox.Show("Unable to save now."); } } this.Close(); }
private void save_Click(object sender, RoutedEventArgs e) { DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); ArrayList valores = new ArrayList(); if (this.TerapiaFecha == null) { MessageBox.Show("Selecciona una fecha", "Advertencia"); return; } if (this.TerapiaFecha.Length == 0) { MessageBox.Show("Selecciona una fecha", "Advertencia"); return; } DateTime curFecha = System.Convert.ToDateTime(this.TerapiaFecha); // Int32 Dia = System.Convert.ToInt32(this.comboBoxDias.SelectedValue); // Int32 Hora = System.Convert.ToInt32(this.comboBoxHoras.SelectedValue); Int32 Duracion = System.Convert.ToInt32(this.textBox.Text); Int32 Terapeuta = System.Convert.ToInt32(this.comboBoxTerapeutas.SelectedValue); Int32 Periodo = System.Convert.ToInt32(this.Repeticion.SelectedValue); DateTime StartFecha = (DateTime)this.datePicker0.SelectedDate; DateTime EndFecha = (DateTime)this.datePicker1.SelectedDate; // Int32 Minuto = System.Convert.ToInt32(this.comboBoxMinutos.SelectedValue); int CurDia = (int)curFecha.DayOfWeek; valores.Add(new Registro("Duracion", Duracion)); valores.Add(new Registro("IdPaciente", this.curPaciente)); valores.Add(new Registro("IdTerapeuta", Terapeuta)); valores.Add(new Registro("Periodo", Periodo)); valores.Add(new Registro("Fecha", StartFecha.ToString("yyyy-MM-dd HH:mm:ss"))); valores.Add(new Registro("Fecha2", EndFecha.ToString("yyyy-MM-dd HH:mm:ss"))); valores.Add(new Registro("Dia", CurDia)); valores.Add(new Registro("Hora", curFecha.ToString("2000-01-01 HH:mm:ss"))); if (this.curTerapia != 0) { datos1.UpdateData(valores, this.curTerapia, "Id", "terapias"); datos1.executeQuery("delete from eventos where IdTipo=1 and IdEvento=" + this.curTerapia.ToString()); datos1.CreateCurrentEvents(this.curTerapia); } else { this.curTerapia = datos1.InsertData(valores, "terapias"); } //MessageBox.Show(curFecha.ToShortDateString(),"Fecha"); //MessageBox.Show(curFecha.ToShortTimeString(), "Hora"); this.Close(); }
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; }
private void otraOpcion(object sender, RoutedEventArgs e) { // return; /* * * * ArrayList valores = new ArrayList(); * * string[] estados = * {"Aguascalientes", * "Baja California", * "Baja California Sur", * "Campeche", * "Coahuila", * "Colima", * "Chiapas", * "Chihuahua", * "Distrito Federal", * "Durango", * "Guanajuato", * "Guerrero", * "Hidalgo", * "Jalisco", * "México", * "Michoacán", * "Morelos", * "Nayarit", * "Nuevo León", * "Oaxaca", * "Puebla", * "Querétaro", * "Quintana Roo", * "San Luis Potosí", * "Sinaloa", * "Sonora", * "Tabasco", * "Tamaulipas", * "Tlaxcala", * "Veracruz", * "Yucatán", * "Zacatecas"}; * * DatosCehavi datos1 = new DatosCehavi(); * datos1.Connect(); * * for(int i=0;i<estados.Length;i++) * { * valores.Add(new Registro("Id", i+1)); * valores.Add(new Registro("Nombre", estados[i])); * datos1.InsertData(valores, "Estados"); * valores.Clear(); * * } * */ DatosCehavi datos1 = new DatosCehavi(); datos1.Connect(); datos1.executeQuery("update Eventos set estatus1=1"); //datos1.executeQuery("ALTER TABLE terapeutas ALTER COLUMN Id COUNTER(1,1)"); //datos1.executeQuery("delete from Citas"); return; }