예제 #1
0
 public void agregarFicha(Ficha ficha)
 {
     if (!File.Exists(ruta + nombreArchivo))
     {
         initialize();
         File.WriteAllLines(ruta + nombreArchivo, agregarFichas(ficha));
     }
     else
     {
         String[] datosDeVuelta = File.ReadAllLines(ruta + nombreArchivo);
         String[] nuevosDatos   = new String[datosDeVuelta.Length + 1];
         for (int i = 0; i < nuevosDatos.Length; i++)
         {
             if (i == datosDeVuelta.Length)
             {
                 nuevosDatos[i] = agregarFichas(ficha)[0];
             }
             else
             {
                 nuevosDatos[i] = datosDeVuelta[i];
             }
         }
         File.WriteAllLines(ruta + nombreArchivo, nuevosDatos);
     }
 }
예제 #2
0
        private void pictureBox1_Click_1(object sender, EventArgs e)
        {
            picEditar.Visible = false;
            Ficha   ficha   = new Ficha(dtDatos.SelectedCells[0].Value.ToString(), dtDatos.SelectedCells[1].Value.ToString(), dtDatos.SelectedCells[2].Value.ToString(), dtDatos.SelectedCells[3].Value.ToString(), dtDatos.SelectedCells[4].Value.ToString(), dtDatos.SelectedCells[5].Value.ToString(), dtDatos.SelectedCells[6].Value.ToString(), dtDatos.SelectedCells[7].Value.ToString(), dtDatos.SelectedCells[8].Value.ToString(), dtDatos.SelectedCells[9].Value.ToString());
            Edicion edicion = new Edicion();

            edicion.Show();
            this.Visible = false;
            edicion.editarFicha(ficha);
        }
예제 #3
0
        private void picSave_Click(object sender, EventArgs e)
        {
            Ficha fichaEditada = new Ficha(txtNombre.Text, txtTel1.Text, txtTel2.Text, txtTel3.Text, txtDireccion.Text, txtAnotaciones.Text, txtObservaciones.Text, txtFechas.Text, txtDeuda.Text, txtID.Text);

            if (control.editarFicha(fichaEditada))
            {
                MessageBox.Show("Datos correctamente editados!");
                Control control = new Control();
                control.Show();
                this.Close();
            }
        }
예제 #4
0
 public void editarFicha(Ficha ficha)
 {
     txtNombre.Text        = ficha.nombre;
     txtTel1.Text          = ficha.telefono1;
     txtTel2.Text          = ficha.telefono2;
     txtTel3.Text          = ficha.telefono3;
     txtDireccion.Text     = ficha.direccion;
     txtAnotaciones.Text   = ficha.anotaciones;
     txtObservaciones.Text = ficha.observaciones;
     txtDeuda.Text         = ficha.deuda;
     txtFechas.Text        = ficha.fechas;
     txtID.Text            = ficha.ID;
 }
예제 #5
0
 private void pictureBox1_Click(object sender, EventArgs e)
 {
     if (txtNombre.Text == "" || txtAnotaciones.Text == "" || txtDeuda.Text == "" || txtDireccion.Text == "" || txtFechas.Text == "" || txtObservaciones.Text == "" || txtTel1.Text == "" || txtTel2.Text == "" || txtTel3.Text == "")
     {
         MessageBox.Show("Llene todos los campos!");
     }
     else
     {
         Guid  id    = Guid.NewGuid();
         Ficha ficha = new Ficha(txtNombre.Text, txtTel1.Text, txtTel2.Text, txtTel3.Text, txtDireccion.Text, txtAnotaciones.Text, txtObservaciones.Text, txtFechas.Text, txtDeuda.Text, id.ToString());
         control.agregarFicha(ficha);
         MessageBox.Show("Ficha agregada exitosamente!");
         refreshData();
     }
 }
예제 #6
0
 public bool editarFicha(Ficha ficha)
 {
     String[] datos         = retornarDatos();
     String[] datosEditados = new String[datos.Length];
     for (int i = 0; i < datos.Length; i++)
     {
         String[] data = datos[i].Split(',');
         if (data[9] == ficha.ID)
         {
             datosEditados[i] = agregarFichas(ficha)[0];
         }
         else
         {
             datosEditados[i] = datos[i];
         }
     }
     File.WriteAllLines(ruta + nombreArchivo, datosEditados);
     return(true);
 }
예제 #7
0
 public String[] agregarFichas(Ficha ficha)
 {
     String[] datos = new String[1];
     datos[0] = ficha.nombre + "," + ficha.telefono1 + "," + ficha.telefono2 + "," + ficha.telefono3 + "," + ficha.direccion + "," + ficha.anotaciones + "," + ficha.observaciones + "," + ficha.fechas + "," + ficha.deuda + "," + ficha.ID.ToString();
     return(datos);
 }