Esempio n. 1
0
        private void boton_agregar_Click(object sender, EventArgs e)
        {
            bool existe = false;

            try
            {
                if (nombre_maquina.Text == "" || marca.Text == "" || serie.Text == "" || origen.Text == "" || precio.Text == "")
                {
                    MessageBox.Show("Faltan campos por llenar");
                }
                else
                {
                    if (grid_maquina.RowCount == 0)
                    {
                        c   = new conexion();
                        cmd = new SqlCommand("INSERT INTO MAQUINA(nombre_maquina, marca, serie, origen, precio, existe_maquina, horas_acumuladas, horas_totales, encargado, categoria) VALUES('" + nombre_maquina.Text + "', '" + marca.Text + "', '" + serie.Text + "', '" + origen.Text + "', " + precio.Text + ", " + 1 + ", " + 0 + ", " + 0 + ", '" + encargado.SelectedItem + "', '" + categoria.SelectedItem + "')", c.regresaConexion());
                        cmd.ExecuteNonQuery();
                        c.cerrarConexion();
                        MessageBox.Show("Maquina Insertada");
                        encargado.SelectedIndex = 0;
                        nombre_maquina.Text     = "";
                        marca.Text  = "";
                        serie.Text  = "";
                        origen.Text = "";
                        precio.Text = "";
                    }
                    else
                    {
                        for (int i = 0; i < grid_maquina.RowCount; i++)
                        {
                            if (grid_maquina.Rows[i].Cells[3].Value.ToString() == serie.Text)
                            {
                                existe = true;
                            }
                        }
                        if (existe == false)
                        {
                            c   = new conexion();
                            cmd = new SqlCommand("INSERT INTO MAQUINA(nombre_maquina, marca, serie, origen, precio, existe_maquina, horas_acumuladas, horas_totales, encargado, categoria) VALUES('" + nombre_maquina.Text + "', '" + marca.Text + "', '" + serie.Text + "', '" + origen.Text + "', " + precio.Text + ", " + 1 + ", " + 0 + ", " + 0 + ", '" + encargado.SelectedItem + "', '" + categoria.SelectedItem + "')", c.regresaConexion());
                            cmd.ExecuteNonQuery();
                            c.cerrarConexion();
                            MessageBox.Show("Maquina Insertada");
                            encargado.SelectedIndex = 0;
                            nombre_maquina.Text     = "";
                            marca.Text  = "";
                            serie.Text  = "";
                            origen.Text = "";
                            precio.Text = "";
                        }
                        else
                        {
                            MessageBox.Show("YA ESTA DADA DE ALTA LA MAQUINA ");
                        }
                        nombre_maquina.Text     = "";
                        marca.Text              = "";
                        serie.Text              = "";
                        origen.Text             = "";
                        precio.Text             = "";
                        encargado.SelectedIndex = 0;
                    }

                    MuestraDatosMaquinaria(grid_maquina);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("No se pudo insertar" + ex.ToString());
                c.cerrarConexion();
            }
        }
Esempio n. 2
0
        private void boton_agregar_Click(object sender, EventArgs e)
        {
            bool existe = false;

            try
            {
                if (fecha.Text == "" || Descripcion.Text == "")
                {
                    MessageBox.Show("Faltan campos por llenar");
                }
                else
                {
                    if (grid_fallas.RowCount == 0)
                    {
                        c   = new conexion();
                        cmd = new SqlCommand("INSERT INTO FALLAS(maquina, sistema_afectado, descripcion, fecha) VALUES('" + nombre_maquina.SelectedItem + "', '" + sistema_afectado.SelectedItem + "', '" + Descripcion.Text + "', '" + fecha.Text + "')", c.regresaConexion());
                        cmd.ExecuteNonQuery();
                        c.cerrarConexion();
                        MessageBox.Show("Mantenimiento Insertado");
                        id_falla.Text = "";
                        fecha.Text    = DateTime.Now.ToString("dd-MM-yyyy");
                        nombre_maquina.SelectedIndex = 0;
                        Descripcion.Text             = "";
                    }
                    else
                    {
                        for (int i = 0; i < grid_fallas.RowCount; i++)
                        {
                            if (grid_fallas.Rows[i].Cells[0].Value.ToString() == id_falla.Text)
                            {
                                existe = true;
                            }
                        }
                        if (existe == false)
                        {
                            c   = new conexion();
                            cmd = new SqlCommand("INSERT INTO FALLAS(maquina, sistema_afectado, descripcion, fecha) VALUES('" + nombre_maquina.SelectedItem + "', '" + sistema_afectado.SelectedItem + "', '" + Descripcion.Text + "', '" + fecha.Text + "')", c.regresaConexion());
                            cmd.ExecuteNonQuery();
                            c.cerrarConexion();
                            MessageBox.Show("Mantenimiento Insertado");
                            nombre_maquina.SelectedIndex = 0;
                            id_falla.Text    = "";
                            fecha.Text       = DateTime.Now.ToString("dd-MM-yyyy");
                            Descripcion.Text = "";
                        }
                        else
                        {
                            MessageBox.Show("YA ESTA DADA DE ALTA LA MAQUINA ");
                        }
                        nombre_maquina.SelectedIndex = 0;
                        id_falla.Text    = "";
                        fecha.Text       = DateTime.Now.ToString("dd-MM-yyyy");
                        Descripcion.Text = "";
                    }

                    MuestraDatos(grid_fallas);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("No se pudo insertar" + ex.ToString());
                c.cerrarConexion();
            }
        }
Esempio n. 3
0
        private void boton_agregar_Click(object sender, EventArgs e)
        {
            bool existe = false;

            try
            {
                if (origen.Text == "" && id_Maquina != 0)
                {
                    MessageBox.Show("Faltan campos por llenar");
                }
                else
                {
                    if (grid_salida_maquinaria.RowCount == 0)
                    {
                        c   = new conexion();
                        cmd = new SqlCommand("INSERT INTO SALIDAS(nombre_maquinaria, nombre_operador, fecha_salida, fecha_regreso, origen, nombre_obra, id_maquina, cliente, categoria) VALUES('" + combo_maquina.SelectedItem + "', '" + combo_operador.SelectedItem + "', '" + fecha_salida.Text + "', '" + fecha_regreso.Text + "','" + origen.Text + "','" + combo_obra.SelectedItem + "', " + id_Maquina + ", '" + cliente.Text + "', '" + categoria.SelectedItem + "')", c.regresaConexion());
                        cmd.ExecuteNonQuery();
                        c.cerrarConexion();
                        ////////////////////////////////////////////////////////////////////////////
                        c   = new conexion();
                        cmd = new SqlCommand("UPDATE MAQUINA SET existe_maquina =" + 0 + " WHERE nombre_maquina = '" + combo_maquina.SelectedItem + "';", c.regresaConexion());
                        cmd.ExecuteNonQuery();
                        c.cerrarConexion();
                        ///////////////////////////////////////////////////////////////////////////
                        MessageBox.Show("Salida Insertada");
                        origen.Text                  = "";
                        fecha_salida.Text            = DateTime.Now.ToString("dd-MM-yyyy");
                        fecha_regreso.Text           = DateTime.Now.ToString("dd-MM-yyyy");
                        combo_maquina.Text           = "";
                        combo_operador.SelectedIndex = 0;
                        combo_obra.SelectedIndex     = 0;
                    }
                    else
                    {
                        for (int i = 0; i < grid_salida_maquinaria.RowCount; i++)
                        {
                            if (grid_salida_maquinaria.Rows[i].Cells[3].Value.ToString() == grid_salida_maquinaria.CurrentRow.Cells[0].Value.ToString())
                            {
                                existe = true;
                            }
                        }
                        if (existe == false)
                        {
                            c   = new conexion();
                            cmd = new SqlCommand("INSERT INTO SALIDAS(nombre_maquinaria, nombre_operador, fecha_salida, fecha_regreso, origen, nombre_obra, id_maquina, cliente, categoria) VALUES('" + combo_maquina.SelectedItem + "', '" + combo_operador.SelectedItem + "', '" + fecha_salida.Text + "', '" + fecha_regreso.Text + "','" + origen.Text + "','" + combo_obra.SelectedItem + "', " + id_Maquina + ", '" + cliente.Text + "', '" + categoria.SelectedItem + "')", c.regresaConexion());
                            cmd.ExecuteNonQuery();

                            c.cerrarConexion();
                            ////////////////////////////////////////////////////////////////////////////
                            c   = new conexion();
                            cmd = new SqlCommand("UPDATE MAQUINA SET existe_maquina =" + 0 + " WHERE nombre_maquina = '" + combo_maquina.SelectedItem + "';", c.regresaConexion());
                            cmd.ExecuteNonQuery();
                            c.cerrarConexion();
                            ///////////////////////////////////////////////////////////////////////////
                            MessageBox.Show("Salida Insertada");
                            origen.Text                  = "";
                            fecha_salida.Text            = DateTime.Now.ToString("dd-MM-yyyy");
                            fecha_regreso.Text           = DateTime.Now.ToString("dd-MM-yyyy");
                            combo_maquina.Text           = "";
                            combo_operador.SelectedIndex = 0;
                            combo_obra.SelectedIndex     = 0;
                        }
                        else
                        {
                            MessageBox.Show("YA ESTA DADA DE ALTA LA SALIDA ");
                        }
                        origen.Text                  = "";
                        fecha_salida.Text            = DateTime.Now.ToString("dd-MM-yyyy");
                        fecha_regreso.Text           = DateTime.Now.ToString("dd-MM-yyyy");
                        combo_maquina.SelectedIndex  = 0;
                        combo_operador.SelectedIndex = 0;
                        combo_obra.SelectedIndex     = 0;
                    }

                    MuestraDatos(grid_salida_maquinaria);
                    combo_maquina.Items.Clear();
                    c   = new conexion();
                    cmd = new SqlCommand("SELECT nombre_maquina FROM MAQUINA WHERE existe_maquina =" + 1 + ";", c.regresaConexion());
                    dr  = cmd.ExecuteReader();

                    while (dr.Read())
                    {
                        combo_maquina.Items.Add(dr["nombre_maquina"].ToString());
                    }

                    c.cerrarConexion();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("No se pudo insertar" + ex.ToString());
                c.cerrarConexion();
            }
        }
Esempio n. 4
0
        private void boton_agregar_Click(object sender, EventArgs e)
        {
            bool existe = false;

            try
            {
                if (nombre_cliente.Text == "" || rfc.Text == "" || empresa.Text == "" || direccion.Text == "" || colonia.Text == "" || ciudad.Text == "" || codigo_postal.Text == "" || telefeno.Text == "" || correo.Text == "")
                {
                    MessageBox.Show("Faltan campos por llenar");
                }
                else
                {
                    if (grid_clientes.RowCount == 0)
                    {
                        c   = new conexion();
                        cmd = new SqlCommand("INSERT INTO CLIENTE(nombre_cliente, rfc, empresa, direccion, colonia, cuidad, codigo_postal, telefono, correo) VALUES('" + nombre_cliente.Text + "', '" + rfc.Text + "', '" + empresa.Text + "', '" + direccion.Text + "', '" + colonia.Text + "', '" + ciudad.Text + "', " + codigo_postal.Text + ", " + telefeno.Text + ",'" + correo.Text + "')", c.regresaConexion());
                        cmd.ExecuteNonQuery();
                        c.cerrarConexion();
                        MessageBox.Show("Cliente Insertado");
                        nombre_cliente.Text = "";
                        rfc.Text            = "";
                        empresa.Text        = "";
                        direccion.Text      = "";
                        colonia.Text        = "";
                        ciudad.Text         = "";
                        codigo_postal.Text  = "";
                        telefeno.Text       = "";
                        correo.Text         = "";
                    }
                    else
                    {
                        for (int i = 0; i < grid_clientes.RowCount; i++)
                        {
                            if (grid_clientes.Rows[i].Cells[2].Value.ToString() == rfc.Text)
                            {
                                existe = true;
                            }
                        }
                        if (existe == false)
                        {
                            c   = new conexion();
                            cmd = new SqlCommand("INSERT INTO CLIENTE(nombre_cliente, rfc, empresa, direccion, colonia, cuidad, codigo_postal, telefono, correo) VALUES('" + nombre_cliente.Text + "', '" + rfc.Text + "', '" + empresa.Text + "', '" + direccion.Text + "', '" + colonia.Text + "', '" + ciudad.Text + "', " + codigo_postal.Text + ", " + telefeno.Text + ",'" + correo.Text + "')", c.regresaConexion());
                            cmd.ExecuteNonQuery();
                            c.cerrarConexion();
                            MessageBox.Show("Cliente Insertado");
                            nombre_cliente.Text = "";
                            rfc.Text            = "";
                            empresa.Text        = "";
                            direccion.Text      = "";
                            colonia.Text        = "";
                            ciudad.Text         = "";
                            codigo_postal.Text  = "";
                            telefeno.Text       = "";
                            correo.Text         = "";
                        }
                        else
                        {
                            MessageBox.Show("YA ESTA DADO DE ALTA EL CLIENTE");
                        }
                        nombre_cliente.Text = "";
                        rfc.Text            = "";
                        empresa.Text        = "";
                        direccion.Text      = "";
                        colonia.Text        = "";
                        ciudad.Text         = "";
                        codigo_postal.Text  = "";
                        telefeno.Text       = "";
                        correo.Text         = "";
                    }

                    MuestraDatos(grid_clientes);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("No se pudo insertar" + ex.ToString());
                c.cerrarConexion();
            }
        }
Esempio n. 5
0
        private void boton_agregar_Click(object sender, EventArgs e)
        {
            int  suma, sumatotales;
            bool existe = false;

            try
            {
                if (horas_trabajadas.Text == "" && notas.Text == "")
                {
                    MessageBox.Show("Faltan campos por llenar");
                }
                else
                {
                    if (grid_horas_maquinaria.RowCount == 0)
                    {
                        suma = int.Parse(horas_trabajadas.Text) + int.Parse(horas_acumuladas.Text);
                        horas_acumuladas.Text = suma.ToString();
                        sumatotales           = int.Parse(horas_acumuladas.Text) + int.Parse(horas_totales.Text);
                        horas_totales.Text    = sumatotales.ToString();
                        c   = new conexion();
                        cmd = new SqlCommand("INSERT INTO HORAS_MAQUINA(maquina, horas_trabajadas, horas_totales, fecha_inicio, fecha_finales, horas_acumuladas, servicio, notas) VALUES('" + nombre_maquina.SelectedItem + "', " + horas_trabajadas.Text + ", " + horas_totales.Text + ", '" + fecha_inicio.Text + "', '" + fecha_final.Text + "', " + horas_trabajadas.Text + "," + 0 + ", '" + notas.Text + "')", c.regresaConexion());
                        cmd.ExecuteNonQuery();
                        c.cerrarConexion();
                        MessageBox.Show("Horas de la Maquinaria Insertadas");
                        fecha_inicio.Text     = DateTime.Now.ToString("dd-MM-yyyy");
                        fecha_final.Text      = DateTime.Now.ToString("dd-MM-yyyy");
                        horas_totales.Text    = "";
                        horas_trabajadas.Text = "";
                        horas_acumuladas.Text = "";
                        MuestraDatos(grid_horas_maquinaria);
                    }
                    else
                    {
                        for (int i = 0; i < grid_horas_maquinaria.RowCount; i++)
                        {
                            if (grid_horas_maquinaria.Rows[i].Cells[0].Value.ToString() == id_horas.Text)
                            {
                                existe = true;
                            }
                        }
                        if (existe == false)
                        {
                            suma = int.Parse(horas_trabajadas.Text) + int.Parse(horas_acumuladas.Text);
                            horas_acumuladas.Text = suma.ToString();
                            sumatotales           = int.Parse(horas_acumuladas.Text) + int.Parse(horas_totales.Text);
                            horas_totales.Text    = sumatotales.ToString();
                            c   = new conexion();
                            cmd = new SqlCommand("INSERT INTO HORAS_MAQUINA(maquina, horas_trabajadas, horas_totales, fecha_inicio, fecha_finales, horas_acumuladas, servicio, notas) VALUES('" + nombre_maquina.SelectedItem + "', " + horas_trabajadas.Text + ", " + horas_totales.Text + ", '" + fecha_inicio.Text + "', '" + fecha_final.Text + "', " + horas_trabajadas.Text + "," + 0 + ",'" + notas.Text + "')", c.regresaConexion());
                            cmd.ExecuteNonQuery();
                            c.cerrarConexion();
                            MessageBox.Show("Horas de la Maquinaria Insertadas");
                            fecha_inicio.Text     = DateTime.Now.ToString("dd-MM-yyyy");
                            fecha_final.Text      = DateTime.Now.ToString("dd-MM-yyyy");
                            horas_totales.Text    = "";
                            horas_trabajadas.Text = "";
                            horas_acumuladas.Text = "";
                        }
                        else
                        {
                            MessageBox.Show("YA ESTAN DADAS DE ALTA LAS HORAS");
                        }
                        fecha_inicio.Text     = DateTime.Now.ToString("dd-MM-yyyy");
                        fecha_final.Text      = DateTime.Now.ToString("dd-MM-yyyy");
                        horas_totales.Text    = "";
                        horas_trabajadas.Text = "";
                        horas_acumuladas.Text = "";
                        MuestraDatos(grid_horas_maquinaria);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("No se pudo insertar" + ex.ToString());
                c.cerrarConexion();
            }
        }
Esempio n. 6
0
        private void Agregar_Obras_Click(object sender, EventArgs e)
        {
            bool existe = false;

            try
            {
                if (Nombre_Obra.Text == "" || Lugar_Obra.Text == "" || Fecha_Inicio.Text == "" || Fecha_Termino.Text == "" || Empresa_Facturar.Text == "" || Estimacion_Obra.Text == "" || Costo_Obra.Text == "" || Residente.Text == "" || Notas.Text == "" || Cliente_Obra.Text == "")
                {
                    MessageBox.Show("Faltan campos por llenar");
                }
                else
                {
                    if (Grid_Obras.RowCount == 0)
                    {
                        c   = new conexion();
                        cmd = new SqlCommand("INSERT INTO OBRA(nombre_obra, lugar_obra, fecha_inicio, fecha_termino, empresa_factura, estimacion, costo, residente, notas, cliente_obra) VALUES('" + Nombre_Obra.Text + "', '" + Lugar_Obra.Text + "', '" + Fecha_Inicio.Text + "', '" + Fecha_Termino.Text + "', '" + Empresa_Facturar.SelectedItem + "', " + Estimacion_Obra.Text + ", " + Costo_Obra.Text + ", '" + Residente.SelectedItem + "','" + Notas.Text + "', '" + Cliente_Obra.SelectedItem + "' )", c.regresaConexion());
                        cmd.ExecuteNonQuery();
                        c.cerrarConexion();
                        MessageBox.Show("Obra Insertada");
                        id_obra.Text          = "";
                        Nombre_Obra.Text      = "";
                        Lugar_Obra.Text       = "";
                        Fecha_Inicio.Text     = "";
                        Fecha_Termino.Text    = "";
                        Empresa_Facturar.Text = "";
                        Estimacion_Obra.Text  = "";
                        Costo_Obra.Text       = "";
                        Residente.Text        = "";
                        Notas.Text            = "";
                        Cliente_Obra.Text     = "";
                        Fecha_Inicio.Text     = DateTime.Now.ToString("dd-MM-yyyy");
                        Fecha_Termino.Text    = DateTime.Now.ToString("dd-MM-yyyy");
                    }
                    else
                    {
                        for (int i = 0; i < Grid_Obras.RowCount; i++)
                        {
                            if (Grid_Obras.Rows[i].Cells[0].Value.ToString() == id_obra.Text)
                            {
                                existe = true;
                            }
                        }
                        if (existe == false)
                        {
                            c   = new conexion();
                            cmd = new SqlCommand("INSERT INTO OBRA(nombre_obra, lugar_obra, fecha_inicio, fecha_termino, empresa_factura, estimacion, costo, residente, notas, cliente_obra) VALUES('" + Nombre_Obra.Text + "', '" + Lugar_Obra.Text + "','" + Fecha_Inicio.Text + "', '" + Fecha_Termino.Text + "', '" + Empresa_Facturar.SelectedItem + "', " + Estimacion_Obra.Text + ", " + Costo_Obra.Text + ", '" + Residente.SelectedItem + "','" + Notas.Text + "', '" + Cliente_Obra.SelectedItem + "' )", c.regresaConexion());
                            cmd.ExecuteNonQuery();
                            c.cerrarConexion();
                            MessageBox.Show("Obra Insertada");
                            id_obra.Text         = "";
                            Nombre_Obra.Text     = "";
                            Lugar_Obra.Text      = "";
                            Fecha_Inicio.Text    = "";
                            Fecha_Termino.Text   = "";
                            Estimacion_Obra.Text = "";
                            Costo_Obra.Text      = "";
                            Notas.Text           = "";
                            Fecha_Inicio.Text    = DateTime.Now.ToString("dd-MM-yyyy");
                            Fecha_Termino.Text   = DateTime.Now.ToString("dd-MM-yyyy");
                        }
                        else
                        {
                            MessageBox.Show("YA ESTA DADA DE ALTA LA OBRA");
                        }
                        id_obra.Text         = "";
                        Nombre_Obra.Text     = "";
                        Lugar_Obra.Text      = "";
                        Fecha_Inicio.Text    = "";
                        Fecha_Termino.Text   = "";
                        Estimacion_Obra.Text = "";
                        Costo_Obra.Text      = "";
                        Notas.Text           = "";
                        Fecha_Inicio.Text    = DateTime.Now.ToString("dd-MM-yyyy");
                        Fecha_Termino.Text   = DateTime.Now.ToString("dd-MM-yyyy");
                    }

                    MuestraDatos(Grid_Obras);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("No se pudo insertar" + ex.ToString());
                c.cerrarConexion();
            }
        }