コード例 #1
0
        /// <summary>
        /// Deletes CurrEntry in Table and Data
        /// </summary>
        private void DeleteCurrEntry()
        {
            GetCurrEntry();

            if (IdInput.Text != "" && AmountInput.Text != "" && OnTheHouseInput.Text != "" && NumInput.Text != "")
            {
                bool suc = false; //to stop the loop
                foreach (Day d in Buchhaltung.CurrWeek.DaysInWeek)
                {
                    if (d.Name == Buchhaltung.CurrDay)
                    {
                        for (int i = 0; i < d.Entrys.Count; i++)
                        {
                            //compares the original entry with the entrys in the mainProgramm
                            if (_originalEntry.ProductForEntry.Id == (d.Entrys[i].ProductForEntry.Id) &&
                                _originalEntry.Amount == (d.Entrys[i].Amount))
                            {
                                d.Entrys.RemoveAt(i);
                                suc = true;
                                break;
                            }
                        }
                    }

                    if (suc)
                    {
                        break;
                    }
                }

                Buchhaltung.SaveEntrys();
                Close();
            }
        }
コード例 #2
0
        /// <summary>
        /// Edits data In Table and Data
        /// </summary>
        private void EditDataAndSave()
        {
            if (IdInput.Text != "" && AmountInput.Text != "" && OnTheHouseInput.Text != "" && NumInput.Text != "")
            {
                bool stopIt = false; //to stop the loop
                try
                {
                    foreach (Day dummy in Buchhaltung.CurrWeek.DaysInWeek)
                    {
                        foreach (Product t in Buchhaltung.Products)
                        {
                            if (IdInput.Text == Convert.ToString(t.Id)) //Checks the id of the product
                            {
                                //Gives the newEntry the correct information
                                Product pNew = t;
                                _newEntry.ProductForEntry  = pNew;
                                _newEntry.Amount           = Convert.ToInt32(AmountInput.Text);
                                _newEntry.AmountOnTheHouse = Convert.ToInt32(OnTheHouseInput.Text);
                                _newEntry.Price            = _originalEntry.Amount * _originalEntry.ProductForEntry.Price;
                                stopIt = true;
                                break;
                            }
                        }

                        if (stopIt) //stopsLoop
                        {
                            break;
                        }
                    }

                    OverridesEntryInMainProgramm();
                    Buchhaltung.SaveEntrys();
                    Close();
                }
                catch (Exception e)
                {
                    Buchhaltung.Log(e.Message);
                    Buchhaltung.SaveErrorMsg(e);
                }
            }
            else
            {
                Buchhaltung.Log("Es wurden Felder leer gelassen!");
            }
        }
コード例 #3
0
        /// <summary>
        /// Saves Entry
        /// </summary>
        private void SaveEntry()
        {
            try
            {
                foreach (Product p in Buchhaltung.Products)
                {
                    if (p.Id != Convert.ToInt32(InputId.Text))
                    {
                        continue;
                    }
                    Entry e;
                    int   actualAmount = 0;
                    if (InputAmountOnTheHouse.Text == "")
                    {
                        actualAmount = Convert.ToInt32(InputAmount.Text);
                        e            = new Entry(p, actualAmount, 0, _priceInUse);
                    }
                    else
                    {
                        actualAmount =
                            Convert.ToInt32(Convert.ToInt32(InputAmount.Text) +
                                            Convert.ToInt32(InputAmountOnTheHouse.Text));
                        e = new Entry(p, actualAmount, Convert.ToInt32(InputAmountOnTheHouse.Text), _priceInUse);
                    }

                    //Adds at the currentWeek and the current Day the entry
                    Buchhaltung.CurrWeek.GetCurrentDayAndAddEntry(e);
                    break;
                }
            }
            catch (Exception e)
            {
                Buchhaltung.Log(e.Message);
                Buchhaltung.SaveErrorMsg(e);
            }
            finally
            {
                Buchhaltung.SaveEntrys();
            }
        }