Beispiel #1
0
        public void Save()
        {
            if (BankAccount != null)
            {
                //stop Entity Framework from trying to save/insert child objects?
                var items = BankAccounts.ToList();
                for (int i = 0; i < items.Count; i++)
                {
                    if (items[i].Bank != null)
                    {
                        _uow.Entry(items[i].Bank).State = EntityState.Detached;
                    }
                    if (items[i].AccountType != null)
                    {
                        _uow.Entry(items[i].AccountType).State = EntityState.Detached;
                    }
                    if (items[i].CurrencyType != null)
                    {
                        _uow.Entry(items[i].CurrencyType).State = EntityState.Detached;
                    }
                }
            }



            var x = _uow.SaveChanges();
        }
        public async Task <Customer> UpdateCustomerAsync(Customer customer)
        {
            if (!_context.Customers.Local.Any(c => c.Id == customer.Id))
            {
                _context.Customers.Attach(customer);
            }
            _context.Entry(customer).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(customer);
        }
        public async Task <Company> UpdateCompanyAsync(Company company)
        {
            //CultureInfo us = new CultureInfo("en-us");
            //var cmd = $"EXEC Company_Update @CompanyId = {company.CompanyId}," +
            //    $" @DateRegistration = '{company.DateRegistration.ToString(us)}'," +
            //    $" @RegistrationNumber =N'{company.RegistrationNumber}'," +
            //    $" @EconomicalNumber = N'{company.EconomicalNumber}'," +
            //    $" @City = N'{company.City}'," +
            //    $" @Province = N'{company.Province}'," +
            //    $" @Town = N'{company.Town}'," +
            //    $" @PostalCode = {company.PostalCode}," +

            //    $" @PhoneManager = N'{company.PhoneManager}'," +
            //    $" @ManagerName = N'{company.ManagerName}'," +
            //    $" @Phone1 = N'{company.Phone1}'," +
            //    $" @Phone2 = N'{company.Phone2}'," +
            //    $" @Phone3 = N'{company.Phone3}'," +

            //    $" @Address = N'{company.Address}'," +
            //    $" @WebSite = N'{company.WebSite}'," +
            //    $" @LatinName = N'{company.LatinName}'," +
            //    $" @FirstAccountBalance = {company.FirstAccountBalance}," +
            //    $" @Fax = {company.Fax}," +
            //    $" @Logo = N'{company.Logo}'";

            //await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(company).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(company);
        }
Beispiel #4
0
        public async Task <DL> UpdateDLAsync(DL dL)
        {
            _uow.Entry(dL).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            //var cmd = $"UPDATE [dbo].[DLs] SET[DLType] = { (int)dL.DLType}" +
            //    $",[DLCode] = {dL.DLCode}," +
            //    $"[Title] = N'{dL.Title}'," +
            //    $"[Title2] =N'{dL.Title2}'," +
            //    $"[Status] = {Convert.ToInt16(dL.Status)}," +
            //    $"[DLAccountsNature] = N'{(int)dL.DLAccountsNature}'," +
            //    $"WHERE([DLId] ={ dL.DLId}";
            //var cmd = $"EXEC DL_Update " +
            //    $"@DLId = {dL.DLId}," +
            //  $" @DLCode = {dL.DLCode}," +
            //  $" @DLType =N' {(int)dL.DLType}'," +
            //  $" @Title = N'{dL.Title}'," +
            //  $" @Title2 = N'{dL.Title2}'," +
            //  $" @DLAccountsNature = N'{(int)dL.DLAccountsNature}'," +
            //  $" @Status = {Convert.ToInt16(dL.Status)}";
            //$" @Customer = {Convert.ToInt16(dL.Customer)},"+
            //$" @Personnel = {Convert.ToInt16(dL.Personnel)},"+
            //$" @Buyer = {Convert.ToInt16(dL.Buyer)}";
            //  await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            return(dL);
        }
        public async Task <Person> UpdatePersonAsync(Person person)
        {
            //CultureInfo us = new CultureInfo("en-us");
            //var cmd = $"EXEC Person_Update @PersonId = {person.PersonId}," +
            // $" @NationalCode = {person.NationalCode}," +
            // $" @CertificateNumber = {person.CertificateNumber}," +
            // $" @BirthDate = '{person.BirthDate.ToString(us)}'," +
            // $" @FatherName = N'{person.FatherName}'," +
            // $" @NumberOfChildren = {person.NumberOfChildren}," +

            // $" @PostalCode = {person.PostalCode}," +
            // $" @BirthPlace = N'{person.BirthPlace}'," +
            // $" @Sexuality = N'{person.Sexuality}'," +
            // $" @CertificatePlace = N'{person.CertificatePlace}'," +
            // $" @CertificateSeries = N'{person.CertificateSeries}'," +
            // $" @WebSite = N'{person.WebSite}'," +
            // $" @Address = N'{person.Address}'," +
            // $" @Address2 = N'{person.Address2}'," +
            //  $" @FirstAccountBalance = {person.FirstAccountBalance}," +
            // $" @Fax = {person.Fax}," +
            // $" @Logo = N'{person.Logo}'";
            //await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(person).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(person);
        }
        public void SetAccDocumentHeader(AccDocumentHeader accDocumentHeader)
        {
            testAccDocumentHeader = accDocumentHeader;
            _uow.AccDocumentHeaders.Attach(testAccDocumentHeader);
            var test = _uow.Entry(testAccDocumentHeader).State;

            if (EditMode == false)
            {
                AccDocumentItemListViewModel.AccDocumentItems = new ObservableCollection <EditableAccDocumentItem>();
            }

            AccDocumentHeader = Mapper.Map <AccDocumentHeader, EditableAccDocumentHeader>(accDocumentHeader);
            AccDocumentHeader.PropertyChanging   += AccDocumentHeader_PropertyChanging;
            AccDocumentHeader.PropertyChanged    += AccDocumentHeader_PropertyChanged;
            AccDocumentHeader.ValidationDelegate += AccDocumentHeader_ValidationDelegate;

            AccDocumentHeader.ErrorsChanged += RaiseCanExecuteChanged;
        }
Beispiel #7
0
        public async Task <DLType> UpdateDLTypeAsync(DLType dLType)
        {
            //  _uow.DLs.Attach();
            // await _uow.SaveChangesAsync().ConfigureAwait(false);
            _uow.Entry(dLType).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(dLType);
        }
Beispiel #8
0
        public async Task <Group> UpdateGroupAsync(Group group)
        {
            //var cmd = $"EXEC Group_Update @GroupId = {group.GroupId}, @YearName = N'{group.Name}'";
            //await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(group).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(group);
        }
        public async Task <AccountType> UpdateAccountTypeAsync(AccountType accountType)
        {
            //var cmd = $"EXEC AccountType_Update @AccountTypeId = {accountType.AccountTypeId}," +
            //    $" @AccountTypeTitle = N'{accountType.AccountTypeTitle}'";
            //await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(accountType).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(accountType);
        }
Beispiel #10
0
        public async Task <Product> UpdateProductAsync(Product product)
        {
            //      var cmd = $"EXEC Product_Update @ProductId = {product.ProductId}," +
            //$" @ProductTitle = N'{product.ProductTitle}'";
            //      await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(product).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(product);
        }
Beispiel #11
0
        public async Task <TypeDocument> UpdateTypeDocumentAsync(TypeDocument typeDocument)
        {
            //    var cmd = $"EXEC TypeDocument_Update @TypeDocumentId = {typeDocument.TypeDocumentId}," +
            //$" @TypeDocumentTitle = N'{typeDocument.TypeDocumentTitle}'";
            //    await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(typeDocument).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(typeDocument);
        }
Beispiel #12
0
        public async Task <AccDocumentItem> UpdateAccDocumentItemAsync(AccDocumentItem accDocumentItem)
        {
            //      var cmd = $"EXEC AccDocumentItem_Update @AccDocumentItemId = {accDocumentItem.AccDocumentItemId},";
            ///*  $" @AccDocumentItemTitle = N'{accDocumentItem.AccDocumentItemTitle}'"*/;
            //      await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(accDocumentItem).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(accDocumentItem);
        }
        public async Task <SelectAgent> UpdateSelectAgentAsync(SelectAgent selectAgent)
        {
            //    var cmd = $"EXEC SelectAgent_Update @SelectAgentId = {selectAgent.SelectAgentId}," +
            //$" @SelectAgentTitle = N'{selectAgent.SelectAgentTitle}'";
            //    await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(selectAgent).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(selectAgent);
        }
        public async Task <DLAccountsNature> UpdateDLAccountsNatureAsync(DLAccountsNature dLAccountsNature)
        {
            //var cmd = $"EXEC DLAccountsNature_Update @DLAccountsNatureId = {dLAccountsNature.DLAccountsNatureId}," +
            //  $" @DLAccountsNatureTitle =N' {dLAccountsNature.DLAccountsNatureTitle}'";

            //await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(dLAccountsNature).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(dLAccountsNature);
        }
        public async Task <BankType> UpdateBankTypeAsync(BankType bankType)
        {
            //var cmd = $"EXEC BankType_Update @BankTypeId = {bankType.BankTypeId}," +
            //$" @BankTypeTitle=N'{bankType.BankTypeTitle}'";

            //await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(bankType).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(bankType);
        }
Beispiel #16
0
        public void SaveChanges(EditableAccDocumentHeader selectedHeader)
        {
            var existingParent = _uow.AccDocumentHeaders
                                 .Where(p => p.AccDocumentHeaderId == selectedHeader.AccDocumentHeaderId)
                                 .Include(p => p.AccDocumentItems)
                                 .SingleOrDefault();

            if (existingParent != null)
            {
                // Update parent
                _uow.Entry(existingParent).CurrentValues.SetValues(selectedHeader);

                // Delete AccDocumentItems
                //foreach (var existingChild in existingParent.AccDocumentItems.ToList())
                //{
                //    if (!selectedHeader.AccDocumentItems.Any(c => c.AccDocumentItemId == existingChild.AccDocumentItemId))
                //        _uow.AccDocumentItems.Remove(existingChild);
                //}


                //// Update and Insert AccDocumentItems
                //foreach (var childModel in selectedHeader.AccDocumentItems)
                //{
                //    var existingChild = existingParent.AccDocumentItems
                //        .SingleOrDefault(c => c.AccDocumentItemId == childModel.AccDocumentItemId);

                //    if (existingChild != null)
                //        // Update child
                //        _uow.Entry(existingChild).CurrentValues.SetValues(childModel);
                //    else
                //    {
                //        // Insert child
                //        var newChild = new AccDocumentItem
                //        {
                //            SLId = childModel.SLId,
                //            DL1Id = childModel.DL1Id,
                //            DL2Id = childModel.DL2Id
                //            ,
                //            Debit = childModel.Debit,
                //            Credit = childModel.Credit,
                //            Description1 = childModel.Description1,
                //            Description2 = childModel.Description2
                //        };// AutoMapper.Mapper.Map<EditableAccDocumentItem, AccDocumentItem>(childModel);// new AccDocumentItem
                //          //{
                //          //    //Data = childModel.Data,
                //          //    ////...
                //          //};
                //        existingParent.AccDocumentItems.Add(newChild);
                //    }
                //}

                _uow.SaveChanges();
            }
        }
Beispiel #17
0
        public async Task <Style> UpdateStyleAsync(Style style)
        {
            //var cmd = $"EXEC Style_Update @StyleId = {style.StyleId}," +
            //   $" @StyleTitle = N'{style.StyleTitle}'";

            //await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(style).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(style);
        }
Beispiel #18
0
        public async Task <Property> UpdatePropertyAsync(Property property)
        {
            _uow.Entry(property).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            //var cmd = $"EXEC Property_Update @PropertyId = {property.PropertyId}," +
            //$" @PropertyTitle=N'{property.PropertyTitle}'";

            //await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);

            return(property);
        }
        public async Task <Bank> UpdateBankAsync(Bank bank)
        {
            //var cmd = $"EXEC Bank_Update @BankId = {bank.BankId}," +
            //    $" @BankName = N'{bank.BankName}'," +
            //    $" @BankName2 = N'{bank.BankName2}'," +
            //    $" @BankTypeId = N'{bank.BankTypeId}'";
            //await _uow.Database.ExecuteSqlCommandAsync(cmd);
            _uow.Entry(bank).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(bank);
        }
Beispiel #20
0
        public async Task <SLStandardDescription> UpdateSLStandardDescriptionAsync(SLStandardDescription sLStandardDescription)
        {
            _uow.Entry(sLStandardDescription).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            //var cmd = $"EXEC SLStandardDescription_Update @SLStandardDescriptionId = {sLStandardDescription.SLStandardDescriptionId}," +
            //$" @SLStandardDescriptionTitle = N'{sLStandardDescription.SLStandardDescriptionTitle}'";

            //await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);

            return(sLStandardDescription);
        }
Beispiel #21
0
        public async Task <AccDocumentHeader> UpdateAccDocumentHeaderAsync(AccDocumentHeader accDocumentHeader)
        {
            //    CultureInfo us = new CultureInfo("en-us");

            //    var cmd = $"EXEC AccDocumentHeader_Update @AccDocumentHeaderId = {accDocumentHeader.AccDocumentHeaderId}," +
            //$" @DocumentNumber = {accDocumentHeader.DocumentNumber}," +
            // $" @DailyNumber = {accDocumentHeader.DailyNumber}," +
            // $" @SystemFixNumber = {accDocumentHeader.SystemFixNumber}," +
            // $" @DocumentDate = '{accDocumentHeader.DocumentDate.ToString(us)}'," +
            // $" @SystemName = N'{accDocumentHeader.SystemName}'," +
            // $" @Exporter = N'{accDocumentHeader.Exporter}'," +
            // $" @Seconder = N'{accDocumentHeader.Seconder}'," +
            // $" @HeaderDescription = N'{accDocumentHeader.HeaderDescription}'," +
            // $" @ManualDocumentNumber = {accDocumentHeader.ManualDocumentNumber}," +
            // $" @BaseDocument = N'{accDocumentHeader.BaseDocument}'," +
            // $" @Seconder = N'{accDocumentHeader.Seconder}'," +
            // $" @TypeDocumentId = {accDocumentHeader.TypeDocumentId}," +
            // $" @DocumentHistory = N'{accDocumentHeader.DocumentHistory}'," +
            // $" @Attachment = N'{accDocumentHeader.Attachment}'," +
            // $" @Status = {Convert.ToInt16(accDocumentHeader.Status)}";
            //    await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(accDocumentHeader).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(accDocumentHeader);
        }
        public async Task <TreeAccount> UpdateTreeAccountAsync(TreeAccount treeAccount)
        {
            //var cmd = $"EXEC TreeAccount_Update @TreeAccountId = {treeAccount.TreeAccountId}," +
            //   $" @GroupCode = {treeAccount.GroupCode}," +
            //   $" @GroupName =N' {treeAccount.GroupName}'," +
            //   $" @TreeAccountType = N'{treeAccount.TreeAccountType}'" ;

            //await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(treeAccount).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(treeAccount);
        }
        public async Task <RelatedPerson> UpdateRelatedPersonAsync(RelatedPerson relatedPerson)
        {
            //var cmd = $"EXEC RelatedPerson_Update @RelatedPersonId = {relatedPerson.RelatedPersonId}," +
            //$" @Name = N'{relatedPerson.Name}',"+
            //$" @Family = N'{relatedPerson.Family}',"+
            //$" @Phone = N'{relatedPerson.Phone}'";

            //await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(relatedPerson).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(relatedPerson);
        }
        public async Task <TL> UpdateTLAsync(TL tL)
        {
            _uow.Entry(tL).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            //   var cmd = $"EXEC TL_Update @TLId = {tL.TLId}," +
            //$" @GLId = {(object)tL.GLId ?? "null"}," +
            //$" @TLCode = {tL.TLCode}," +
            //$" @Title = N'{tL.Title}'," +
            //$" @Title2 = N'{tL.Title2}'," +
            //$" @Status = {Convert.ToInt16(tL.Status)}";
            //   await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            return(tL);
        }
        public async Task <AccountDocument> UpdateAccountDocumentAsync(AccountDocument accountDocument)
        {
            //if (!_uow.Set<AccountDocument>().Local.Any(c => c.AccountDocumentId == accountDocument.AccountDocumentId))
            //{
            //_uow.Set<AccountDocument>().Attach(accountDocument);
            ////}
            ////_uow.Entry(accountDocument).State = EntityState.Modified;
            //await _uow.SaveChangesAsync();
            //      var cmd = $"EXEC AccountDocument_Update @AccountDocumentId = {accountDocument.AccountDocumentId}," +
            //$" @AccountDocumentTitle = N'{accountDocument.AccountDocumentTitle}'";
            //      await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(accountDocument).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(accountDocument);
        }
        public async Task <ExchangeRate> UpdateExchangeRateAsync(ExchangeRate exchangeRate)
        {
            //CultureInfo us = new CultureInfo("en-us");

            //var cmd = $"EXEC ExchangeRate_Update @ExchangeRateId = {exchangeRate.ExchangeRateId}," +
            //$" @CurrencyId = {(object)exchangeRate.CurrencyId ?? "null"} ," +
            //$" @EffectiveDate =N' {exchangeRate.EffectiveDate.ToString(us)}'," +
            //$" @ParityRate = {exchangeRate.ParityRate}," +
            //$" @Description = N'{exchangeRate.Description}',"+
            //$" @ExchangeUnitId = {(object)exchangeRate.ExchangeUnitId ?? "null"} ";
            //await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(exchangeRate).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(exchangeRate);
        }
        public async Task <DocumentNumbering> UpdateDocumentNumberingAsync(DocumentNumbering documentNumbering)
        {
            //var cmd = $"EXEC DocumentNumbering_Update @DocumentNumberingId = {documentNumbering.DocumentNumberingId}," +
            // $" @AccountDocumentId = {documentNumbering.AccountDocumentId}," +
            // $" @CountingWayId = {documentNumbering.CountingWayId}," +
            // $" @StartNumber = {documentNumbering.StartNumber}," +
            // $" @EndNumber = {documentNumbering.EndNumber}," +
            // $" @StyleId = {documentNumbering.StyleId}";


            //await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(documentNumbering).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(documentNumbering);
        }
Beispiel #28
0
        public void Save()
        {
            var SelectedStocks = Stocks.Where(x => x.IsSelected == true);

            Product.Stocks.Clear();
            foreach (var stock in SelectedStocks)
            {
                //if (!Product.Stocks.Any(x => x.StockId == stock.StockId))
                Product.Stocks.Add(stock);
                //else
                //    Product.Stocks.Add(stock);
            }
            var ss = _uow.Entry <Product>(Product).State;

            _uow.SaveChanges();
        }
        public async Task <CountingWay> UpdateCountingWayAsync(CountingWay countingWay)
        {
            //if (!_uow.Set<CountingWay>().Local.Any(c => c.CountingWayId == countingWay.CountingWayId))
            ////{
            //_uow.Set<CountingWay>().Attach(countingWay);
            ////}
            ////_uow.Entry(countingWay).State = EntityState.Modified;
            //await _uow.SaveChangesAsync();
            //var cmd = $"EXEC CountingWay_Update @CountingWayId = {countingWay.CountingWayId}," +
            //   $" @CountingWayTitle = N'{countingWay.CountingWayTitle}'";

            //await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(countingWay).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(countingWay);
        }
Beispiel #30
0
        public async Task <GL> UpdateGLAsync(GL gL)
        {
            //var cmd = $"EXEC GL_Update @GLId = {gL.GLId}," +
            //$" @AccountGLEnum={(int)gL.AccountGLEnum}," +
            //$" @GLCode = {gL.GLCode}," +
            //$" @Title = N'{gL.Title}'," +
            //$" @Title2 = N'{gL.Title2}'," +
            //$" @Status = {Convert.ToInt16(gL.Status)} ";

            //;

            //await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(gL).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(gL);
        }