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 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.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(); }