예제 #1
0
 public void EditDetails(string name, string cui, string address)
 {
     //only allow one company to exist
     using (var context = GetContext())
     {
         var existingCompany = context.Companies.FirstOrDefault();
         if (existingCompany == null)
         {
             Company soc = new Company()
             {
                 Id = DbIdHelper.GetNextID(),
                 Adresa = address,
                 Nume = name,
                 CUI = cui
             };
             context.Companies.AddObject(soc);
         }
         else
         {
             existingCompany.Adresa = address;
             existingCompany.Nume = name;
             existingCompany.CUI = cui;
         }
         context.SaveChanges();
     }
 }
 /// <summary>
 /// Create a new Company object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="nume">Initial value of the Nume property.</param>
 /// <param name="adresa">Initial value of the Adresa property.</param>
 /// <param name="cUI">Initial value of the CUI property.</param>
 public static Company CreateCompany(global::System.Int64 id, global::System.String nume, global::System.String adresa, global::System.String cUI)
 {
     Company company = new Company();
     company.Id = id;
     company.Nume = nume;
     company.Adresa = adresa;
     company.CUI = cUI;
     return company;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Companies EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCompanies(Company company)
 {
     base.AddObject("Companies", company);
 }
        public List<ReportPageVM> GetPages(Company company, UserCashBook cashBook, DateTime dateTime, ICashBookRepository cashBookRepository, ICashBookEntryRepository cashBookEntryRepository, int maxEntriesPerPage)
        {
            //maxEntriesPerPage = 13;
            List<ReportPageVM> resultPages = new List<ReportPageVM>();
            try
            {

                this.MaxEntriesPerPage = maxEntriesPerPage;

                var MoneyExchangeRate = cashBookEntryRepository.GetExchangeRateForDay(cashBook.Id, dateTime);

                CashBookEntries = new ObservableCollection<CashBookEntryUI>();
                var tempCashBookEntries = new ObservableCollection<CashBookEntryUI>();

                var existingCashBookEntries = cashBookEntryRepository.GetEntriesForDay(cashBook.Id, dateTime);
                if (existingCashBookEntries != null)
                {
                    foreach (var item in existingCashBookEntries)
                    {
                        tempCashBookEntries.Add((CashBookEntryUI)item);
                    }
                }
                if (tempCashBookEntries.Count == 0)
                {
                    //no report to print for this day, return empty;
                    return resultPages;
                }

                //add incasari
                foreach (var item in tempCashBookEntries)
                {
                    if (item.Incasari != 0)
                    {
                        CashBookEntries.Add((CashBookEntryUI)item);
                    }
                }

                //add payments
                foreach (var item in tempCashBookEntries)
                {
                    if (item.Plati != 0)
                    {
                        CashBookEntries.Add((CashBookEntryUI)item);
                    }
                }
                var ReportTitle = cashBook.IsLei ? "REGISTRU DE CASA in LEI" : "REGISTRU DE CASA in VALUTA";
                var MoneyExchangeRateVisibility = cashBook.IsLei ? Visibility.Collapsed : Visibility.Visible;

                if (!cashBook.IsLei && MoneyExchangeRate.HasValue)
                {
                    foreach (var item in CashBookEntries)
                    {
                        if (item.Incasari != 0)
                        {
                            item.LeiValue = item.Incasari * MoneyExchangeRate.Value;
                        }
                        else
                        {
                            item.LeiValue = item.Plati * MoneyExchangeRate.Value;
                        }
                    }
                }

                var InitialBalanceForDayDecimal = cashBookRepository.GetInitialBalanceForDay(cashBook.Id, dateTime);

                AddExtraDetailsRows(InitialBalanceForDayDecimal, cashBook, MoneyExchangeRate);
                currentPage = 0;
                nrCrt = 1;
                while (HasNextPage())
                {
                    currentPage++;
                    LoadDataForCurrentPage();

                    ReportPageVM newPage = new ReportPageVM()
                    {
                        Company = company,
                        CurrentPageCashBookEntries = CurrentPageCashBookEntries,
                        InitialBalanceForDayDecimal = InitialBalanceForDayDecimal,
                        MoneyExchangeRate = MoneyExchangeRate,
                        MoneyExchangeRateVisibility = MoneyExchangeRateVisibility,
                        PageNumber = PageNumber,
                        ReportTitle = ReportTitle,
                        SelectedCashBook = cashBook,
                        SelectedDate = dateTime,
                    };
                    resultPages.Add(newPage);
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.Log.Error(ex);
            }
            return resultPages;
        }