Пример #1
0
        /// <summary>
        /// Fügt dem Datagrid eine neue Zeile mit einem Einkommen hinzu, welches editiert werden kann.
        /// Anschließend erfolgt ein Commit und ein Refresh.
        /// 
        /// Author: Antonios Fesenmeier
        /// </summary>
        private void addNewRev()
        {
            IEnumerable<DB.RevenueType> revTypes = DB.RevenueType.GetRevenueTypes();

            var types = revTypes.ToList();
            var cbItems = types.ToList().Select(n => new CBItem
            {
                Name = n.Name
            });
            List<CBItem> tmpRevTypes = new List<CBItem>();
            tmpRevTypes.Add(null);

            foreach (CBItem cI in cbItems)
            {
                tmpRevTypes.Add(cI);
            }

            DateTime defaultDate = DateTime.Today;

            RevenueModel newRev = new RevenueModel();
            newRev.revType = tmpRevTypes;
            newRev.revDescription = "";
            newRev.revStartDate = defaultDate;
            newRev.revEndDate = defaultDate;
            newRev.revAmount = "0";
            newRev.isAdded = false;

            this._Revenues.Add(newRev);
            dtgRevenue2.ItemsSource = this._Revenues;

            dtgRevenue2.CommitEdit();
            dtgRevenue2.Items.Refresh();
        }
Пример #2
0
        public void fillRevenuesDataGrid(IEnumerable<Revenue> revenues)
        {
            //Bisheriger Gesamtbetrag
            double amount = 0;

            IEnumerable<DB.RevenueType> revTypes = DB.RevenueType.GetRevenueTypes();

            // Combobox mit den RevenueTypes befüllen!
            var types = revTypes.ToList();
            var cbItems = types.ToList().Select(n => new CBItem
            {
                Name = n.Name
            });

            List<CBItem> tmpRevTypes = new List<CBItem>();
            tmpRevTypes.Add(null);

            foreach (CBItem cI in cbItems)
            {
                tmpRevTypes.Add(cI);
            }

            DateTime defaultDate = DateTime.Today;
            //DB.RevenueDetail revDetail = new RevenueDetail();
            //revDetail.Amount = 0;
            //revDetail.EndDate = defaultDate;
            //revDetail.StartDate = defaultDate;

            //vorhandene Revenues eintragen

            foreach (Revenue rev in revenues)
            {
                //Combobox individuell füllen Selektiertes zuerst.

                List<CBItem> existingRevType = new List<CBItem>();

                foreach (CBItem cI in cbItems)
                {
                    if (cI.Name == rev.RevenueType.Name)
                        existingRevType.Add(cI);
                }

                foreach (CBItem cI in cbItems)
                {
                    if (cI.Name != rev.RevenueType.Name)
                        existingRevType.Add(cI);
                }

                RevenueModel existingRev = new RevenueModel();
                existingRev.revType = existingRevType;
                existingRev.revDescription = rev.Description;
                existingRev.revAmount = rev.Amount.ToString();
                amount += rev.Amount;
                existingRev.isAdded = true;
                existingRev.revStartDate = rev.StartDate;
                existingRev.revEndDate = (DateTime)rev.EndDate;
                existingRev.revenueID = rev.RevenueID;

                this._Revenues.Add(existingRev);

            }

            //eine Neue Zeile hinzufügen
            RevenueModel newRev = new RevenueModel();
            newRev.revType = tmpRevTypes;
            newRev.revDescription = "";
            newRev.revStartDate = defaultDate;
            newRev.revEndDate = defaultDate;
            newRev.revenueID = 0;
            newRev.revAmount = "0";
            newRev.isAdded = false;

            this._Revenues.Add(newRev);
            dtgRevenue2.Items.Refresh();
            dtgRevenue2.ItemsSource = this._Revenues;
            dtgRevenue2.Items.Refresh();

            //Gesamtbetrag vorbelegen
            lblAmount.Content = SafeStringParser.safeParseToMoney(amount, true);
        }