private void button_guardar_Click(object sender, EventArgs e)
 {
     if (filas_eliminadas.Count > 0)
     {
         eliminar_filas();
     }
     if (comprobarImporte())
     {
         for (int a = 0; a < dataGridView_reparto.Rows.Count; a++)
         {
             if (dataGridView_reparto.Rows[a].Cells[3].Value != null && dataGridView_reparto.Rows[a].Cells[0].Value != null)
             {
                 actualizar_filasReparto(dataGridView_reparto.Rows[a].Cells[0].Value.ToString(), dataGridView_reparto.Rows[a].Cells[4].Value.ToString(), dataGridView_reparto.Rows[a].Cells[2].Value.ToString(), dataGridView_reparto.Rows[a].Cells[3].Value.ToString());
             }
             else if (dataGridView_reparto.Rows[a].Cells[3].Value != null && dataGridView_reparto.Rows[a].Cells[0].Value == null)
             {
                 insertar_filasReparto(dataGridView_reparto.Rows[a].Cells[4].Value.ToString(), dataGridView_reparto.Rows[a].Cells[2].Value.ToString(), dataGridView_reparto.Rows[a].Cells[3].Value.ToString());
             }
         }
         if (vengoDePantallaVer)
         {
             form_anterior.cargarOperacion(id_operacion_cargado);
         }
         else
         {
             FormOperacionesVencimientos nueva = new FormOperacionesVencimientos(id_comunidad_cargado, id_operacion_cargado, textBox_importe_actual.Text);
             nueva.Show();
         }
         guardada = "si";
         this.Close();
     }
     else
     {
         MessageBox.Show("Revise los importes, el total es : " + textBox_importe_actual.Text + " y debe ser " + textBox_importe_op.Text);
     }
 }
Esempio n. 2
0
        private void button_add_vencimiento_Click(object sender, EventArgs e)
        {
            FormOperacionesVencimientos nueva = new FormOperacionesVencimientos(this, id_comunidad_cargado, id_operacion_cargado, textBox_importe.Text, true);

            nueva.Show();
        }
Esempio n. 3
0
        private void button_crear_Click(object sender, EventArgs e)
        {
            //CREAMOS CABECERA
            String sqlInsertCabe = "";
            String fechaOp;

            if (id_op_bbdd != "")
            {
                try
                {
                    fechaOp = (Convert.ToDateTime(maskedTextBox_nueva_fecha.Text)).ToString("yyyy-MM-dd");
                }
                catch (Exception)
                {
                    MessageBox.Show("Comprueba la fecha de la operación.");
                    return;
                }
                String fechaAhora    = (Convert.ToDateTime(DateTime.Now)).ToString("yyyy-MM-dd hh:mm:ss");
                String sqlSelectCabe = "SELECT IdComunidad, IdEntidad, IdSubCuenta, IdTipoReparto, IdRetencion, BaseRet, Retencion, Notas, IdCuota, IdDivision, IdExpte FROM com_operaciones WHERE (((com_operaciones.IdOp) = " + id_op_bbdd + "));";

                DataTable cabecera = Persistencia.SentenciasSQL.select(sqlSelectCabe);

                id_comunidad_cargado = cabecera.Rows[0][0].ToString();

                if (cabecera.Rows[0][3].ToString() == "1")
                {
                    if (cabecera.Rows[0][10].ToString() == "")
                    {
                        sqlInsertCabe = "INSERT INTO com_operaciones (IdComunidad, IdEntidad, IdSubCuenta, IdTipoReparto, Fecha, Documento, Descripcion,IdRetencion, BaseRet, Retencion, Notas, IdEstado, ImpOp, ImpOpPte, NumMov, Guardada, IdURD, FAct) VALUES (" + cabecera.Rows[0][0].ToString() + "," + cabecera.Rows[0][1].ToString() + "," + cabecera.Rows[0][2].ToString() + "," + cabecera.Rows[0][3].ToString() + ",'" + fechaOp + "','" + textBox_documento.Text + "','" + textBox_nuevo_nombre.Text + "'," + cabecera.Rows[0][4].ToString() + "," + cabecera.Rows[0][5].ToString().Replace(',', '.') + "," + cabecera.Rows[0][6].ToString().Replace(',', '.') + ",'" + cabecera.Rows[0][7].ToString() + "',1," + textBox_importe.Text.Replace(',', '.') + "," + textBox_importe.Text.Replace(',', '.') + ",0,'No'," + Login.getId() + ",'" + fechaAhora + "')";
                    }
                    else
                    {
                        sqlInsertCabe = "INSERT INTO com_operaciones (IdComunidad, IdEntidad, IdSubCuenta, IdTipoReparto, Fecha, Documento, Descripcion,IdRetencion, BaseRet, Retencion, Notas, IdEstado, IdExpte, ImpOp, ImpOpPte, NumMov, Guardada, IdURD, FAct) VALUES (" + cabecera.Rows[0][0].ToString() + "," + cabecera.Rows[0][1].ToString() + "," + cabecera.Rows[0][2].ToString() + "," + cabecera.Rows[0][3].ToString() + ",'" + fechaOp + "','" + textBox_documento.Text + "','" + textBox_nuevo_nombre.Text + "'," + cabecera.Rows[0][4].ToString() + "," + cabecera.Rows[0][5].ToString().Replace(',', '.') + "," + cabecera.Rows[0][6].ToString().Replace(',', '.') + ",'" + cabecera.Rows[0][7].ToString() + "',1," + cabecera.Rows[0][10].ToString() + "," + textBox_importe.Text.Replace(',', '.') + "," + textBox_importe.Text.Replace(',', '.') + ",0,'No'," + Login.getId() + ",'" + fechaAhora + "')";
                    }
                    id_op = Persistencia.SentenciasSQL.InsertarGenericoID(sqlInsertCabe);
                    if (Convert.ToDouble(cabecera.Rows[0][6].ToString()) > 0.00)
                    {
                        tieneRetencion(id_op.ToString(), fechaOp);
                    }

                    //CREAMOS IVA
                    String sqlSelectIva = "SELECT aux_iva.`%IVA`, com_opdetiva.IdIVA FROM com_opdetiva INNER JOIN aux_iva ON com_opdetiva.IdIVA = aux_iva.IdIVA WHERE(((com_opdetiva.IdOp) = " + id_op_bbdd + "));";

                    DataTable iva = Persistencia.SentenciasSQL.select(sqlSelectIva);
                    if (iva.Rows.Count == 1)
                    {
                        int    ivaPer           = Convert.ToInt32(iva.Rows[0][0].ToString());
                        double ivaPerIntermedio = ivaPer / 100.00;
                        double baseIVA          = Convert.ToDouble(textBox_importe.Text.Replace('.', ',')) / (ivaPerIntermedio + 1);

                        double ivaTotal = ((baseIVA * ivaPer) / 100.00);

                        String sqlInsert = "INSERT INTO com_opdetiva (IdOp, Base, IdIVA, IVA) VALUES (" + id_op + "," + baseIVA.ToString().Replace(',', '.') + "," + iva.Rows[0][1].ToString() + "," + ivaTotal.ToString().Replace(',', '.') + ")";
                        Persistencia.SentenciasSQL.InsertarGenerico(sqlInsert);
                    }
                    else
                    {
                        MessageBox.Show("La Operacion tiene mas de una linea de IVA, por tanto se tiene que añadir el IVA manualmente.");
                        String    sqlTodosIvas = "SELECT Base, IdIVA, IVA FROM com_opdetiva WHERE IdOp = " + id_op_bbdd;
                        DataTable variosIvas   = Persistencia.SentenciasSQL.select(sqlTodosIvas);
                        for (int a = 0; a < variosIvas.Rows.Count; a++)
                        {
                            String sqlInsertIvas = "INSERT INTO com_opdetiva (IdOp, Base, IdIVA, IVA) VALUES (" + id_op + "," + variosIvas.Rows[a][0].ToString().Replace(',', '.') + "," + variosIvas.Rows[a][1].ToString() + "," + variosIvas.Rows[a][2].ToString().Replace(',', '.') + ")";
                            Persistencia.SentenciasSQL.InsertarGenerico(sqlInsertIvas);
                        }

                        masDeUnaLineaIVA = true;
                    }

                    //CREAMOS REPARTO
                    String    sqlSelectReparto = "SELECT IdBloque, Porcentaje FROM com_opdetbloques WHERE IdOp = " + id_op_bbdd + ";";
                    DataTable repartos         = Persistencia.SentenciasSQL.select(sqlSelectReparto);
                    for (int a = 0; a < repartos.Rows.Count; a++)
                    {
                        double porcentaje = Convert.ToDouble(repartos.Rows[a][1].ToString()) * 100;

                        double total = (Convert.ToDouble(textBox_importe.Text.Replace('.', ',')) * porcentaje) / 100;

                        String sqlInsertReparto = "INSERT INTO com_opdetbloques (IdOp, IdBloque, Porcentaje, Importe) VALUES (" + id_op + "," + repartos.Rows[a][0].ToString() + "," + repartos.Rows[a][1].ToString().Replace(',', '.') + "," + total.ToString().Replace(',', '.') + ")";
                        Persistencia.SentenciasSQL.InsertarGenerico(sqlInsertReparto);
                    }

                    //CREAMOS VENCIMIENTOS
                    String    sqlEntidadVencimiento = "SELECT IdEntidad, Importe FROM com_opdetalles WHERE com_opdetalles.IdOp = " + id_op_bbdd + ";";
                    DataTable vencimientos          = Persistencia.SentenciasSQL.select(sqlEntidadVencimiento);
                    String    fechaAhora2           = (Convert.ToDateTime(fechaOp)).ToString("yyyy-MM-dd");

                    if (vencimientos.Rows.Count > 1)
                    {
                        double cantidad = 0.00;
                        for (int b = 0; b < vencimientos.Rows.Count; b++)
                        {
                            cantidad = cantidad + Convert.ToDouble(vencimientos.Rows[b][1].ToString());

                            String sqlInsertVencimiento = "INSERT INTO com_opdetalles (IdOp, IdEntidad, Fecha, Importe, ImpOpDetPte) VALUES (" + id_op + "," + vencimientos.Rows[b][0].ToString() + ",'" + fechaAhora2 + "'," + Logica.FuncionesGenerales.ArreglarImportes(vencimientos.Rows[b][1].ToString()) + "," + Logica.FuncionesGenerales.ArreglarImportes(vencimientos.Rows[b][1].ToString()) + ")";
                            Persistencia.SentenciasSQL.InsertarGenerico(sqlInsertVencimiento);
                        }
                        if (!cantidad.Equals(Convert.ToDouble(textBox_importe.Text.ToString().Replace(".", ","))))
                        {
                            MessageBox.Show("EL IMPORTE NO SUMA CORRECTAMENTE LOS VENCIMIENTOS ¡ REVISAR !");
                            masDeUnaLineaVencimientos = true;
                        }
                    }
                    else if (vencimientos.Rows.Count == 1)
                    {
                        String sqlInsertVencimiento = "INSERT INTO com_opdetalles (IdOp, IdEntidad, Fecha, Importe, ImpOpDetPte) VALUES (" + id_op + "," + vencimientos.Rows[0][0].ToString() + ",'" + fechaAhora2 + "'," + Logica.FuncionesGenerales.ArreglarImportes(textBox_importe.Text) + "," + Logica.FuncionesGenerales.ArreglarImportes(textBox_importe.Text) + ")";
                        Persistencia.SentenciasSQL.InsertarGenerico(sqlInsertVencimiento);
                    }
                    else
                    {
                        MessageBox.Show("La Operacion no tiene vencimientos");
                    }

                    //LIQUIDACIONES
                    String    sqlSelectLiqui = "SELECT Porcentaje FROM com_opdetliquidacion WHERE com_opdetliquidacion.IdOp = " + id_op_bbdd + ";";
                    DataTable liquidaciones  = Persistencia.SentenciasSQL.select(sqlSelectLiqui);

                    //COJO LA FECHA
                    String fecha = (Convert.ToDateTime(maskedTextBox_nueva_fecha.Text)).ToString("yyyy-MM-dd");

                    //Buscamos liquidacion a la que pertenece
                    String sqlSelectLiquidacionesActivas = "SELECT com_liquidaciones.IdLiquidacion FROM com_ejercicios INNER JOIN com_liquidaciones ON com_ejercicios.IdEjercicio = com_liquidaciones.IdEjercicio WHERE(((com_liquidaciones.Cerrada) <> -1) AND((com_ejercicios.IdComunidad) = " + id_comunidad_cargado + ") AND((com_liquidaciones.Ppal) = -1) AND((com_liquidaciones.FIni) <= '" + fecha + "' ) AND ((com_liquidaciones.FFin) >= '" + fecha + "' ));";


                    DataTable liquidacionesActivas = Persistencia.SentenciasSQL.select(sqlSelectLiquidacionesActivas);

                    if (liquidacionesActivas.Rows.Count > 0)
                    {
                        if (liquidaciones.Rows.Count == 1)
                        {
                            String sqlInsertarLiquidacionDet = "INSERT INTO com_opdetliquidacion (IdOp, IdLiquidacion, Porcentaje, Importe) VALUES (" + id_op + "," + liquidacionesActivas.Rows[0][0].ToString() + "," + liquidaciones.Rows[0][0].ToString() + "," + Logica.FuncionesGenerales.ArreglarImportes(textBox_importe.Text) + ")";

                            Persistencia.SentenciasSQL.InsertarGenerico(sqlInsertarLiquidacionDet);
                        }
                        else
                        {
                            MessageBox.Show("La Operacion tiene mas de una linea de Liquidacion o ninguna, por tanto se tiene que añadir manualmente.");
                        }
                    }
                    else
                    {
                        String sqlLiqPpal = "SELECT com_liquidaciones.IdLiquidacion FROM com_liquidaciones INNER JOIN com_ejercicios ON com_liquidaciones.IdEjercicio = com_ejercicios.IdEjercicio WHERE(((com_ejercicios.IdComunidad) = " + id_comunidad_cargado + ") AND((com_liquidaciones.Ppal) = -1));";
                        String LiqPpal    = (Persistencia.SentenciasSQL.select(sqlLiqPpal)).Rows[0][0].ToString();
                        if (LiqPpal != "" || LiqPpal != null)
                        {
                            MessageBox.Show("¡¡ CUIDADO LA LIQUIDACIÓN SUGERIDA ESTA CERRADA !!");
                            String sqlInsertarLiquidacionDet = "INSERT INTO com_opdetliquidacion (IdOp, IdLiquidacion, Porcentaje, Importe) VALUES (" + id_op + "," + LiqPpal + "," + liquidaciones.Rows[0][0].ToString() + "," + Logica.FuncionesGenerales.ArreglarImportes(textBox_importe.Text) + ")";
                            Persistencia.SentenciasSQL.InsertarGenerico(sqlInsertarLiquidacionDet);
                        }
                        else
                        {
                            MessageBox.Show("No hay liquidacion principal");
                        }
                    }

                    if (masDeUnaLineaIVA)
                    {
                        FromOperacionesVer    nueva    = new FromOperacionesVer(id_op.ToString(), 1, id_comunidad_cargado, textoBuscar);
                        FormOperacionesAddIVA nuevaIVA = new FormOperacionesAddIVA(nueva, id_comunidad_cargado, id_op.ToString(), textBox_importe.Text.Replace('.', ','), true);
                        nuevaIVA.Show();
                        nueva.Show();
                        nuevaIVA.TopMost = true;
                    }
                    else if (masDeUnaLineaVencimientos)
                    {
                        FromOperacionesVer          nueva             = new FromOperacionesVer(id_op.ToString(), 1, id_comunidad_cargado, textoBuscar);
                        FormOperacionesVencimientos nuevaVencimientos = new FormOperacionesVencimientos(nueva, id_comunidad_cargado, id_op.ToString(), textBox_importe.Text.Replace('.', ','), true);
                        nuevaVencimientos.Show();
                        nueva.Show();
                        nuevaVencimientos.TopMost = true;
                    }
                    else
                    {
                        FromOperacionesVer nueva = new FromOperacionesVer(id_op.ToString(), 1, id_comunidad_cargado, textoBuscar);
                        nueva.Show();
                    }
                }
                else if (cabecera.Rows[0][3].ToString() == "3")
                {
                    if (cabecera.Rows[0][10].ToString() == "")
                    {
                        sqlInsertCabe = "INSERT INTO com_operaciones (IdComunidad, IdEntidad, IdSubCuenta, IdTipoReparto, Fecha, Documento, Descripcion,IdRetencion, BaseRet, Retencion,Notas, IdEstado, ImpOp, ImpOpPte, NumMov, Guardada, IdURD, FAct) VALUES (" + cabecera.Rows[0][0].ToString() + "," + cabecera.Rows[0][1].ToString() + "," + cabecera.Rows[0][2].ToString() + "," + cabecera.Rows[0][3].ToString() + ",'" + fechaOp + "','" + textBox_documento.Text + "','" + textBox_nuevo_nombre.Text + "'," + cabecera.Rows[0][4].ToString() + "," + cabecera.Rows[0][5].ToString().Replace(',', '.') + "," + cabecera.Rows[0][6].ToString().Replace(',', '.') + ",'" + cabecera.Rows[0][7].ToString() + "',1," + textBox_importe.Text.Replace(',', '.') + "," + textBox_importe.Text.Replace(',', '.') + ",0,'No'," + Login.getId() + ",'" + fechaAhora + "')";
                    }
                    else
                    {
                        sqlInsertCabe = "INSERT INTO com_operaciones (IdComunidad, IdEntidad, IdSubCuenta, IdTipoReparto, Fecha, Documento, Descripcion,IdRetencion, BaseRet, Retencion,Notas, IdEstado, IdExpte, ImpOp, ImpOpPte, NumMov, Guardada, IdURD, FAct) VALUES (" + cabecera.Rows[0][0].ToString() + "," + cabecera.Rows[0][1].ToString() + "," + cabecera.Rows[0][2].ToString() + "," + cabecera.Rows[0][3].ToString() + ",'" + fechaOp + "','" + textBox_documento.Text + "','" + textBox_nuevo_nombre.Text + "'," + cabecera.Rows[0][4].ToString() + "," + cabecera.Rows[0][5].ToString().Replace(',', '.') + "," + cabecera.Rows[0][6].ToString().Replace(',', '.') + ",'" + cabecera.Rows[0][7].ToString() + "',1," + cabecera.Rows[0][10].ToString() + "," + textBox_importe.Text.Replace(',', '.') + "," + textBox_importe.Text.Replace(',', '.') + ",0,'No'," + Login.getId() + ",'" + fechaAhora + "')";
                    }
                    id_op = Persistencia.SentenciasSQL.InsertarGenericoID(sqlInsertCabe);


                    //CREAMOS IVA
                    String sqlSelectIva = "SELECT aux_iva.`%IVA`, com_opdetiva.IdIVA FROM com_opdetiva INNER JOIN aux_iva ON com_opdetiva.IdIVA = aux_iva.IdIVA WHERE(((com_opdetiva.IdOp) = " + id_op_bbdd + "));";

                    DataTable iva = Persistencia.SentenciasSQL.select(sqlSelectIva);
                    if (iva.Rows.Count == 1)
                    {
                        int    ivaPer           = Convert.ToInt32(iva.Rows[0][0].ToString());
                        double ivaPerIntermedio = ivaPer / 100.00;
                        double baseIVA          = Convert.ToDouble(textBox_importe.Text.Replace('.', ',')) / (ivaPerIntermedio + 1);

                        double ivaTotal = ((baseIVA * ivaPer) / 100.00);

                        String sqlInsert = "INSERT INTO com_opdetiva (IdOp, Base, IdIVA, IVA) VALUES (" + id_op + "," + baseIVA.ToString().Replace(',', '.') + "," + iva.Rows[0][1].ToString() + "," + ivaTotal.ToString().Replace(',', '.') + ")";
                        Persistencia.SentenciasSQL.InsertarGenerico(sqlInsert);
                    }
                    else
                    {
                        MessageBox.Show("La Operacion tiene mas de una linea de IVA, por tanto se tiene que añadir el IVA manualmente.");
                        String    sqlTodosIvas = "SELECT Base, IdIVA, IVA FROM com_opdetiva WHERE IdOp = " + id_op_bbdd;
                        DataTable variosIvas   = Persistencia.SentenciasSQL.select(sqlTodosIvas);
                        for (int a = 0; a < variosIvas.Rows.Count; a++)
                        {
                            String sqlInsertIvas = "INSERT INTO com_opdetiva (IdOp, Base, IdIVA, IVA) VALUES (" + id_op + "," + variosIvas.Rows[a][0].ToString().Replace(',', '.') + "," + variosIvas.Rows[a][1].ToString() + "," + variosIvas.Rows[a][2].ToString().Replace(',', '.') + ")";
                            Persistencia.SentenciasSQL.InsertarGenerico(sqlInsertIvas);
                        }

                        masDeUnaLineaIVA = true;
                    }

                    //CREAMOS REPARTO
                    String    sqlSelectReparto = "SELECT IdEntidad, Porcentaje FROM com_opdetbloques WHERE IdOp = " + id_op_bbdd + ";";
                    DataTable repartos         = Persistencia.SentenciasSQL.select(sqlSelectReparto);
                    for (int a = 0; a < repartos.Rows.Count; a++)
                    {
                        double porcentaje = Convert.ToDouble(repartos.Rows[a][1].ToString()) * 100;

                        double total = (Convert.ToDouble(textBox_importe.Text.Replace('.', ',')) * porcentaje) / 100;

                        String sqlInsertReparto = "INSERT INTO com_opdetbloques (IdOp, IdEntidad, Porcentaje, Importe) VALUES (" + id_op + "," + repartos.Rows[a][0].ToString() + "," + repartos.Rows[a][1].ToString().Replace(',', '.') + "," + total.ToString().Replace(',', '.') + ")";
                        Persistencia.SentenciasSQL.InsertarGenerico(sqlInsertReparto);
                    }


                    //CREAMOS VENCIMIENTOS
                    String    sqlEntidadVencimiento = "SELECT IdEntidad, Importe FROM com_opdetalles WHERE com_opdetalles.IdOp = " + id_op_bbdd + ";";
                    DataTable vencimientos          = Persistencia.SentenciasSQL.select(sqlEntidadVencimiento);
                    String    fechaAhora2           = (Convert.ToDateTime(fechaOp)).ToString("yyyy-MM-dd");

                    if (vencimientos.Rows.Count > 0)
                    {
                        for (int a = 0; a < vencimientos.Rows.Count; a++)
                        {
                            if (vencimientos.Rows.Count > 1)
                            {
                                String sqlInsertVencimiento = "INSERT INTO com_opdetalles (IdOp, IdEntidad, Fecha, Importe, ImpOpDetPte) VALUES (" + id_op + "," + vencimientos.Rows[a][0].ToString() + ",'" + fechaAhora2 + "'," + Logica.FuncionesGenerales.ArreglarImportes(vencimientos.Rows[a][1].ToString()) + "," + Logica.FuncionesGenerales.ArreglarImportes(vencimientos.Rows[a][1].ToString()) + ")";
                                Persistencia.SentenciasSQL.InsertarGenerico(sqlInsertVencimiento);
                            }
                            else if (vencimientos.Rows.Count == 1)
                            {
                                String sqlInsertVencimiento = "INSERT INTO com_opdetalles (IdOp, IdEntidad, Fecha, Importe, ImpOpDetPte) VALUES (" + id_op + "," + vencimientos.Rows[a][0].ToString() + ",'" + fechaAhora2 + "'," + Logica.FuncionesGenerales.ArreglarImportes(textBox_importe.Text) + "," + Logica.FuncionesGenerales.ArreglarImportes(textBox_importe.Text) + ")";
                                Persistencia.SentenciasSQL.InsertarGenerico(sqlInsertVencimiento);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("La Operacion no tiene vencimientos");
                    }

                    //LIQUIDACIONES
                    String    sqlSelectLiqui = "SELECT Porcentaje FROM com_opdetliquidacion WHERE com_opdetliquidacion.IdOp = " + id_op_bbdd + ";";
                    DataTable liquidaciones  = Persistencia.SentenciasSQL.select(sqlSelectLiqui);

                    //COJO LA FECHA
                    String fecha = (Convert.ToDateTime(maskedTextBox_nueva_fecha.Text)).ToString("yyyy-MM-dd");

                    //Buscamos liquidacion a la que pertenece
                    String sqlSelectLiquidacionesActivas = "SELECT com_liquidaciones.IdLiquidacion FROM com_ejercicios INNER JOIN com_liquidaciones ON com_ejercicios.IdEjercicio = com_liquidaciones.IdEjercicio WHERE(((com_liquidaciones.Cerrada) <> -1) AND((com_ejercicios.IdComunidad) = " + id_comunidad_cargado + ") AND((com_liquidaciones.Ppal) = -1) AND((com_liquidaciones.FIni) <= '" + fecha + "' ) AND ((com_liquidaciones.FFin) >= '" + fecha + "' ));";

                    DataTable liquidacionesActivas = Persistencia.SentenciasSQL.select(sqlSelectLiquidacionesActivas);

                    if (liquidacionesActivas.Rows.Count > 0)
                    {
                        if (liquidaciones.Rows.Count == 1)
                        {
                            String sqlInsertarLiquidacionDet = "INSERT INTO com_opdetliquidacion (IdOp, IdLiquidacion, Porcentaje, Importe) VALUES (" + id_op + "," + liquidacionesActivas.Rows[0][0].ToString() + "," + liquidaciones.Rows[0][0].ToString() + "," + Logica.FuncionesGenerales.ArreglarImportes(textBox_importe.Text) + ")";

                            Persistencia.SentenciasSQL.InsertarGenerico(sqlInsertarLiquidacionDet);
                        }
                        else
                        {
                            MessageBox.Show("La Operacion tiene mas de una linea de Liquidacion o ninguna, por tanto se tiene que añadir manualmente.");
                        }
                    }
                    else
                    {
                        String sqlLiqPpal = "SELECT com_liquidaciones.IdLiquidacion FROM com_liquidaciones INNER JOIN com_ejercicios ON com_liquidaciones.IdEjercicio = com_ejercicios.IdEjercicio WHERE(((com_ejercicios.IdComunidad) = " + id_comunidad_cargado + ") AND((com_liquidaciones.Ppal) = -1));";
                        String LiqPpal    = (Persistencia.SentenciasSQL.select(sqlLiqPpal)).Rows[0][0].ToString();
                        if (LiqPpal != "" || LiqPpal != null)
                        {
                            String sqlInsertarLiquidacionDet = "INSERT INTO com_opdetliquidacion (IdOp, IdLiquidacion, Porcentaje, Importe) VALUES (" + id_op + "," + LiqPpal + "," + liquidaciones.Rows[0][0].ToString() + "," + Logica.FuncionesGenerales.ArreglarImportes(textBox_importe.Text) + ")";
                            Persistencia.SentenciasSQL.InsertarGenerico(sqlInsertarLiquidacionDet);
                        }
                        else
                        {
                            MessageBox.Show("No hay liquidacion principal");
                        }
                    }
                    int       numRecibo          = 0;
                    String    vencimientosRecibo = "SELECT com_opdetbloques.IdEntidad, com_operaciones.Fecha, com_opdetbloques.Importe, com_operaciones.Descripcion FROM com_operaciones INNER JOIN com_opdetbloques ON com_operaciones.IdOp = com_opdetbloques.IdOp WHERE(((com_operaciones.IdOp) = " + id_op + "));";
                    DataTable reparto            = Persistencia.SentenciasSQL.select(vencimientosRecibo);
                    for (int a = 0; a < reparto.Rows.Count; a++)
                    {
                        String fechaRecibo = (Convert.ToDateTime(reparto.Rows[a][1].ToString())).ToString("yyyy-MM-dd");
                        numRecibo = Logica.FuncionesTesoreria.CreoReciboID(id_comunidad_cargado, reparto.Rows[a][0].ToString(), fechaRecibo, reparto.Rows[a][2].ToString(), reparto.Rows[a][2].ToString(), reparto.Rows[a][3].ToString());
                        String id_opdet = (Persistencia.SentenciasSQL.select("SELECT IdOpDet FROM com_opdetalles WHERE IdOp = " + id_op)).Rows[0][0].ToString();
                        Logica.FuncionesTesoreria.ActualizoIdReciboVencimiento(numRecibo.ToString(), id_opdet);
                    }

                    if (masDeUnaLineaIVA)
                    {
                        FromOperacionesVer    nueva    = new FromOperacionesVer(id_op.ToString(), 1, id_comunidad_cargado, textoBuscar);
                        FormOperacionesAddIVA nuevaIVA = new FormOperacionesAddIVA(nueva, id_comunidad_cargado, id_op.ToString(), textBox_importe.Text.Replace('.', ','), true);
                        nuevaIVA.Show();
                        nueva.Show();
                        nuevaIVA.TopMost = true;
                    }
                    else
                    {
                        FromOperacionesVer nueva = new FromOperacionesVer(id_op.ToString(), 1, id_comunidad_cargado, textoBuscar);
                        nueva.Show();
                    }
                }
            }
        }
Esempio n. 4
0
        private void enviarOtroForm()
        {
            Form existe = Application.OpenForms.OfType <Form>().Where(pre => pre.Name.Contains(nombre_form_anterior)).SingleOrDefault <Form>();

            if (existe != null)
            {
                if (nombre_form_anterior == "FormAltaComunero")
                {
                    Presentacion.ComunidadesForms.ComunerosForms.FormAltaComunero nuevo = (Presentacion.ComunidadesForms.ComunerosForms.FormAltaComunero)existe;
                    nuevo.recibirEntidad(dataGridView1.SelectedCells[0].Value.ToString());
                }
                //if (nombre_form_anterior == "FormAltaAsociacion") {
                //    Presentacion.ComunidadesForms.DivisionesForms.FormAltaAsociacion nuevo = (Presentacion.ComunidadesForms.DivisionesForms.FormAltaAsociacion) existe;
                //    nuevo.recogerEntidad(dataGridView1.SelectedCells[0].Value.ToString());
                //}
                if (nombre_form_anterior == "FormOperacionesCabeceraEdicion")
                {
                    Presentacion.ComunidadesForms.OperacionesForms.FormOperacionesCabeceraEdicion nuevo = (Presentacion.ComunidadesForms.OperacionesForms.FormOperacionesCabeceraEdicion)existe;
                    nuevo.recibirEntidad(dataGridView1.SelectedCells[0].Value.ToString());
                }
                if (nombre_form_anterior == "FormOperacionesVencimientos")
                {
                    ComunidadesForms.OperacionesForms.FormOperacionesVencimientos nuevo = (ComunidadesForms.OperacionesForms.FormOperacionesVencimientos)existe;
                    nuevo.recibirEntidad(dataGridView1.SelectedCells[0].Value.ToString(), dataGridView1.SelectedCells[1].Value.ToString());
                }
                if (nombre_form_anterior == "FormOperacionesEditReparto")
                {
                    ComunidadesForms.OperacionesForms.FormOperacionesEditReparto nuevo = (ComunidadesForms.OperacionesForms.FormOperacionesEditReparto)existe;
                    nuevo.recogerBloque(dataGridView1.SelectedCells[0].Value.ToString(), dataGridView1.SelectedCells[1].Value.ToString());
                }

                if (nombre_form_anterior == "FormAccesoOperacionesTesoreria")
                {
                    ComunidadesForms.TesoreriaForms.FormAccesoOperacionesTesoreria nuevo = (ComunidadesForms.TesoreriaForms.FormAccesoOperacionesTesoreria)existe;
                    nuevo.recibirEntidad(dataGridView1.SelectedCells[0].Value.ToString(), dataGridView1.SelectedCells[1].Value.ToString());
                }
                if (nombre_form_anterior == "FormCrearCuentaComunidad")
                {
                    ComunidadesForms.TesoreriaForms.FormCrearCuentaComunidad nuevo = (ComunidadesForms.TesoreriaForms.FormCrearCuentaComunidad)existe;
                    nuevo.recibirEntidad(dataGridView1.SelectedCells[0].Value.ToString(), dataGridView1.SelectedCells[1].Value.ToString());
                }

                if (nombre_form_anterior == "FormReasignarOperacion")
                {
                    ComunidadesForms.DivisionesForms.FormReasignarPagador nuevo = (ComunidadesForms.DivisionesForms.FormReasignarPagador)existe;
                    nuevo.recibirEntidad(dataGridView1.SelectedCells[0].Value.ToString(), dataGridView1.SelectedCells[1].Value.ToString());
                }

                if (nombre_form_anterior == "FormNuevoRecibo")
                {
                    ComunidadesForms.Recibos.FormNuevoRecibo nuevo = (ComunidadesForms.Recibos.FormNuevoRecibo)existe;
                    nuevo.recibirEntidad(dataGridView1.SelectedCells[0].Value.ToString());
                }
                if (nombre_form_anterior == "FormIngresoFondo")
                {
                    ComunidadesForms.OperacionesForms.FormIngresoFondo nuevo = (ComunidadesForms.OperacionesForms.FormIngresoFondo)existe;
                    nuevo.recibirComunero(dataGridView1.SelectedCells[0].Value.ToString(), dataGridView1.SelectedCells[1].Value.ToString());
                }
                if (nombre_form_anterior == "FormAnyadirProveedor")
                {
                    ComunidadesForms.ProveedoresForms.FormAnyadirProveedor nuevo = (ComunidadesForms.ProveedoresForms.FormAnyadirProveedor)existe;
                    nuevo.recibirEntidad(dataGridView1.SelectedCells[0].Value.ToString(), dataGridView1.SelectedCells[1].Value.ToString());
                }
                if (form_ant.Name.Contains("FormVerTarea"))
                {
                    Tareas.FormVerTarea nuevo = (Tareas.FormVerTarea)existe;
                    nuevo.recibirEntidad(dataGridView1.SelectedCells[0].Value.ToString());
                }
                if (nombre_form_anterior == "FormInsertarContacto")
                {
                    Tareas.FormInsertarContacto nuevo = (Tareas.FormInsertarContacto)existe;
                    nuevo.recibirEntidad(dataGridView1.SelectedCells[1].Value.ToString(), dataGridView1.SelectedCells[2].Value.ToString(), dataGridView1.SelectedCells[3].Value.ToString());
                }
                if (form_ant.Name.Contains("FormInsertarGestion"))
                {
                    Tareas.FormInsertarGestion nuevo = (Tareas.FormInsertarGestion)existe;
                    nuevo.recibirEntidad(dataGridView1.SelectedCells[0].Value.ToString(), dataGridView1.SelectedCells[1].Value.ToString());
                }
                if (nombre_form_anterior == "FormGestionesPrincipalEsperaDe")
                {
                    Tareas.FormGestionesPrincipal nuevo = (Tareas.FormGestionesPrincipal)existe;
                    nuevo.recibirEntidadEspera(dataGridView1.SelectedCells[0].Value.ToString(), dataGridView1.SelectedCells[1].Value.ToString());
                }
                if (nombre_form_anterior == "FormGestionesPrincipalEntidad")
                {
                    Tareas.FormGestionesPrincipal nuevo = (Tareas.FormGestionesPrincipal)existe;
                    nuevo.recibirEntidad(dataGridView1.SelectedCells[0].Value.ToString(), dataGridView1.SelectedCells[1].Value.ToString());
                }
                if (nombre_form_anterior == "FormGeneralTareasPrincipal")
                {
                    Tareas.FormTareasPrincipal nuevo = (Tareas.FormTareasPrincipal)existe;
                    nuevo.recibirEntidad(dataGridView1.SelectedCells[0].Value.ToString(), dataGridView1.SelectedCells[1].Value.ToString());
                }
            }
            this.Close();
        }
Esempio n. 5
0
        private void enviarOtroForm()
        {
            Form existe = Application.OpenForms.OfType <Form>().Where(pre => pre.Name.Contains(nombre_form_anterior)).SingleOrDefault <Form>();

            if (existe != null)
            {
                if (nombre_form_anterior == "FormOperacionesCabeceraEdicion")
                {
                    OperacionesForms.FormOperacionesCabeceraEdicion nuevo = (OperacionesForms.FormOperacionesCabeceraEdicion)existe;
                    nuevo.recibirComunero(dataGridView_comuneros.SelectedCells[1].Value.ToString());
                }
                if (nombre_form_anterior == "FormOperacionesVencimientos")
                {
                    OperacionesForms.FormOperacionesVencimientos nuevo = (OperacionesForms.FormOperacionesVencimientos)existe;
                    nuevo.recibirComunero(dataGridView_comuneros.SelectedCells[1].Value.ToString());
                }
                if (nombre_form_anterior == "FormReasignarOperacion")
                {
                    DivisionesForms.FormReasignarPagador nuevo = (DivisionesForms.FormReasignarPagador)existe;
                    nuevo.recibirEntidad(dataGridView_comuneros.SelectedCells[1].Value.ToString(), dataGridView_comuneros.SelectedCells[2].Value.ToString());
                }

                if (nombre_form_anterior == "FormAltaAsociacion")
                {
                    DivisionesForms.FormAltaAsociacion nuevo = (DivisionesForms.FormAltaAsociacion)existe;
                    nuevo.recibirComunero(dataGridView_comuneros.SelectedCells[1].Value.ToString());
                }

                if (nombre_form_anterior == "FormAccesoOperacionesTesoreria")
                {
                    TesoreriaForms.FormAccesoOperacionesTesoreria nuevo = (TesoreriaForms.FormAccesoOperacionesTesoreria)existe;
                    nuevo.recibirEntidad(dataGridView_comuneros.SelectedCells[1].Value.ToString(), dataGridView_comuneros.SelectedCells[2].Value.ToString());
                }
                if (nombre_form_anterior == "FormIngresoFondo")
                {
                    OperacionesForms.FormIngresoFondo nuevo = (OperacionesForms.FormIngresoFondo)existe;
                    nuevo.recibirComunero(dataGridView_comuneros.SelectedCells[1].Value.ToString(), dataGridView_comuneros.SelectedCells[2].Value.ToString());
                }
                if (nombre_form_anterior == "FormCompensarAnticipos")
                {
                    OperacionesForms.FormCompensarAnticipos nuevo = (OperacionesForms.FormCompensarAnticipos)existe;
                    nuevo.recibirEntidad(dataGridView_comuneros.SelectedCells[1].Value.ToString(), dataGridView_comuneros.SelectedCells[2].Value.ToString());
                }
                if (nombre_form_anterior == "FormAnyadirReglaDetalle")
                {
                    DivisionesForms.ReglasPago.FormAnyadirReglaDetalle nuevo = (DivisionesForms.ReglasPago.FormAnyadirReglaDetalle)existe;
                    nuevo.recibirComunero(dataGridView_comuneros.SelectedCells[0].Value.ToString(), dataGridView_comuneros.SelectedCells[2].Value.ToString());
                }
                if (nombre_form_anterior == "FormCargosAlta")
                {
                    CargosForms.FormCargosAlta nuevo = (CargosForms.FormCargosAlta)existe;
                    nuevo.recibirComunero(dataGridView_comuneros.SelectedCells[0].Value.ToString(), dataGridView_comuneros.SelectedCells[2].Value.ToString(), dataGridView_comuneros.SelectedCells[1].Value.ToString());
                }
                if (nombre_form_anterior == "FormAbonarVencimiento")
                {
                    OperacionesForms.FormAbonarVencimiento nuevo = (OperacionesForms.FormAbonarVencimiento)existe;
                    nuevo.recibirComunero(dataGridView_comuneros.SelectedCells[1].Value.ToString(), dataGridView_comuneros.SelectedCells[2].Value.ToString());
                }
                if (nombre_form_anterior == "FormInsertarContacto")
                {
                    Tareas.FormInsertarContacto nuevo = (Tareas.FormInsertarContacto)existe;
                    nuevo.recibirComunero(dataGridView_comuneros.SelectedCells[0].Value.ToString(), dataGridView_comuneros.SelectedCells[2].Value.ToString(), textBox_EMail.Text);
                }
                if (nombre_form_anterior == "FormInsertarGestion")
                {
                    Tareas.FormInsertarGestion nuevo = (Tareas.FormInsertarGestion)existe;
                    nuevo.recibirComunero(dataGridView_comuneros.SelectedCells[1].Value.ToString(), dataGridView_comuneros.SelectedCells[2].Value.ToString());
                }
            }
            this.Close();
        }