Example #1
0
        public async Task <IEnumerable <int> > GetIdsApuntesCuentaAsync(CuentaMayor cuenta)
        {
            bool sphrWaiting = true; //The semaphore will be relased in the using block, if it doesn't get released, the method won't wait for it again after the using
            await base._RepoSphr.WaitAsync();

            base.CurrentCdadOwner = cuenta.IdOwnerComunidad;
            base.CurrentEjerOwner = cuenta.IdOwnerEjercicio;

            IEnumerable <int> ids;

            using (SqlConnection con = new SqlConnection(this._strCon))
            {
                await con.OpenAsync().ConfigureAwait(false);

                QueryBuilder qBuilder = ((IRepositoryDependent <CuentaMayor>) this).GetIdsDependentByMasterSelectSQL(cuenta.Id);
                base._RepoSphr.Release();

                ids = await con.QueryAsync <int>(qBuilder.Query, qBuilder.Parameters).ConfigureAwait(false);

                con.Close();
            }

            if (!sphrWaiting)
            {
                base._RepoSphr.Release();
            }

            return(ids);
        }
Example #2
0
        //TODO cuando se crea un record en la tabla de cuentas contables hay que terminar de rellenar datos (importante: nombres de las cuentas)
        public override void CreateTable(string tableName, string cod, CuentaMayor acc)
        {
            //Create account table
            string command = this.CreateCmd;

            command = command.Remove(this._TypeNameIndex, this._TypeNameLength);
            command = command.Insert(this._TypeNameIndex, tableName);

            this.ExecuteNonQuery(command);

            //Update cdad's list(table) of accounts with the new table, create it if no exist
            TableCreateCmds Tcc           = new TableCreateCmds();
            string          accountsTable = "C" + cod + Tcc.TableTypeNames[(int)TableType.CuentasC];

            if (!base.ExistsTableInDB(accountsTable))
            {
                command = Tcc[TableType.CuentasC];
                command = command.Remove(this._TypeNameIndex, this._TypeNameLength);
                command = command.Insert(this._TypeNameIndex, accountsTable);

                this.ExecuteNonQuery(command);
            }

            //TODO faltan nombres de las cuentas
            this.ExecuteNonQuery(string.Format("INSERT INTO {0} (CodigoCuenta, Grupo, Subgrupo, Sufijo, Nombre) VALUES ({1},{2},{3},{4},'{5}')",
                                               accountsTable,
                                               acc.Id,
                                               acc.Grupo,
                                               acc.Subgrupo,
                                               acc.Sufijo,
                                               acc.Nombre));
        }
Example #3
0
        public void IngresaCuentaMayor(EntityConnectionStringBuilder connection, CuentaMayor cm)
        {
            var context = new samEntities(connection.ToString());

            context.INSERT_cuenta_mayor_MDL(cm.SAKNR,
                                            cm.KTOPL,
                                            cm.TXT50_ES,
                                            cm.TXT50_EN);
        }
Example #4
0
        public bool TryRemoveCuenta(ref CuentaMayor cuenta, string nombreParaPresupuesto, decimal saldoCuenta)
        {
            var c = new CuentaParaPresupuesto(cuenta, nombreParaPresupuesto, saldoCuenta);

            if (!this._Cuentas.Contains(c))
            {
                return(false);
            }

            this._Cuentas.RemoveAt(this._Cuentas.IndexOf(c));
            this._Importe -= saldoCuenta;
            return(true);
        }
Example #5
0
        public bool TryAddCuenta(ref CuentaMayor cuenta, string nombreParaPresupuesto, decimal saldoCuenta)
        {
            var c = new CuentaParaPresupuesto(cuenta, nombreParaPresupuesto, saldoCuenta);

            if (this._Cuentas.Contains(c))
            {
                return(false);
            }

            this._Cuentas.Add(c);
            this._Importe += saldoCuenta;
            return(true);
        }
Example #6
0
        public void InsertarCuentaM(EntityConnectionStringBuilder connection, CuentaMayor m)
        {
            var context = new samEntities(connection.ToString());

            context.INSERT_cuenta_mayor_MDL1(m.SAKNR,
                                             m.KTOPL,
                                             m.TXT50_ES,
                                             m.TXT50_EN);
            //context.INSERT_cuenta_mayor_MDL(m.SAKNR,
            //                                m.KTOPL,
            //                                m.TXT50_ES,
            //                                m.TXT50_EN);
        }
Example #7
0
        public TabMayorModel(int cod)
        {
            this._DTable = new DataTable();
            string tableName = string.Format("C{0}Cuen{1}",
                                             cod.ToString(),
                                             GlobalSettings.Properties.Settings.Default.CUENTADEFAULT);

            this._CurrentAccount = CuentaMayor.GetCuentaDefault();

            if (!base.ExistsTableInDB(tableName))
            {
                base.CreateTable(tableName, cod.ToString(), this.CurrentAccount);
            }

            string SQLcmd = string.Format("{0} {1} {2}",
                                          GlobalSettings.Properties.Settings.Default.SELECTMAYOR,
                                          tableName,
                                          GlobalSettings.Properties.Settings.Default.ORDERMAYOR);

            base.SetDataTableByCommand(SQLcmd, ref this._DTable);
            this.UpdateMinMaxAccs(cod);
            this.DView = this.DTable.DefaultView;
        }
Example #8
0
        public async Task <List <Asiento> > GetTodosAsientosCuentaAsync(CuentaMayor cuenta)
        {
            await base._RepoSphr.WaitAsync();

            base.CurrentCdadOwner = cuenta.IdOwnerComunidad;
            base.CurrentEjerOwner = cuenta.IdOwnerEjercicio;

            IEnumerable <int> ids;

            using (SqlConnection con = new SqlConnection(this._strCon))
            {
                await con.OpenAsync().ConfigureAwait(false);

                QueryBuilder qBuilder = ((IRepositoryDependent <CuentaMayor>) this).GetIdsDependentByMasterSelectSQL(cuenta.Id);

                ids = await con.QueryAsync <int>(qBuilder.Query, qBuilder.Parameters).ConfigureAwait(false);

                con.Close();
            }

            //Remove currently existent objects
            if (this._CuentaDependenciesDict.ContainsKey(cuenta))
            {
                //Más asientos podrían haberse añadido a la misma cuenta
                bool idsAreTheSameThanThoseInDictionary = ids
                                                          .OrderBy(x => x)
                                                          .SequenceEqual(
                    this._CuentaDependenciesDict[cuenta]
                    .OrderBy(x => x));
                //Si no se han añadido más asientos, devuelve los que están ya en el diccionario
                if (idsAreTheSameThanThoseInDictionary)
                {
                    base._RepoSphr.Release();
                    return(this._ObjModels
                           .Where(kvp => ids.Contains(kvp.Key))
                           .Select(kvp => kvp.Value)
                           .ToList());
                }
                //De otra manera coge solo los asientos nuevos que NO están en el diccionario
                ids = ids.Except(this._CuentaDependenciesDict[cuenta]);
            }

            IEnumerable <dynamic> result;

            using (SqlConnection con = new SqlConnection(this._strCon))
            {
                await con.OpenAsync().ConfigureAwait(false);

                QueryBuilder qBuilder = ((IRepositoryDependent <CuentaMayor>) this).GetDependentByMasterSelectSQL(cuenta.Id, ids);

                result = await con.QueryAsync(qBuilder.Query, qBuilder.Parameters).ConfigureAwait(false);

                con.Close();
            }

            List <Asiento> final = await Task.Run(() => this._Mapper.Map <List <Asiento> >(result)).ConfigureAwait(false);

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
            Task.Run(async() =>
            {
                if (!this._CuentaDependenciesDict.ContainsKey(cuenta))
                {
                    this._CuentaDependenciesDict.TryAdd(cuenta, ids.ToList());
                }
                else
                {
                    this._CuentaDependenciesDict[cuenta] = this._CuentaDependenciesDict[cuenta].Union(ids).ToList();
                }

                foreach (Asiento asi in final)
                {
                    this._OriginalObjModels.TryAdd(asi.Id, asi);
                }

                List <Asiento> copy = this._Mapper.Map <List <Asiento> >(result);
                foreach (Asiento asi in copy)
                {
                    this._ObjModels.TryAdd(asi.Id, asi);
                }
            })
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
            .Forget().ConfigureAwait(false);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

            base._RepoSphr.Release();

            return(final);
        }
Example #9
0
 public CuentaParaPresupuesto(CuentaMayor cuenta, string nombre, decimal saldo)
 {
     this.Cuenta = cuenta;
     this.NombreParaPresupuesto = nombre;
     this.SaldoAlAñadirLaCuenta = saldo;
 }
 public virtual void CreateTable(string tableName, string cod, CuentaMayor acc)
 {
     throw new NotImplementedException();
 }