예제 #1
0
        private static bool IsValidActivo(tfi_TDCompTesoreriaDataset.tfi_TDCompTesoreriaRow row)
        {
            bool   Activo            = Convert.ToBoolean(row["Activo"]);
            string IdTDCompTesoreria = Convert.ToString(row["IdTDCompTesoreria"]);

            if (Activo)
            {
                return(true);
            }
            DataSet data  = mz.erp.businessrules.tsa_CondicionesDeVentas.GetCondicionesDeVentaByIdTDCompTesoreria(IdTDCompTesoreria);
            string  error = "No se puede Desactivar la forma de pago porque esta asociada a las siguientes condiciones de ventas: ";

            foreach (DataRow r in data.Tables[0].Rows)
            {
                string desc = Convert.ToString(r["Descripcion"]);
                error = error + " - " + desc;
            }
            if (data.Tables[0].Rows.Count > 0)
            {
                row.SetColumnError("Descripcion", error);
                return(false);
            }

            return(true);
        }
예제 #2
0
        public static void Update(tfi_TDCompTesoreriaDataset.tfi_TDCompTesoreriaRow row, SqlTransaction trx)
        {
            if (row.RowState == DataRowState.Detached)
            {
                ((tfi_TDCompTesoreriaDataset.tfi_TDCompTesoreriaDataTable)row.Table).Addtfi_TDCompTesoreriaRow(row);
            }

            Update(row.Table, trx);
        }
예제 #3
0
        public static bool IsValid(tfi_TDCompTesoreriaDataset.tfi_TDCompTesoreriaRow row)
        {
            bool ok = true;

            ok = ok && RowIsValid(row) && IsValidDescripcion(row) && IsValidActivo(row);
            if (ok)
            {
                ok = ok && ValidarCompleto(row);
            }
            return(ok);
        }
예제 #4
0
        private static bool ValidarCompleto(tfi_TDCompTesoreriaDataset.tfi_TDCompTesoreriaRow row)
        {
            bool   ok           = true;
            string messageError = row.GetColumnError("IdTDCompTesoreria");
            bool   validadRelacionCondicionesDeVentas = Variables.GetValueBool("ProcesoABMFormasDePagos", "ABMFormasDePagos", "Validar.RelacionObligatoriaCondicionesDeVentas");

            if (validadRelacionCondicionesDeVentas && _dataTDCompTesoreria_CondicionesDeVentas.tfi_TDCompTesoreria_CondicionesDeVenta.Rows.Count == 0)
            {
                messageError = messageError + ". " + "Debe seleccionar La Condición de Venta a la que se asocia la Forma de Pago";
                ok           = false;
            }


            return(ok);
        }
예제 #5
0
 /// <summary>
 /// Obtiene un registro de la tabla tfi_TDCompTesoreria que luego puede ser persistido en la base de datos.
 /// </summary>
 public static tfi_TDCompTesoreriaDataset.tfi_TDCompTesoreriaRow GetByPk(string IdTDCompTesoreria)
 {
     tfi_TDCompTesoreriaDataset.tfi_TDCompTesoreriaRow row = mz.erp.dataaccess.tfi_TDCompTesoreria.GetByPk(IdTDCompTesoreria);
     if (row != null)
     {
         foreach (DataColumn dc in row.Table.Columns)
         {
             if (row[dc] == System.DBNull.Value)
             {
                 row[dc] = Util.DefaultValue(dc.DataType);
             }
         }
     }
     return(row);
 }
예제 #6
0
        private static bool IsValidDescripcion(tfi_TDCompTesoreriaDataset.tfi_TDCompTesoreriaRow row)
        {
            string  Descripcion = Convert.ToString(row["Descripcion"]);
            DataSet data        = mz.erp.businessrules.tfi_TDCompTesoreria.GetListByDescripcion(Descripcion);

            foreach (DataRow r in data.Tables[0].Rows)
            {
                if (Convert.ToString(r["IdTDCompTesoreria"]) != Convert.ToString(row["IdTDCompTesoreria"]))
                {
                    row.SetColumnError("Descripcion", "Ya existe una forma de pago con ese nombre");
                    return(false);
                }
            }

            return(true);
        }
        public ValoresController GetValoresController()
        {
            bool _agrupado = false;

            tfi_TDCompTesoreriaDataset.tfi_TDCompTesoreriaRow rowTdcomp = (tfi_TDCompTesoreria.GetByPk(ValorTDCompTesoreria));
            if (rowTdcomp != null)
            {
                _agrupado = rowTdcomp.Agrupado;
            }
            decimal _total = 0;

            if (_agrupado)
            {
                decimal totalValoresAgrupadoOrigen    = System.Math.Abs(this.TotalValoresAgrupadoOrigen());
                decimal totalValoresAgrupadoAjustados = System.Math.Abs(this.ValoresAjustados());
                decimal totalSinAjustar = totalValoresAgrupadoOrigen - totalValoresAgrupadoAjustados;
                decimal totalValor      = System.Math.Abs(ValorTotal);
                if (totalSinAjustar > 0)
                {
                    if (totalValor > totalSinAjustar)
                    {
                        _total = totalSinAjustar;
                    }
                    else
                    {
                        _total = totalValor;
                    }
                }
                if (_model.DetalleValorAgrupadoOrigen != null)
                {
                    string     IdCotizacion = _model.DetalleValorAgrupadoOrigen.IdCotizacionMoneda;
                    Cotizacion cot          = mz.erp.businessrules.tfi_CotizacionesMonedas.GetCotizacion(IdCotizacion);
                    _total = _total * cot.Valor;
                }
            }

            ValoresController valorescontroller = new ValoresController(ValorTDCompTesoreria, ValorMoneda, _agrupado, _total, 0, null, this, string.Empty);

            //seteo valores por defecto para la ventana de valores
            valorescontroller.AllowEditTDCompTesoreria  = _model.ValorAllowEditIdTDCompTesoreria;
            valorescontroller.IdTDCompTesoreriaReadOnly = _model.ValorIdTDCompTesoreriaReadOnly;
            valorescontroller.AllowEditMoneda           = _model.ValorAllowEditIdMoneda;
            valorescontroller.IdMonedaOrigenReadOnly    = _model.ValorIdMonedaReadOnly;

            return(valorescontroller);
        }
예제 #8
0
        /// <summary>
        /// Valida un tfi_TDCompTesoreriaRow.
        /// </summary>
        public static bool RowIsValid(tfi_TDCompTesoreriaDataset.tfi_TDCompTesoreriaRow row)
        {
            ApplicationAssert.Check(row != null, "El argumento row no debe ser nulo.", ApplicationAssert.LineNumber);
            bool   isValid = true;
            string mensaje;


            if (!IdTDCompTesoreriaIsValid(row.IdTDCompTesoreria, out mensaje))
            {
                row.SetColumnError("IdTDCompTesoreria", mensaje);
                isValid = false;
            }

            if (!DescripcionIsValid(row.Descripcion, out mensaje))
            {
                row.SetColumnError("Descripcion", mensaje);
                isValid = false;
            }

            if (!SistemaIsValid(row.Sistema, out mensaje))
            {
                row.SetColumnError("Sistema", mensaje);
                isValid = false;
            }

            if (!AgrupadoIsValid(row.Agrupado, out mensaje))
            {
                row.SetColumnError("Agrupado", mensaje);
                isValid = false;
            }

            /*
             * if ( !FechaCreacionIsValid( row.FechaCreacion, out mensaje) )
             * {
             *      row.SetColumnError( "FechaCreacion" , mensaje);
             *      isValid=false;
             *
             * }
             *
             *
             * if ( !IdConexionCreacionIsValid( row.IdConexionCreacion, out mensaje) )
             * {
             *      row.SetColumnError( "IdConexionCreacion" , mensaje);
             *      isValid=false;
             *
             * }
             *
             * if ( !UltimaModificacionIsValid( row.UltimaModificacion, out mensaje) )
             * {
             *      row.SetColumnError( "UltimaModificacion" , mensaje);
             *      isValid=false;
             *
             * }
             *
             * if ( !IdConexionUltimaModificacionIsValid( row.IdConexionUltimaModificacion, out mensaje) )
             * {
             *      row.SetColumnError( "IdConexionUltimaModificacion" , mensaje);
             *      isValid=false;
             *
             * }
             *
             * if ( !IdReservadoIsValid( row.IdReservado, out mensaje) )
             * {
             *      row.SetColumnError( "IdReservado" , mensaje);
             *      isValid=false;
             *
             * }
             *
             * if ( !RowIdIsValid( row.RowId, out mensaje) )
             * {
             *      row.SetColumnError( "RowId" , mensaje);
             *      isValid=false;
             *
             * }
             */

            if (!IdEmpresaIsValid(row.IdEmpresa, out mensaje))
            {
                row.SetColumnError("IdEmpresa", mensaje);
                isValid = false;
            }

            if (!IdSucursalIsValid(row.IdSucursal, out mensaje))
            {
                row.SetColumnError("IdSucursal", mensaje);
                isValid = false;
            }
            ;

            return(isValid);
        }
예제 #9
0
        /// <summary>
        /// Envia los cambios del tfi_TDCompTesoreriaRow a la base de datos.
        /// </summary>
        public static void Update(tfi_TDCompTesoreriaDataset.tfi_TDCompTesoreriaRow row, SqlTransaction trx)
        {
            ApplicationAssert.Check(row != null, "El argumento row no debe ser nulo.", ApplicationAssert.LineNumber);

            mz.erp.dataaccess.tfi_TDCompTesoreria.Update(row, trx);
        }
예제 #10
0
        public static void UpdateWithValidation(tfi_TDCompTesoreriaDataset.tfi_TDCompTesoreriaRow row)
        {
            ApplicationAssert.Check(row != null, "El argumento row no debe ser nulo.", ApplicationAssert.LineNumber);

            if (IsValid(row))
            {
                SqlConnection cnx = dbhelper.Connection.GetConnection();;
                cnx.Open();

                SqlTransaction trx = cnx.BeginTransaction(IsolationLevel.Serializable);

                try
                {
                    string IdTDCompTesoreria = string.Empty;
                    Update(row, trx);
                    IdTDCompTesoreria = Convert.ToString(row.IdTDCompTesoreria);

                    // se actualizan la variables terminadas en ',', apra que se agregue el ID recientemente insertado
                    if (_state.ToUpper().Equals("NEW"))
                    {
                        foreach (sy_VariablesDataset.sy_VariablesRow rowV in _dataVariables.sy_Variables.Rows)
                        {
                            string str = Convert.ToString(rowV["ValorDefault"]);
                            int    x   = str.LastIndexOf(',');
                            if (str.Length != 0 && (x + 1 == str.Length))
                            {
                                rowV["ValorDefault"] = str + Convert.ToString(row["IdTDCompTesoreria"]);
                            }
                        }
                    }

                    if (_dataCompEntidades != null)
                    {
                        foreach (tfi_TDCompTesoreria_EntidadesDataset.tfi_TDCompTesoreria_EntidadesRow rowE in _dataCompEntidades.tfi_TDCompTesoreria_Entidades.Rows)
                        {
                            //actualizo el id del comp tesoreria
                            rowE["TDCompTesoreria"] = row["idTDCompTesoreria"];
                        }
                    }
                    if (_dataTDCompTesoreria_CondicionesDeVentas != null)
                    {
                        foreach (tfi_TDCompTesoreria_CondicionesDeVentaDataset.tfi_TDCompTesoreria_CondicionesDeVentaRow row_TDCT_CV in _dataTDCompTesoreria_CondicionesDeVentas.tfi_TDCompTesoreria_CondicionesDeVenta.Rows)
                        {
                            row_TDCT_CV.idTDCompTesoreria = IdTDCompTesoreria;
                        }
                    }

                    if (_dataTDCompTesoreria_Monedas_Recargos != null)
                    {
                        foreach (tfi_TDCompTesoreriasMonedasRecargosDataset.tfi_TDCompTesoreriasMonedasRecargosRow row_TDCT_M_R in _dataTDCompTesoreria_Monedas_Recargos.tfi_TDCompTesoreriasMonedasRecargos.Rows)
                        {
                            row_TDCT_M_R.IdTDCompTesoreria = IdTDCompTesoreria;
                        }
                    }
                    if (_dataCuentas_CondicionesDeVentas_TDCompTesoreria != null)
                    {
                        foreach (tsa_CuentasCondicionesDeVenta_TDCompTesoreriaDataset.tsa_CuentasCondicionesDeVenta_TDCompTesoreriaRow row_C_CV_TDCT in _dataCuentas_CondicionesDeVentas_TDCompTesoreria.tsa_CuentasCondicionesDeVenta_TDCompTesoreria.Rows)
                        {
                            row_C_CV_TDCT.idTDCompTesoreria = IdTDCompTesoreria;
                        }
                    }

                    if (_dataTiposDeComprobantes_CondicionesDeVentas_TDCompTesoreria != null)
                    {
                        foreach (Tsy_TiposDeComprobantes_CondicionesDeVenta_TDCompTesoreriaDataset.Tsy_TiposDeComprobantes_CondicionesDeVenta_TDCompTesoreriaRow row_TC_CV_TDCT in _dataTiposDeComprobantes_CondicionesDeVentas_TDCompTesoreria.Tsy_TiposDeComprobantes_CondicionesDeVenta_TDCompTesoreria.Rows)
                        {
                            row_TC_CV_TDCT.IdTDCompTesoreria = IdTDCompTesoreria;
                        }
                    }

                    if (_dataConfiguracionFDP != null)
                    {
                        if (_dataConfiguracionFDP.tui_ConfiguracionFormasDePago.Rows.Count > 0)
                        {
                            _dataConfiguracionFDP.tui_ConfiguracionFormasDePago.Rows[0]["IdTDCompTesoreria"] = Convert.ToString(row["IdTDCompTesoreria"]);
                        }
                    }
                    if (_dataAgrupamientoTDCompTesoreria != null)
                    {
                        if (_dataAgrupamientoTDCompTesoreria.tfi_AgrupTDCompTesoreria.Rows.Count > 0)
                        {
                            _dataAgrupamientoTDCompTesoreria.tfi_AgrupTDCompTesoreria.Rows[0]["IdTDCompTesoreria"] = Convert.ToString(row["IdTDCompTesoreria"]);
                        }
                    }
                    mz.erp.dataaccess.sy_Variables.Update(_dataVariables.sy_Variables, trx);
                    mz.erp.dataaccess.sy_VariablesPerfiles.Update(_dataVariablesPerfiles.sy_VariablesPerfiles, trx);
                    //mz.erp.dataaccess.sy_Variables.Update(_dataVariablesABorrar.sy_Variables, trx);
                    //mz.erp.dataaccess.sy_VariablesPerfiles.Update(_dataVariablesPerfilesABorrar.sy_VariablesPerfiles , trx);
                    mz.erp.dataaccess.tfi_TDCompTesoreria_Entidades.Update(_dataCompEntidades.tfi_TDCompTesoreria_Entidades, trx);
                    mz.erp.dataaccess.tui_ConfiguracionFormasDePago.Update(_dataConfiguracionFDP.tui_ConfiguracionFormasDePago, trx);
                    if (_dataAgrupamientoTDCompTesoreria != null)
                    {
                        if (_state.Equals("NEW"))
                        {
                            mz.erp.dataaccess.tfi_AgrupTDCompTesoreria.Update(_dataAgrupamientoTDCompTesoreria.tfi_AgrupTDCompTesoreria, trx);
                        }
                    }
                    if (_dataTDCompTesoreria_CondicionesDeVentas != null)
                    {
                        mz.erp.dataaccess.tfi_TDCompTesoreria_CondicionesDeVenta.Update(_dataTDCompTesoreria_CondicionesDeVentas.tfi_TDCompTesoreria_CondicionesDeVenta, trx);
                    }
                    mz.erp.dataaccess.tfi_TDCompTesoreriasMonedasRecargos.Update(_dataTDCompTesoreria_Monedas_Recargos.tfi_TDCompTesoreriasMonedasRecargos, trx);
                    if (_dataCuentas_CondicionesDeVentas_TDCompTesoreria != null)
                    {
                        mz.erp.dataaccess.tsa_CuentasCondicionesDeVenta_TDCompTesoreria.Update(_dataCuentas_CondicionesDeVentas_TDCompTesoreria.tsa_CuentasCondicionesDeVenta_TDCompTesoreria, trx);
                    }
                    if (_dataTiposDeComprobantes_CondicionesDeVentas_TDCompTesoreria != null)
                    {
                        mz.erp.dataaccess.Tsy_TiposDeComprobantes_CondicionesDeVenta_TDCompTesoreria.Update(_dataTiposDeComprobantes_CondicionesDeVentas_TDCompTesoreria.Tsy_TiposDeComprobantes_CondicionesDeVenta_TDCompTesoreria, trx);
                    }
                    Variables.Reset();                     //reinicia las variables;
                    MAPStaticInfo.Reset();
                    trx.Commit();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message.ToString());
                    trx.Rollback();
                }
                finally
                {
                    cnx.Close();
                }
            }
        }
예제 #11
0
 /// <summary>
 /// Establece los valores por defecto de tfi_TDCompTesoreriaRow.
 /// </summary>
 public static tfi_TDCompTesoreriaDataset.tfi_TDCompTesoreriaRow SetRowDefaultValues(tfi_TDCompTesoreriaDataset.tfi_TDCompTesoreriaRow row)
 {
     row.IdTDCompTesoreria  = Util.NewStringId();
     row.Descripcion        = string.Empty;
     row.Sistema            = false;
     row.Agrupado           = false;
     row.FechaCreacion      = mz.erp.businessrules.Sistema.DateTime.Now;
     row.IdConexionCreacion = Security.IdConexion;
     //row.UltimaModificacion = null;
     row.IdConexionUltimaModificacion = Security.IdConexion;
     row.IdReservado = 0;
     row.RowId       = Guid.Empty;
     row.IdEmpresa   = Security.IdEmpresa;
     row.IdSucursal  = Security.IdSucursal;
     row.Cuotas      = 1;
     row.Activo      = true;
     return(row);
 }