Ejemplo n.º 1
0
 public void MuestraDatosMaquinaria(DataGridView d)
 {
     try
     {
         c  = new conexion();
         da = new SqlDataAdapter("SELECT * FROM MAQUINA", c.regresaConexion());
         dt = new DataTable();
         da.Fill(dt);
         d.DataSource = dt;
         c.cerrarConexion();
         if (grid_maquina.RowCount == 0)
         {
             boton_modificar.Enabled = false;
             boton_eliminar.Enabled  = false;
         }
         if (grid_maquina.RowCount != 0)
         {
             boton_modificar.Enabled = true;
             boton_eliminar.Enabled  = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("No se pudo insertar" + ex.ToString());
         c.cerrarConexion();
     }
 }
Ejemplo n.º 2
0
        private void Salidas_de_Maquinaria_Load(object sender, EventArgs e)
        {
            /* 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());
             * }
             * combo_maquina.Items.Insert(0, "-----SELECCIONA MAQUINA----------");
             * combo_maquina.SelectedIndex = 0;*/


            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            c   = new conexion();
            cmd = new SqlCommand("SELECT nombre FROM OPERADORES", c.regresaConexion());
            dr  = cmd.ExecuteReader();
            while (dr.Read())
            {
                combo_operador.Items.Add(dr["nombre"].ToString());
            }
            combo_operador.Items.Insert(0, "----SELECCIONA OPERADOR----");
            combo_operador.SelectedIndex = 0;


            c.cerrarConexion();
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            c   = new conexion();
            cmd = new SqlCommand("SELECT nombre_obra FROM OBRA", c.regresaConexion());
            dr  = cmd.ExecuteReader();
            while (dr.Read())
            {
                combo_obra.Items.Add(dr["nombre_obra"].ToString());
            }
            combo_obra.Items.Insert(0, "----SELECCIONA OBRA----");
            combo_obra.SelectedIndex = 0;


            c.cerrarConexion();

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            c   = new conexion();
            cmd = new SqlCommand("SELECT DISTINCT categoria FROM MAQUINA", c.regresaConexion());
            dr  = cmd.ExecuteReader();
            while (dr.Read())
            {
                categoria.Items.Add(dr["categoria"].ToString());
            }
            categoria.Items.Insert(0, "----SELECCIONA CATEGORIA----");
            categoria.SelectedIndex = 0;


            c.cerrarConexion();
        }
Ejemplo n.º 3
0
        /*  private void CargaCliente()
         * {
         *    Cliente_Obra.Items.Insert(0, "Julio Marin");
         *    Cliente_Obra.SelectedIndex = 0;
         *    Cliente_Obra.Items.Insert(1, "Cesar Cardona");
         *    Cliente_Obra.Items.Insert(2, "Rafael Fariña");
         *    Cliente_Obra.Items.Insert(3, "Dante lopez");
         *
         * }*/

        private void OBRAS_Load(object sender, EventArgs e)
        {
            c   = new conexion();
            cmd = new SqlCommand("SELECT nombre_cliente FROM CLIENTE", c.regresaConexion());
            dr  = cmd.ExecuteReader();
            while (dr.Read())
            {
                Cliente_Obra.Items.Add(dr["nombre_cliente"].ToString());
            }
            Cliente_Obra.SelectedIndex = 0;
            c.cerrarConexion();
        }
Ejemplo n.º 4
0
 private void FALLAS_Load(object sender, EventArgs e)
 {
     c   = new conexion();
     cmd = new SqlCommand("SELECT nombre_maquina FROM MAQUINA", c.regresaConexion());
     dr  = cmd.ExecuteReader();
     while (dr.Read())
     {
         nombre_maquina.Items.Add(dr["nombre_maquina"].ToString());
     }
     nombre_maquina.SelectedIndex = 0;
     c.cerrarConexion();
 }
Ejemplo n.º 5
0
        private void boton_modificar_Click(object sender, EventArgs e)
        {
            try
            { //(id_Obra, nombre_obra, lugar_obra, fecha_inicio, fecha_termino, empresa_factura, estimacion, costo, residente, notas, cliente_obra) VALUES(" + id_obra.Text+",'" + 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());
                c   = new conexion();
                cmd = new SqlCommand("UPDATE MAQUINA SET nombre_maquina ='" + nombre_maquina.Text + "',marca='" + marca.Text + "',serie='" + serie.Text + "',origen='" + origen.Text + "',precio=" + precio.Text + ", encargado='" + encargado.SelectedItem + "', categoria='" + categoria.SelectedItem + "' WHERE id_Maquina = " + grid_maquina.CurrentRow.Cells[0].Value.ToString() + ";", c.regresaConexion());
                cmd.ExecuteNonQuery();
                c.cerrarConexion();
                MessageBox.Show("Maquina Modificada");
                id_Maquina.Text         = "";
                nombre_maquina.Text     = "";
                encargado.SelectedIndex = 0;
                marca.Text  = "";
                serie.Text  = "";
                origen.Text = "";
                precio.Text = "";
                MuestraDatosMaquinaria(grid_maquina);
            }

            catch (Exception ex)
            {
                MessageBox.Show("No se pudo Modificar" + ex.ToString());
                c.cerrarConexion();
            }
        }
Ejemplo n.º 6
0
 private void boton_eliminar_Click(object sender, EventArgs e)
 {
     try
     {
         c   = new conexion();
         cmd = new SqlCommand("DELETE FROM FALLAS WHERE id_Falla =" + id_falla.Text, c.regresaConexion());
         cmd.ExecuteNonQuery();
         c.cerrarConexion();
         MuestraDatos(grid_fallas);
         MessageBox.Show("Mantenimiento eliminado");
         nombre_maquina.SelectedIndex = 0;
         id_falla.Text    = "";
         fecha.Text       = DateTime.Now.ToString("dd-MM-yyyy");
         Descripcion.Text = "";
     }
     catch
     {
     }
 }
Ejemplo n.º 7
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();
            }
        }
Ejemplo n.º 8
0
        public void MuestraMaquinaCategoria()
        {
            c   = new conexion();
            cmd = new SqlCommand("SELECT DISTINCT nombre_maquina FROM MAQUINA WHERE categoria='" + categoria.SelectedItem + "' AND existe_maquina =" + 1 + "", c.regresaConexion());
            dr  = cmd.ExecuteReader();
            while (dr.Read())
            {
                combo_maquina.Items.Add(dr["nombre_maquina"].ToString());
            }



            c.cerrarConexion();
        }
Ejemplo n.º 9
0
 private void boton_eliminar_Click(object sender, EventArgs e)
 {
     try
     {
         c   = new conexion();
         cmd = new SqlCommand("DELETE FROM  HORAS_MAQUINA WHERE id_Horas_Maquina =" + grid_horas_maquinaria.CurrentRow.Cells[0].Value.ToString(), c.regresaConexion());
         cmd.ExecuteNonQuery();
         c.cerrarConexion();
         MuestraDatos(grid_horas_maquinaria);
         MessageBox.Show("Maquina Eliminada");
         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 = "";
     }
     catch
     {
     }
 }
Ejemplo n.º 10
0
        private void boton_modificar_Click(object sender, EventArgs e)
        {
            //bool servicio= false;
            int suma, sumatotales;

            try
            { //(id_Obra, nombre_obra, lugar_obra, fecha_inicio, fecha_termino, empresa_factura, estimacion, costo, residente, notas, cliente_obra) VALUES(" + id_obra.Text+",'" + 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());
              //if(servicio==false)
              //{
                suma = int.Parse(horas_trabajadas.Text) + int.Parse(horas_acumuladas.Text);
                horas_acumuladas.Text = suma.ToString();
                sumatotales           = int.Parse(horas_totales.Text) + int.Parse(horas_trabajadas.Text);
                horas_totales.Text    = sumatotales.ToString();
                c   = new conexion();
                cmd = new SqlCommand("UPDATE HORAS_MAQUINA SET maquina ='" + nombre_maquina.SelectedItem + "',horas_trabajadas='" + horas_trabajadas.Text + "',horas_acumuladas='" + horas_acumuladas.Text + "',horas_totales='" + horas_totales.Text + "',fecha_inicio='" + fecha_inicio.Text + "',fecha_finales='" + fecha_final.Text + "', servicio=" + 0 + ", notas ='" + notas.Text + "' WHERE id_Horas_Maquina=" + grid_horas_maquinaria.CurrentRow.Cells[0].Value.ToString(), c.regresaConexion());
                cmd.ExecuteNonQuery();
                c.cerrarConexion();
                MessageBox.Show("Reporte modificado");

                /*   //if(suma > 20)
                 * //{
                 *    //  MessageBox.Show("le toca servicio a la maqina");
                 *     cmd = new SqlCommand("UPDATE HORAS_MAQUINA SET maquina ='" + nombre_maquina.SelectedItem + "',horas_trabajadas='" + horas_trabajadas.Text + "',horas_acumuladas='" + horas_acumuladas.Text + "',horas_totales='" + horas_totales.Text + "',fecha_inicio='" + fecha_inicio.Text + "',fecha_finales='" + fecha_final.Text + "', servicio=" + 1 + " WHERE id_Horas_Maquina=" + grid_horas_maquinaria.CurrentRow.Cells[0].Value.ToString(), c.regresaConexion());
                 *     servicio = true;
                 * //}
                 * //else {
                 *          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
                 * // {*/
                // MessageBox.Show("le toca servicio a la maqina");
                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 Modificar" + ex.ToString());
                c.cerrarConexion();
            }
        }
Ejemplo n.º 11
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();
            }
        }
Ejemplo n.º 12
0
        public void MuestraHoras_Totales_Maquina()
        {
            c   = new conexion();
            cmd = new SqlCommand("SELECT horas_totales FROM MAQUINA WHERE nombre_maquina='" + nombre_maquina.SelectedItem.ToString() + "';", c.regresaConexion());
            dr  = cmd.ExecuteReader();
            while (dr.Read())
            {
                horas_totales.Text = (dr["horas_totales"].ToString());
            }


            c.cerrarConexion();
        }
Ejemplo n.º 13
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool existe = false;

            try
            {
                if (nombre_operador.Text == "" || telefono.Text == "")
                {
                    MessageBox.Show("Faltan campos por llenar");
                }
                else
                {
                    if (grid_operadores.RowCount == 0)
                    {
                        c   = new conexion();
                        cmd = new SqlCommand("INSERT INTO OPERADORES(nombre, telefono) VALUES('" + nombre_operador.Text + "', '" + telefono.Text + "')", c.regresaConexion());
                        cmd.ExecuteNonQuery();
                        c.cerrarConexion();
                        MessageBox.Show("Operador Insertado");
                        nombre_operador.Text = "";
                        telefono.Text        = "";
                    }
                    else
                    {
                        for (int i = 0; i < grid_operadores.RowCount; i++)
                        {
                            if (grid_operadores.Rows[i].Cells[1].Value.ToString() == nombre_operador.Text)
                            {
                                existe = true;
                            }
                        }
                        if (existe == false)
                        {
                            c   = new conexion();
                            cmd = new SqlCommand("INSERT INTO OPERADORES(nombre, telefono) VALUES('" + nombre_operador.Text + "', '" + telefono.Text + "')", c.regresaConexion());
                            cmd.ExecuteNonQuery();
                            c.cerrarConexion();
                            MessageBox.Show("Operador Insertado");
                            nombre_operador.Text = "";
                            telefono.Text        = "";
                        }
                        else
                        {
                            MessageBox.Show("YA ESTA DADO DE ALTA EL OPERADOR ");
                        }
                        nombre_operador.Text = "";
                        telefono.Text        = "";
                    }

                    MuestraDatos(grid_operadores);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("No se pudo insertar" + ex.ToString());
                c.cerrarConexion();
            }
        }
Ejemplo n.º 14
0
 private void boton_eliminar_Click(object sender, EventArgs e)
 {
     try
     {
         c   = new conexion();
         cmd = new SqlCommand("DELETE FROM OPERADORES WHERE id_operadores =" + grid_operadores.CurrentRow.Cells[0].Value.ToString(), c.regresaConexion());
         cmd.ExecuteNonQuery();
         c.cerrarConexion();
         MuestraDatos(grid_operadores);
         MessageBox.Show("Falla eliminado");
         nombre_operador.Text = "";
         telefono.Text        = "";
     }
     catch
     {
     }
 }
Ejemplo n.º 15
0
        private void boton_modificar_Click(object sender, EventArgs e)
        {
            try
            { //(id_Obra, nombre_obra, lugar_obra, fecha_inicio, fecha_termino, empresa_factura, estimacion, costo, residente, notas, cliente_obra) VALUES(" + id_obra.Text+",'" + 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());
                c   = new conexion();
                cmd = new SqlCommand("UPDATE OPERADORES SET nombre ='" + nombre_operador.Text + "',telefono='" + telefono.Text + "' WHERE id_operadores = " + grid_operadores.CurrentRow.Cells[0].Value.ToString() + ";", c.regresaConexion());
                cmd.ExecuteNonQuery();
                c.cerrarConexion();
                MessageBox.Show("OPERADOR MODIFICADO");
                nombre_operador.Text = "";
                telefono.Text        = "";
                MuestraDatos(grid_operadores);
            }

            catch (Exception ex)
            {
                MessageBox.Show("No se pudo Modificar" + ex.ToString());
                c.cerrarConexion();
            }
        }
Ejemplo n.º 16
0
        public void MuestraOrigen()
        {
            c   = new conexion();
            cmd = new SqlCommand("SELECT origen FROM MAQUINA WHERE nombre_maquina='" + combo_maquina.SelectedItem + "'", c.regresaConexion());
            dr  = cmd.ExecuteReader();
            while (dr.Read())
            {
                origen.Text = (dr["origen"].ToString());
            }


            c.cerrarConexion();
        }
Ejemplo n.º 17
0
        public void MuestraCliente()
        {
            c   = new conexion();
            cmd = new SqlCommand("SELECT cliente_obra FROM OBRA WHERE nombre_obra='" + combo_obra.SelectedItem + "'", c.regresaConexion());
            dr  = cmd.ExecuteReader();
            while (dr.Read())
            {
                cliente.Text = (dr["cliente_obra"].ToString());
            }


            c.cerrarConexion();
        }
Ejemplo n.º 18
0
 private void button1_Click(object sender, EventArgs e)
 {
     c   = new conexion();
     cmd = new SqlCommand("UPDATE  HORAS_MAQUINA SET horas_acumuladas =" + 0 + ", servicio=" + 0 + ";", c.regresaConexion());
     cmd.ExecuteNonQuery();
     c.cerrarConexion();
     MuestraDatos(grid_horas_maquinaria);
 }
Ejemplo n.º 19
0
        private void combo_maquina_SelectedValueChanged(object sender, EventArgs e)
        {
            // if(combo_maquina.SelectedIndex)
            // {
            c   = new conexion();
            cmd = new SqlCommand("SELECT id_Maquina FROM MAQUINA WHERE nombre_maquina='" + combo_maquina.SelectedItem + "'", c.regresaConexion());
            dr  = cmd.ExecuteReader();
            while (dr.Read())
            {
                id_Maquina = int.Parse(dr["id_Maquina"].ToString());
            }

            MuestraOrigen();

            // }
        }
Ejemplo n.º 20
0
 private void boton_eliminar_Click(object sender, EventArgs e)
 {
     try
     {
         c   = new conexion();
         cmd = new SqlCommand("DELETE FROM CLIENTE WHERE id_Cliente =" + id_cliente.Text, c.regresaConexion());
         cmd.ExecuteNonQuery();
         c.cerrarConexion();
         MuestraDatos(grid_clientes);
         MessageBox.Show("Cliente eliminado");
         id_cliente.Text     = "";
         nombre_cliente.Text = "";
         rfc.Text            = "";
         empresa.Text        = "";
         direccion.Text      = "";
         colonia.Text        = "";
         ciudad.Text         = "";
         codigo_postal.Text  = "";
         telefeno.Text       = "";
         correo.Text         = "";
     }
     catch
     {
     }
 }
Ejemplo n.º 21
0
 private void boton_modificar_Click(object sender, EventArgs e)
 {
     try
     { //(id_Obra, nombre_obra, lugar_obra, fecha_inicio, fecha_termino, empresa_factura, estimacion, costo, residente, notas, cliente_obra) VALUES(" + id_obra.Text+",'" + 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());
         c   = new conexion();
         cmd = new SqlCommand("UPDATE CLIENTE SET nombre_cliente ='" + nombre_cliente.Text + "',rfc='" + rfc.Text + "',empresa='" + empresa.Text + "',direccion='" + direccion.Text + "',colonia='" + colonia.Text + "',cuidad='" + ciudad.Text + "',codigo_postal=" + codigo_postal.Text + ",telefono=" + telefeno.Text + ",correo='" + correo.Text + "' WHERE id_Cliente=" + grid_clientes.CurrentRow.Cells[0].Value.ToString() + "; ", c.regresaConexion());
         cmd.ExecuteNonQuery();
         c.cerrarConexion();
         MessageBox.Show("Cliente modificado");
         id_cliente.Text     = "";
         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 Modificar" + ex.ToString());
         c.cerrarConexion();
     }
 }
Ejemplo n.º 22
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();
            }
        }
Ejemplo n.º 23
0
        private void boton_modifcar_Click(object sender, EventArgs e)
        {
            try
            { //(id_Obra, nombre_obra, lugar_obra, fecha_inicio, fecha_termino, empresa_factura, estimacion, costo, residente, notas, cliente_obra) VALUES(" + id_obra.Text+",'" + 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());
                c   = new conexion();
                cmd = new SqlCommand("UPDATE FALLAS SET maquina ='" + nombre_maquina.SelectedItem + "',sistema_afectado='" + sistema_afectado.SelectedItem + "',descripcion='" + Descripcion.Text + "',fecha='" + fecha.Text + "' WHERE id_Falla = " + grid_fallas.CurrentRow.Cells[0].Value.ToString() + ";", c.regresaConexion());
                cmd.ExecuteNonQuery();
                c.cerrarConexion();
                MessageBox.Show("Mantenimiento Modificado");
                nombre_maquina.SelectedIndex = 0;
                fecha.Text       = fecha.Text = DateTime.Now.ToString("dd-MM-yyyy");
                Descripcion.Text = "";
                MuestraDatos(grid_fallas);
            }

            catch (Exception ex)
            {
                MessageBox.Show("No se pudo Modificar" + ex.ToString());
                c.cerrarConexion();
            }
        }
Ejemplo n.º 24
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();
            }
        }
Ejemplo n.º 25
0
        public void MuestraDatos(DataGridView d)
        {
            foreach (string item in categoria.Items)
            {
                try
                {
                    c  = new conexion();
                    da = new SqlDataAdapter("select ma.serie, ma.nombre_maquina, ma.origen, s.fecha_salida, s.fecha_regreso, ma.encargado, s.nombre_operador, ma.existe_maquina, s.nombre_obra, ma.categoria from MAQUINA ma full join SALIDAS s on ma.id_Maquina = s.id_maquina", c.regresaConexion());
                    dt = new DataTable();
                    da.Fill(dt);
                    d.DataSource = dt;

                    c.cerrarConexion();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("No se pudo insertar" + ex.ToString());
                    c.cerrarConexion();
                }
            }
        }
Ejemplo n.º 26
0
        private void boton_modificar_Click(object sender, EventArgs e)
        {
            try
            { //(id_Obra, nombre_obra, lugar_obra, fecha_inicio, fecha_termino, empresa_factura, estimacion, costo, residente, notas, cliente_obra) VALUES(" + id_obra.Text+",'" + 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());
                c   = new conexion();
                cmd = new SqlCommand("UPDATE SALIDAS SET nombre_maquinaria ='" + grid_salida_maquinaria.CurrentRow.Cells[2].Value.ToString() + "',nombre_operador='" + combo_operador.SelectedItem + "',fecha_salida='" + fecha_salida.Text + "',fecha_regreso='" + fecha_regreso.Text + "',origen='" + origen.Text + "',nombre_obra='" + combo_obra.SelectedItem + "', cliente='" + cliente.Text + "', categoria='" + categoria.SelectedItem + "' WHERE id_salidas= " + grid_salida_maquinaria.CurrentRow.Cells[0].Value.ToString() + ";", c.regresaConexion());
                cmd.ExecuteNonQuery();
                c.cerrarConexion();
                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                c = new conexion();
                if (fecha_regreso.Text != grid_salida_maquinaria.CurrentRow.Cells[4].Value.ToString())
                {
                    cmd = new SqlCommand("UPDATE MAQUINA SET existe_maquina =" + 1 + " WHERE nombre_maquina = '" + grid_salida_maquinaria.CurrentRow.Cells[2].Value.ToString() + "';", c.regresaConexion());
                    cmd.ExecuteNonQuery();
                    c.cerrarConexion();
                }


                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                MessageBox.Show("salida Modificada");
                origen.Text        = "";
                fecha_salida.Text  = DateTime.Now.ToString("dd-MM-yyyy");
                fecha_regreso.Text = DateTime.Now.ToString("dd-MM-yyyy");

                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();
                combo_maquina.Items.Insert(0, "--------");
                while (dr.Read())
                {
                    combo_maquina.Items.Add(dr["nombre_maquina"].ToString());
                }
                combo_maquina.SelectedIndex = 0;
                c.cerrarConexion();
            }

            catch (Exception ex)
            {
                MessageBox.Show("No se pudo Modificar" + ex.ToString());
                c.cerrarConexion();
            }
        }
Ejemplo n.º 27
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();
            }
        }
Ejemplo n.º 28
0
 private void boton_Eliminar_Click(object sender, EventArgs e)
 {
     try
     {
         c   = new conexion();
         cmd = new SqlCommand("DELETE FROM SALIDAS WHERE id_salidas =" + grid_salida_maquinaria.CurrentRow.Cells[0].Value.ToString(), c.regresaConexion());
         cmd.ExecuteNonQuery();
         c.cerrarConexion();
         MuestraDatos(grid_salida_maquinaria);
         MessageBox.Show("Maquina Eliminada");
         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;
     }
     catch
     {
     }
 }
Ejemplo n.º 29
0
 private void boton_eliminar_Click(object sender, EventArgs e)
 {
     try
     {
         c   = new conexion();
         cmd = new SqlCommand("DELETE FROM SALIDAS WHERE id_maquina =" + id_Maquina.Text, c.regresaConexion());
         cmd.ExecuteNonQuery();
         c.cerrarConexion();
         c   = new conexion();
         cmd = new SqlCommand("DELETE FROM MAQUINA WHERE id_Maquina =" + id_Maquina.Text, c.regresaConexion());
         cmd.ExecuteNonQuery();
         c.cerrarConexion();
         MuestraDatosMaquinaria(grid_maquina);
         MessageBox.Show("Maquina Eliminada");
         id_Maquina.Text         = "";
         nombre_maquina.Text     = "";
         encargado.SelectedIndex = 0;
         marca.Text  = "";
         serie.Text  = "";
         origen.Text = "";
         precio.Text = "";
     }
     catch (Exception ex)
     {
         MessageBox.Show("No se pudo Modificar" + ex.ToString());
         c.cerrarConexion();
     }
 }
Ejemplo n.º 30
0
 private void Modificar_Obras_Click(object sender, EventArgs e)
 {
     try
     { //(id_Obra, nombre_obra, lugar_obra, fecha_inicio, fecha_termino, empresa_factura, estimacion, costo, residente, notas, cliente_obra) VALUES(" + id_obra.Text+",'" + 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());
         c   = new conexion();
         cmd = new SqlCommand("UPDATE OBRA SET nombre_obra ='" + Nombre_Obra.Text + "',lugar_obra='" + Lugar_Obra.Text + "',fecha_inicio='" + Fecha_Inicio.Text + "',fecha_termino='" + Fecha_Termino.Text + "',empresa_factura='" + Empresa_Facturar.SelectedItem + "',estimacion=" + Estimacion_Obra.Text + ",costo=" + Costo_Obra.Text + ",residente='" + Residente.SelectedItem + "',notas='" + Notas.Text + "',cliente_obra='" + Cliente_Obra.SelectedItem + "' WHERE id_Obra=" + id_obra.Text, c.regresaConexion());
         cmd.ExecuteNonQuery();
         c.cerrarConexion();
         MessageBox.Show("Reporte modificado");
         id_obra.Text         = "";
         Nombre_Obra.Text     = "";
         Lugar_Obra.Text      = "";
         Estimacion_Obra.Text = "";
         Costo_Obra.Text      = "";
         Notas.Text           = "";
         MuestraDatos(Grid_Obras);
     }
     catch (Exception ex)
     {
         MessageBox.Show("No se pudo Modificar" + ex.ToString());
         c.cerrarConexion();
     }
 }