예제 #1
0
        private void Guardar_Final()
        {
            Variables_Globales.id = textBox15.Text;

            String  SQL = "SELECT * from doc_fin where ID = '" + Variables_Globales.id + "' ORDER BY ID ";
            DataSet ds  = Conexiones.Retorna_Datos(SQL);

            string ID   = "";
            string LF   = "";
            string CF   = "";
            string AREC = "";
            string CEE  = "";

            ID   = Convert.ToString(textBox15.Text);
            LF   = checkBox26.Checked.ToString();
            CF   = checkBox27.Checked.ToString();
            AREC = checkBox28.Checked.ToString();
            CEE  = checkBox29.Checked.ToString();

            if (ds.Tables[0].Rows.Count > 0)
            {
                Conexiones.Ejecuta_Consulta("UPDATE doc_fin set LF = '" + LF + "', CF = '" + CF + "', AREC = '" + AREC + "', CEE = '" + CEE + "' where ID = '" + Variables_Globales.id + "'");
            }
            else
            {
                Conexiones.Ejecuta_Consulta("INSERT INTO doc_fin (ID, LF, CF, AREC, CEE) " +
                                            "VALUES ('" + ID + "', '" + LF + "', '" + CF + "', '" + AREC + "','" + CEE + "')");
            }
        }
예제 #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            string ID;
            string ID_obra;
            string Fecha       = "";
            string Tipo        = "";
            string Descripcion = "";

            ID          = textBox1.Text;
            ID_obra     = Convert.ToString(Variables_Globales.id);
            Fecha       = Convert.ToString(dateTimePicker1.Text);
            Tipo        = Convert.ToString(checkedListBox1.Text);
            Descripcion = textBox4.Text;

            if (Fecha != "" && Tipo != "" && Descripcion != "")
            {
                Conexiones.Ejecuta_Consulta("INSERT INTO planificacion (ID, ID_obra, Fecha, Tipo, Descripcion) " +
                                            "VALUES ('" + ID + "', '" + ID_obra + "', '" + Fecha + "', '" + Tipo + "', '" + Descripcion + "')");

                MessageBox.Show("Registro guardado correctamente.");

                this.Close();
            }
            else
            {
                MessageBox.Show("Debes insertar fecha, tipo y/o descripción.");
                return;
            }
        }
예제 #3
0
        private void dataGridView3_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            try
            {
                if (senderGrid.Columns[e.ColumnIndex] is DataGridViewImageColumn && e.RowIndex >= 0)
                {
                    NumFila = e.RowIndex;

                    //dataGridView3.CurrentCell = dataGridView1[0, NumFila];
                    string ID_Eliminar = Convert.ToString(dataGridView3.Rows[NumFila].Cells[4].Value);

                    //Eliminar
                    if (e.ColumnIndex == 5)
                    {
                        DialogResult resp = MessageBox.Show("¿Seguro que deseas eliminar al trabajador de esta obra?", "¡ALERTA!", MessageBoxButtons.YesNo);

                        if (resp == DialogResult.Yes)
                        {
                            string SQL = "UPDATE trabajadores_obra SET Libre = 'SI', Obra_asignada = '00' where CODI = '" + ID_Eliminar + "'";
                            Conexiones.Ejecuta_Consulta("UPDATE trabajadores_obra SET Libre = 'SI', Obra_asignada = '00' where CODI = '" + ID_Eliminar + "'");

                            MessageBox.Show("El trabajador ha quedado LIBRE.");

                            Cargar_Grid_Trabajadores();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error eliminando el registro indicado.");
            }
        }
예제 #4
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            try
            {
                if (senderGrid.Columns[e.ColumnIndex] is DataGridViewImageColumn && e.RowIndex >= 0)
                {
                    NumFila = e.RowIndex;

                    dataGridView1.CurrentCell = dataGridView1[0, NumFila];
                    string Trabajador = Convert.ToString(dataGridView1.Rows[NumFila].Cells[0].Value);
                    //Seleccionar
                    if (e.ColumnIndex == 3)
                    {
                        DialogResult resp = MessageBox.Show("¿Quieres añadir al trabajador a la obra " + Variables_Globales.id + "?", "¡ALERTA!", MessageBoxButtons.YesNo);

                        if (resp == DialogResult.Yes)
                        {
                            string SQL = "UPDATE trabajadores_obra SET Libre = 'NO', Obra_asignada = '" + Variables_Globales.id + "' WHERE CODI =  '" + Trabajador + "'";
                            Conexiones.Ejecuta_Consulta("UPDATE trabajadores_obra SET Libre = 'NO', Obra_asignada = '" + Variables_Globales.id + "' WHERE CODI =  '" + Trabajador + "'");

                            MessageBox.Show("Añadido correctamente.");
                            this.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error modificando el registro indicado.");
            }
        }
예제 #5
0
        private void Guardar_Inicio()
        {
            Variables_Globales.id = textBox15.Text;

            String  SQL = "SELECT * from doc_inicio where ID = '" + Variables_Globales.id + "' ORDER BY ID ";
            DataSet ds  = Conexiones.Retorna_Datos(SQL);

            string ID  = "";
            string CF  = "";
            string PC  = "";
            string EG  = "";
            string LO  = "";
            string AP  = "";
            string NP  = "";
            string LD  = "";
            string PSS = "";
            string LC  = "";
            string AC  = "";
            string LI  = "";
            string PGR = "";
            string LS  = "";
            string PG  = "";
            string AR  = "";

            ID  = Convert.ToString(textBox15.Text);
            CF  = checkBox1.Checked.ToString();
            PC  = checkBox2.Checked.ToString();
            EG  = checkBox3.Checked.ToString();
            LO  = checkBox4.Checked.ToString();
            AP  = checkBox5.Checked.ToString();
            NP  = checkBox6.Checked.ToString();
            LD  = checkBox7.Checked.ToString();
            PSS = checkBox8.Checked.ToString();
            LC  = checkBox9.Checked.ToString();
            AC  = checkBox10.Checked.ToString();
            LI  = checkBox11.Checked.ToString();
            PGR = checkBox12.Checked.ToString();
            LS  = checkBox13.Checked.ToString();
            PG  = checkBox14.Checked.ToString();
            AR  = checkBox15.Checked.ToString();

            string SQL2 = "INSERT INTO doc_inicio (ID, CF, PC, EG, LO, AP, NP, LD, PSS, LC, AC, LI, PGR, LS, PG, AR) " +
                          "VALUES ('" + ID + "', '" + CF + "', '" + PC + "', '" + EG + "','" + LO + "', '" + AP + "', '" + NP + "', '" + LD + "', '" + PSS + "', '" + LC + "', '" + AC + "', '" + LI + "','" + PGR + "', '" + LS + "', '" + PG + "', '" + AR + "')";

            if (ds.Tables[0].Rows.Count > 0)
            {
                Conexiones.Ejecuta_Consulta("UPDATE doc_inicio set CF = '" + CF + "', PC = '" + PC + "', EG = '" + EG + "', LO = '" + LO + "'," +
                                            " AP = '" + AP + "', NP = '" + NP + "', LD = '" + LD + "', PSS = '" + PSS + "', LC = '" + LC + "', AC = '" + AC + "', " +
                                            "LI = '" + LI + "', PGR = '" + PGR + "', LS = '" + LS + "', PG = '" + PG + "', AR =  '" + AR + "' where ID = '" + Variables_Globales.id + "'");
            }
            else
            {
                Conexiones.Ejecuta_Consulta("INSERT INTO doc_inicio (ID, CF, PC, EG, LO, AP, NP, LD, PSS, LC, AC, LI, PGR, LS, PG, AR) " +
                                            "VALUES ('" + ID + "', '" + CF + "', '" + PC + "', '" + EG + "','" + LO + "', '" + AP + "', '" + NP + "', '" + LD + "', '" + PSS + "', '" + LC + "', '" + AC + "', '" + LI + "','" + PGR + "', '" + LS + "', '" + PG + "', '" + AR + "')");
            }
            //Conexiones.Ejecuta_Consulta("INSERT INTO doc_inicio (ID, CF, PC, EG, LO, AP, NP, LD, PSS, LC, AC, LI, PGR, LS, PG, AR) " +
            //    "VALUES ('" + ID + "', '" + CF + "', '" + PC + "', '" + EG + "','" + LO + "', '" + AP + "', '" + NP + "', '" + LD + "', '" + PSS + "', '" + LC + "', '" + AC + "', '" + LI + "','" + PGR + "', '" + LS + "', '" + PG + "', '" + AR + "')");
        }
예제 #6
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            try
            {
                if (senderGrid.Columns[e.ColumnIndex] is DataGridViewImageColumn && e.RowIndex >= 0)
                {
                    NumFila = e.RowIndex;

                    dataGridView1.CurrentCell = dataGridView1[0, NumFila];
                    string ID_Eliminar = Convert.ToString(dataGridView1.Rows[NumFila].Cells[0].Value);
                    //Eliminar
                    if (e.ColumnIndex == 18)
                    {
                        DialogResult resp = MessageBox.Show("¿Seguro que deseas eliminar el registro?", "¡ALERTA!", MessageBoxButtons.YesNo);

                        if (resp == DialogResult.Yes)
                        {
                            string SQL = "DELETE FROM trabajadores_obra where CODI = '" + ID_Eliminar + "'";
                            Conexiones.Ejecuta_Consulta("DELETE FROM trabajadores_obra where CODI = '" + ID_Eliminar + "'");

                            MessageBox.Show("Eliminado correctamente.");
                            Cargar_Grid_Trabajadores();
                            //this.Close();
                        }
                    }

                    //Editar
                    if (e.ColumnIndex == 17)
                    {
                        string codigo_empleado = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();

                        Variables_Globales.codigo_empleado = codigo_empleado;
                        Variables_Globales.Form16_Desde    = "FORM10";

                        Form16 frm = new Form16();
                        frm.ShowDialog();
                        Cargar_Grid_Trabajadores();

                        //Variables_Globales.id = "";
                        //Variables_Globales.expediente = "";
                        //Variables_Globales.titulo = "";
                        Variables_Globales.Form16_Desde = "";
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error eliminando el registro indicado.");
            }
        }
예제 #7
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (Convert.ToString(maskedTextBox1) != "" && Convert.ToString(maskedTextBox2) != "")
            {
                Calcular_Total_Horas();
            }
            else
            {
                MessageBox.Show("Debes insertar la hora de entrada y la de salida.");
            }

            string COD_Horas  = "";
            string Fecha      = "";
            string Obra       = "";
            string H_entrada  = "";
            string H_salida   = "";
            string Total      = "";
            string Expediente = "";
            string Titulo     = "";

            COD_Horas  = textBox1.Text;
            Fecha      = Convert.ToString(dateTimePicker1.Text);
            Obra       = textBox_ID.Text;
            H_entrada  = maskedTextBox1.Text;
            H_salida   = maskedTextBox2.Text;
            Total      = textBox4.Text;
            Expediente = Convert.ToString(textBox_Exp.Text);
            Titulo     = Convert.ToString(textBox_Tit.Text);

            if (Convert.ToString(COD_Horas) != "" && Convert.ToString(Obra) != "" && Convert.ToString(Total) != "")
            {
                string SQL = "INSERT INTO horas (COD_Horas, Fecha, Obra, Expediente, Titulo, H_entrada, H_salida, Total) " +
                             "VALUES ('" + COD_Horas + "', '" + Fecha + "', '" + Obra + "', '" + Expediente + "', '" + Titulo + "', '" + H_entrada + "', '" + H_salida + "', '" + Total + "')";
                Conexiones.Ejecuta_Consulta("INSERT INTO horas (COD_Horas, Fecha, Obra, Expediente, Titulo, H_entrada, H_salida, Total) " +
                                            "VALUES ('" + COD_Horas + "', '" + Fecha + "', '" + Obra + "', '" + Expediente + "', '" + Titulo + "', '" + H_entrada + "', '" + H_salida + "', '" + Total + "')");

                MessageBox.Show("Registro guardado correctamente.");

                this.Close();
            }
            else
            {
                MessageBox.Show("Debes seleccionar la obra e insertar las horas de entrada y salida.");
                return;
            }
        }
예제 #8
0
        private void Guardar_Durante()
        {
            Variables_Globales.id = textBox15.Text;

            String  SQL = "SELECT * from doc_durante where ID = '" + Variables_Globales.id + "' ORDER BY ID ";
            DataSet ds  = Conexiones.Retorna_Datos(SQL);

            string ID    = "";
            string DC    = "";
            string DE    = "";
            string DF    = "";
            string DP    = "";
            string DCARP = "";
            string DA    = "";
            string DI    = "";
            string DINS  = "";
            string DR    = "";
            string DEQ   = "";

            ID    = Convert.ToString(textBox15.Text);
            DC    = checkBox16.Checked.ToString();
            DE    = checkBox17.Checked.ToString();
            DF    = checkBox18.Checked.ToString();
            DP    = checkBox19.Checked.ToString();
            DCARP = checkBox20.Checked.ToString();
            DA    = checkBox21.Checked.ToString();
            DI    = checkBox22.Checked.ToString();
            DINS  = checkBox23.Checked.ToString();
            DR    = checkBox24.Checked.ToString();
            DEQ   = checkBox25.Checked.ToString();

            if (ds.Tables[0].Rows.Count > 0)
            {
                Conexiones.Ejecuta_Consulta("UPDATE doc_durante set DC = '" + DC + "', DE = '" + DE + "', DF = '" + DF + "', DP = '" + DP + "'," +
                                            " DCARP = '" + DCARP + "', DA = '" + DA + "', DI = '" + DI + "', DINS = '" + DINS + "', DR = '" + DR + "', DEQ = '" + DEQ + "'" +
                                            " where ID = '" + Variables_Globales.id + "'");
            }
            else
            {
                Conexiones.Ejecuta_Consulta("INSERT INTO doc_durante (ID, DC, DE, DF, DP, DCARP, DA, DI, DINS, DR, DEQ) " +
                                            "VALUES ('" + ID + "', '" + DC + "', '" + DE + "', '" + DF + "','" + DP + "', '" + DCARP + "', '" + DA + "', '" + DI + "', '" + DINS + "', '" + DR + "', '" + DEQ + "')");
            }
        }
예제 #9
0
        private void button4_Click(object sender, EventArgs e)
        {
            string CODIGO;
            string N_factura;
            string Fecha    = "";
            string Empresa  = "";
            string Producto = "";
            string Importe  = "";
            string ID_Obra  = "";


            CODIGO    = textBox1.Text;
            N_factura = textBox2.Text;
            Fecha     = Convert.ToString(dateTimePicker1.Text);
            Empresa   = textBox3.Text;
            Producto  = textBox4.Text;
            Importe   = textBox6.Text;
            ID_Obra   = Variables_Globales.id;


            if (Convert.ToString(CODIGO) != "" && ID_Obra != "" && Convert.ToString(N_factura) != "" && Importe != "")
            {
                string SQL = "INSERT INTO facturas (CODIGO, ID_Obra, N_factura, Fecha, Empresa, Producto, Importe) " +
                             "VALUES ('" + CODIGO + "', '" + ID_Obra + "', '" + N_factura + "', '" + Fecha + "', '" + Empresa + "', '" + Producto + "', '" + Importe + "')";

                Conexiones.Ejecuta_Consulta("INSERT INTO facturas (CODIGO, ID_Obra, N_factura, Fecha, Empresa, Producto, Importe) " +
                                            "VALUES ('" + CODIGO + "', '" + ID_Obra + "', '" + N_factura + "', '" + Fecha + "', '" + Empresa + "', '" + Producto + "', '" + Importe + "')");

                MessageBox.Show("Registro guardado correctamente.");

                this.Close();
            }
            else
            {
                MessageBox.Show("Debes insertar nº de factura e importe.");
                return;
            }
        }
예제 #10
0
        private void button4_Click(object sender, EventArgs e)
        {
            string COD_GASTOS = "";
            string N_factura  = "";
            string Fecha      = "";
            string Tipo       = "";
            string Obra       = "";
            string Expediente = "";
            string Titulo     = "";
            string Importe    = "";

            COD_GASTOS = textBox1.Text;
            N_factura  = Convert.ToString(textBox2.Text);
            Fecha      = Convert.ToString(dateTimePicker1.Text);
            Tipo       = Convert.ToString(listBox1.Text);
            Importe    = textBox3.Text;
            Obra       = textBox_ID.Text;
            Expediente = Convert.ToString(textBox_Exp.Text);
            Titulo     = Convert.ToString(textBox_Tit.Text);

            if (Convert.ToString(COD_GASTOS) != "" && Convert.ToString(Obra) != "" && Convert.ToString(N_factura) != "" && Convert.ToString(Fecha) != "" && Convert.ToString(Tipo) != "" && Convert.ToString(Importe) != "")
            {
                string SQL = "INSERT INTO gastos (COD_GASTOS, N_factura, Fecha, Tipo, Obra, Expediente, Titulo, Importe) " +
                             "VALUES ('" + COD_GASTOS + "', '" + N_factura + "', '" + Fecha + "', '" + Tipo + "', '" + Obra + "', '" + Expediente + "', '" + Titulo + "', '" + Importe + "')";
                Conexiones.Ejecuta_Consulta("INSERT INTO gastos (COD_GASTOS, N_factura, Fecha, Tipo, Obra, Expediente, Titulo, Importe) " +
                                            "VALUES ('" + COD_GASTOS + "', '" + N_factura + "', '" + Fecha + "', '" + Tipo + "', '" + Obra + "', '" + Expediente + "', '" + Titulo + "', '" + Importe + "')");

                MessageBox.Show("Registro guardado correctamente.");

                this.Close();
            }
            else
            {
                MessageBox.Show("Debes insertar nº de factura, fecha, tipo de gasto e importe.");
                return;
            }
        }
예제 #11
0
        private void button4_Click(object sender, EventArgs e)
        {
            string CODI        = "";
            string Nombre      = "";
            string Apellidos   = "";
            string DNI         = "";
            string Telefono    = "";
            string Nivel       = "";
            string Contrato    = "";
            string EPIs        = "";
            string Maquinaria  = "";
            string Apto        = "";
            string PRL         = "";
            string Albañileria = "";
            string Hormigon    = "";
            string Grua        = "";
            string Plataformas = "";
            string Libre       = "";
            string Obra        = "";

            CODI        = textBox1.Text;
            Nombre      = textBox2.Text;
            Apellidos   = textBox5.Text;
            DNI         = textBox3.Text;
            Telefono    = textBox4.Text;
            Nivel       = listBox1.Text;
            Contrato    = checkBox1.Checked.ToString();
            EPIs        = checkBox2.Checked.ToString();
            Maquinaria  = checkBox3.Checked.ToString();
            Apto        = checkBox9.Checked.ToString();
            PRL         = checkBox4.Checked.ToString();
            Albañileria = checkBox5.Checked.ToString();
            Hormigon    = checkBox6.Checked.ToString();
            Grua        = checkBox7.Checked.ToString();
            Plataformas = checkBox8.Checked.ToString();
            Libre       = listBox2.Text;

            if (listBox2.Text == "SI")
            {
                Obra = "00";
            }
            else if (listBox2.Text == "NO")
            {
                Obra = textBox_ID.Text;
            }

            if (Libre == "NO")
            {
                if (listBox3.SelectedIndex == 0)
                {
                    MessageBox.Show("Si el trabajador NO está libre, debes asignarlo a una obra.");
                }
                else
                {
                    if (Convert.ToString(CODI) != "" && Nombre != "" && DNI != "" && Telefono != "" && Libre != "")
                    {
                        string  SQL = "Select * from trabajadores_obra where CODI = '" + CODI + "'";
                        DataSet ds  = Conexiones.Retorna_Datos(SQL);

                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            Conexiones.Ejecuta_Consulta("UPDATE trabajadores_obra set Telefono = '" + Telefono + "', Nivel = '" + Nivel + "', Contrato = '" + Contrato + "', EPIs = '" + EPIs + "' , Maquinaria = '" + Maquinaria + "', Apto = '" + Apto + "'," +
                                                        " PRL = '" + PRL + "', Albañileria = '" + Albañileria + "', Hormigon = '" + Hormigon + "' , Grua = '" + Grua + "' , Plataformas = '" + Plataformas + "' , Libre = '" + Libre + "' , Obra_asignada = '" + Obra + "'" +
                                                        " where CODI = '" + CODI + "'");

                            MessageBox.Show("Registro modificado correctamente.");

                            this.Close();
                        }
                        else
                        {
                            Conexiones.Ejecuta_Consulta("INSERT INTO trabajadores_obra (CODI, Nombre, Apellidos, DNI, Telefono, Nivel, Contrato, EPIs, Maquinaria, Apto, PRL, Albañileria, Hormigon, Grua, Plataformas, Libre, Obra_asignada) " +
                                                        "VALUES ('" + CODI + "', '" + Nombre + "', '" + Apellidos + "', '" + DNI + "','" + Telefono + "', '" + Nivel + "', '" + Contrato + "', '" + EPIs + "', '" + Maquinaria + "', '" + Apto + "', '" + PRL + "', '" + Albañileria + "','" + Hormigon + "', '" + Grua + "', '" + Plataformas + "', '" + Libre + "', '" + Obra + "')");

                            MessageBox.Show("Registro guardado correctamente.");

                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Debes insertar nombre, DNI, teléfono y si el trabajador no está asignado a una obra (Libre).");
                        return;
                    }
                }
            }
            else
            {
                if (Convert.ToString(CODI) != "" && Nombre != "" && DNI != "" && Telefono != "" && Libre != "")
                {
                    Conexiones.Ejecuta_Consulta("INSERT INTO trabajadores_obra (CODI, Nombre, Apellidos, DNI, Telefono, Nivel, Contrato, EPIs, Maquinaria, Apto, PRL, Albañileria, Hormigon, Grua, Plataformas, Libre, Obra_asignada) " +
                                                "VALUES ('" + CODI + "', '" + Nombre + "', '" + Apellidos + "', '" + DNI + "','" + Telefono + "', '" + Nivel + "', '" + Contrato + "', '" + EPIs + "', '" + Maquinaria + "', '" + Apto + "', '" + PRL + "', '" + Albañileria + "','" + Hormigon + "', '" + Grua + "', '" + Plataformas + "', '" + Libre + "', '" + Obra + "')");

                    MessageBox.Show("Registro guardado correctamente.");

                    this.Close();
                }
                else
                {
                    MessageBox.Show("Debes insertar nombre, DNI, teléfono y si el trabajador no está asignado a una obra (Libre).");
                    return;
                }
            }
        }
예제 #12
0
        private void button2_Click(object sender, EventArgs e)
        {
            string ID         = "";
            string Expediente = "";
            string Titulo     = "";
            string Direccion  = "";
            string Poblacion  = "";
            string CP;
            string Estado       = "";
            string Importe      = "";
            string IVA          = "";
            string Total        = "";
            string Promotor     = "";
            string Fecha_inicio = "";
            string Fecha_fin    = "";
            string Duracion     = "";

            ID           = textBox1.Text;
            Expediente   = textBox2.Text;
            Titulo       = textBox3.Text;
            Direccion    = textBox4.Text;
            Poblacion    = textBox5.Text;
            CP           = textBox6.Text;
            Estado       = listBox1.Text;
            Importe      = textBox8.Text;
            IVA          = listBox2.Text;
            Total        = textBox10.Text;
            Promotor     = textBox11.Text;
            Fecha_inicio = dateTimePicker1.Text;
            Fecha_fin    = dateTimePicker2.Text;
            Duracion     = textBox14.Text;

            if (textBox2.Text != "" && textBox3.Text != "" && listBox2.Text != "" && listBox1.Text != "")
            {
                string  SQL = "Select * from obras where ID = '" + ID + "'";
                DataSet ds  = Conexiones.Retorna_Datos(SQL);


                if (ds.Tables[0].Rows.Count > 0)
                {
                    string SQL2 = "UPDATE obras  set Estado = '" + Estado + "', Importe = '" + Importe + "', IVA = '" + IVA + "', Total = '" + Total + "' ," +
                                  "Fecha_inicio = '" + Fecha_inicio + "' , Fecha_fin = '" + Fecha_fin + "' , Duracion = '" + Duracion + "' where ID = '" + ID + "'";

                    Conexiones.Ejecuta_Consulta("UPDATE obras set Estado = '" + Estado + "', Importe = '" + Importe + "', IVA = '" + IVA + "', Total = '" + Total + "' ," +
                                                "Fecha_inicio = '" + Fecha_inicio + "' , Fecha_fin = '" + Fecha_fin + "' , Duracion = '" + Duracion + "' where ID = '" + ID + "'");

                    textBox15.Text = ID;
                    textBox16.Text = Expediente;
                    textBox17.Text = Titulo;

                    MessageBox.Show("Registro modificado correctamente.");

                    tabControl1.SelectedIndex = 1;
                }
                else
                {
                    string SQL2 = "INSERT INTO obras (ID, Expediente, Titulo, Direccion, Poblacion, CP, Estado, Importe, IVA, Total, Promotor, Fecha_inicio, Fecha_fin, Duracion) " +
                                  "VALUES ('" + ID + "', '" + Expediente + "', '" + Titulo + "', '" + Direccion + "', '" + Poblacion + "', '" + CP + "', '" + Estado + "', '" + Importe + "', '" + IVA + "', '" + Total + "', '" + Promotor + "', '" + Fecha_inicio + "', '" + Fecha_fin + "', '" + Duracion + "')";

                    Conexiones.Ejecuta_Consulta("INSERT INTO obras (ID, Expediente, Titulo, Direccion, Poblacion, CP, Estado, Importe, IVA, Total, Promotor, Fecha_inicio, Fecha_fin, Duracion) " +
                                                "VALUES ('" + ID + "', '" + Expediente + "', '" + Titulo + "', '" + Direccion + "', '" + Poblacion + "', '" + CP + "', '" + Estado + "', '" + Importe + "', '" + IVA + "', '" + Total + "', '" + Promotor + "', '" + Fecha_inicio + "', '" + Fecha_fin + "', '" + Duracion + "')");

                    textBox15.Text = ID;
                    textBox16.Text = Expediente;
                    textBox17.Text = Titulo;

                    MessageBox.Show("Registro guardado correctamente.");

                    tabControl1.SelectedIndex = 1;
                }
            }
            else
            {
                if (textBox2.Text == "")
                {
                    MessageBox.Show("Es obligatorio completar el EXPEDIENTE.");
                }

                if (textBox3.Text == "")
                {
                    MessageBox.Show("Es obligatorio completar el TÍTULO.");
                }

                if (listBox1.Text == "")
                {
                    MessageBox.Show("Es obligatorio completar el ESTADO.");
                }

                if (listBox2.Text == "")
                {
                    MessageBox.Show("Es obligatorio completar el IVA.");
                }
            }
        }