Exemple #1
0
        private void btnEjecutar_Click(object sender, EventArgs e)
        {
            // Se llama al método validacion
            Boolean condicion = validacion();

            if (!condicion)
            {
                MessageBox.Show("Los campos marcados con (*) son obligatorios", "Revisar", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                try
                {
                    //Se inserta los insumos utilizados en el mantenimiento
                    if (dgIns.Rows.Count > 0)
                    {
                        for (int i = 0; i < dgIns.Rows.Count; i++)
                        {
                            ic.InsertarInsumosHasMantenimiento(dgIns[0, i].Value.ToString(), lblCodigo.Text, dgIns[2, i].Value.ToString());
                        }
                    }
                    //Se inserta los trabajadores encargados del mantenimiento
                    for (int i = 0; i < dgPersonas.Rows.Count; i++)
                    {
                        mpc.asignarValores(lblCodigo.Text, dgPersonas[0, i].Value.ToString());
                        mpc.insertar();
                    }

                    // Se actualiza el mantenimiento
                    String fecha_inicio = dtpFechaInicio.Value.Year + "-" + dtpFechaInicio.Value.Month + "-" + dtpFechaInicio.Value.Day + "T" + dtpTiempoInicio.Value.ToString("HH:mm:ss");
                    String fecha_fin    = dtpFechaFin.Value.Year + "-" + dtpFechaFin.Value.Month + "-" + dtpFechaFin.Value.Day + "T" + dtpTiempoFin.Value.ToString("HH:mm:ss");
                    mc.agarrarDatosAct(fecha_inicio, fecha_fin, txtProceso.Text);
                    mc.actualizarEjecucion(lblCodigo.Text);
                    m.cargarTabla("");
                    m.cargarHoras();
                    Hide();
                }
                catch (Exception)
                {
                    MessageBox.Show("Ocurrió un error al ejectuar el mantenimiento preventivo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #2
0
        private void btnEjecutar_Click(object sender, EventArgs e)
        {
            // Con el método validacion validamos que los campos no estén vacíos
            Boolean condicion = validacion();

            if (!condicion)
            {
                MessageBox.Show("Los campos marcados con (*) son obligatorios", "Revisar", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                try
                {
                    //Se trae el valor de la fecha de daño, de estar deshabilitado la fecha se le pone nulo
                    String fecha_dano = dtpFechaDano.Value.Year + "-" + dtpFechaDano.Value.Month + "-" + dtpFechaDano.Value.Day;
                    if (!checkBox1.Checked)
                    {
                        fecha_dano = "";
                    }

                    //Se inserta el mantenimiento Correctivo
                    String  fecha_inicio     = dtpFechaInicio.Value.Year + "-" + dtpFechaInicio.Value.Month + "-" + dtpFechaInicio.Value.Day + "T" + dtpTiempoInicio.Value.ToString("HH:mm:ss");
                    String  fecha_fin        = dtpFechaFin.Value.Year + "-" + dtpFechaFin.Value.Month + "-" + dtpFechaFin.Value.Day + "T" + dtpTiempoFin.Value.ToString("HH:mm:ss");
                    String  fecha_solicitada = dtpFechaSoli.Value.Year + "-" + dtpFechaSoli.Value.Month + "-" + dtpFechaSoli.Value.Day + "T" + dtpFechaSoli.Value.ToString("HH:mm:ss");
                    DataRow r         = mc.traerUltimo("numero_orden");
                    int     num_orden = int.Parse(r["ultimo"].ToString()) + 1;
                    mc.agarrarDatosTodos("Correctivo", fecha_dano, fecha_inicio, fecha_fin, txtProceso.Text, listEqui.SelectedValue.ToString(), num_orden.ToString(), txtSoli.Text, fecha_solicitada);
                    mc.insertarTodo();

                    DataRow code = mc.traerUltimo("id");
                    //Se inserta en las tablas InsumosHasMantenimiento, MantenimientoHasHerramienta, MantenimientoHasPersona
                    for (int i = 0; i < dgIns.Rows.Count; i++)
                    {
                        ic.InsertarInsumosHasMantenimiento(dgIns[0, i].Value.ToString(), code["ultimo"].ToString(), dgIns[2, i].Value.ToString());
                    }

                    for (int i = 0; i < dgPersonas.Rows.Count; i++)
                    {
                        mpc.asignarValores(code["ultimo"].ToString(), dgPersonas[0, i].Value.ToString());
                        mpc.insertar();
                    }
                    for (int i = 0; i < dgFallo.Rows.Count - 1; i++)
                    {
                        if (dgFallo[0, i].Value.ToString() != "")
                        {
                            ayf.agarrarMantenimiento(dgFallo[0, i].Value.ToString(), code["ultimo"].ToString());
                            ayf.insertarFalloMantenimiento();
                        }
                    }
                    for (int i = 0; i < dgActividad.Rows.Count - 1; i++)
                    {
                        if (dgActividad[0, i].Value.ToString() != "")
                        {
                            ayf.agarrarMantenimiento(dgActividad[0, i].Value.ToString(), code["ultimo"].ToString());
                            ayf.insertarActividadMantenimiento();
                        }
                    }

                    me.cargarPrecios("");
                    Hide();
                    me.Show();
                }
                catch (Exception)
                {
                    MessageBox.Show("Ocurrió un error al ejecutar el mantenimiento correctivo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }