Esempio n. 1
0
        private void Ok_Click(object sender, RoutedEventArgs e)
        {
            int inputAmount;

            try
            {
                inputAmount = Convert.ToInt32(InputAmount.Text);
            }
            catch (Exception ex)
            {
                Buchhaltung.Log(ex.Message);
                Buchhaltung.SaveErrorMsg(ex);
                inputAmount = -1;
            }

            if (inputAmount > -1 && InputId.Text.Length > 0)
            {
                SaveEntry();
                Close();
            }
            else if (inputAmount != -1)
            {
                MessageBox.Show("Nicht alle Felder wurden korrekt ausgefüllt!");
            }
        }
Esempio n. 2
0
 //Starts the programm with the data needed
 private void StartProgramm()
 {
     try
     {
         if (Convert.ToInt32(WeekNrTextBox.Text) > 0 && Convert.ToInt32(WeekNrTextBox.Text) < 56) //Week in year
         {
             if (File.Exists(@"Data\" + WeekNrTextBox.Text + @".week"))                           //Week does exist
             {
                 Buchhaltung b = new Buchhaltung(WeekNrTextBox.Text);
                 b.Show();
             }
             else
             {
                 string oldCashDeskStr = OldCashDesk.Text;
                 if (oldCashDeskStr.Contains("€"))
                 {
                     oldCashDeskStr = oldCashDeskStr.Replace('€', ' ');
                 }
                 Buchhaltung b = new Buchhaltung(WeekNrTextBox.Text, NameInput.Text, Convert.ToDateTime(DateTextBox.Text), Convert.ToDouble(oldCashDeskStr));
                 MessageBox.Show("Die Woche wurde nicht gefunden! Es wird eine neue erstellt.");
                 b.Show();
             }
             Close();
         }
         else
         {
             Buchhaltung.Log("Ungültige Woche");
         }
     }
     catch (Exception e)
     {
         Buchhaltung.Log(e.Message);
         Buchhaltung.SaveErrorMsg(e);
     }
 }
Esempio n. 3
0
        private void CalcPrice()
        {
            if (InputId.Text.Length <= 0 || InputAmount.Text.Length <= 0)
            {
                return;
            }

            PriceOutput.Text = "Preis: ";
            try
            {
                foreach (Product p in Buchhaltung.Products)
                {
                    if (Convert.ToInt32(InputId.Text) == p.Id)
                    {
                        PriceOutput.Text += "   " + (p.Price * Convert.ToInt32(InputAmount.Text)) + "€";
                        _priceInUse       = p.Price * Convert.ToDouble(InputAmount.Text);
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Buchhaltung.Log(e.Message);
                Buchhaltung.SaveErrorMsg(e);
            }
        }
        //Updates toBank value currDay
        private void okBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (ToBankInput.Text != "")
                {
                    string toBank = ToBankInput.Text;

                    if (toBank.Contains("€"))
                    {
                        toBank = toBank.Replace("€", "");
                    }

                    Buchhaltung.CurrWeek.GetCurrentDay().AddBank(Convert.ToDouble(toBank));

                    Close();
                }
                else
                {
                    Buchhaltung.Log("Felder sind leer!");
                }
            }
            catch (Exception ex)
            {
                Buchhaltung.Log(ex.Message);
                Buchhaltung.SaveErrorMsg(ex);
            }
        }
Esempio n. 5
0
        private void SaveEntry()
        {
            try
            {
                foreach (Product p in Buchhaltung.Products)
                {
                    if (p.Id != Convert.ToInt32(InputId.Text))
                    {
                        continue;
                    }
                    Entry e;
                    if (InputAmountOnTheHouse.Text == "")
                    {
                        _actualAmount = Convert.ToInt32(InputAmount.Text);
                        e             = new Entry(p, _actualAmount, 0, _priceInUse);
                    }
                    else
                    {
                        _actualAmount = Convert.ToInt32(p.Amount * 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);
            }

            Buchhaltung.SaveEntrys();
        }
Esempio n. 6
0
        private void SearchForProduct()
        {
            if (InputId.Text.Length <= 0)
            {
                return;
            }

            ProductOutput.Text = "Produkt:";
            try
            {
                foreach (Product p in Buchhaltung.Products)
                {
                    if (p.Id == Convert.ToInt32(InputId.Text))
                    {
                        ProductOutput.Text += "       " + p.Name;
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Buchhaltung.Log(e.Message);
                Buchhaltung.SaveErrorMsg(e);
            }
        }
Esempio n. 7
0
        private void SaveEntry()
        {
            try
            {
                foreach (Product p in Buchhaltung.products)
                {
                    if (p.ID != Convert.ToInt32(inputID.Text))
                    {
                        continue;
                    }
                    Entry e;
                    if (inputAmountOnTheHouse.Text == "")
                    {
                        // Convert.ToInt32(p.Amount *     Falls Probleme auftreten wieder probieren
                        actualAmount = Convert.ToInt32(inputAmount.Text);
                        e            = new Entry(p, actualAmount, 0, priceInUse);
                    }
                    else
                    {
                        actualAmount = Convert.ToInt32(p.Amount * 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);
            }

            Buchhaltung.SaveEntrys();
        }
 private void StartProgramm()
 {
     try
     {
         if (Convert.ToInt32(weekNrTextBox.Text) > 0 && Convert.ToInt32(weekNrTextBox.Text) < 56)
         {
             if (!File.Exists(@"Data\" + weekNrTextBox.Text + @".week"))
             {
                 MessageBox.Show("Die Woche wurde nicht gefunden! Es wird eine neue erstellt.");
                 using (StreamWriter writer = new StreamWriter(@"Data\" + weekNrTextBox.Text + @".week"))
                 {
                     writer.Write("[monday]\n[tuesday]\n[wednesday]\n[thursday]\n[saturday]\n[sunday]\n[end]");
                 }
             }
             Buchhaltung b = new Buchhaltung(weekNrTextBox.Text);
             b.Show();
             this.Close();
         }
         else
         {
             Buchhaltung.Log("Ungültige Woche");
         }
     }
     catch (Exception e)
     {
         Buchhaltung.Log(e.Message);
         Buchhaltung.SaveErrorMsg(e);
     }
 }
Esempio n. 9
0
        private void SearchFunc(object sender, TextChangedEventArgs e)
        {
            try
            {
                ProductTable.Items.Filter = o =>
                {
                    if (SearchBox.Text == "")
                    {
                        return(true);
                    }
                    using (Product p = o as Product)
                    {
                        if (p != null && p.Id.ToString() == SearchBox.Text.Trim()
                            | (SearchBox.Text.ToLower().Contains((p.Name).ToLower()))
                            | (SearchBox.Text.ToLower().Contains(Convert.ToString(p.Price, CultureInfo.CurrentCulture).ToLower()))
                            | (SearchBox.Text.ToLower().Contains(Convert.ToString(p.Tax).ToLower()))
                            | (p.Name.ToLower().Contains(SearchBox.Text.ToLower()))
                            | (Convert.ToString(p.Price, CultureInfo.CurrentCulture).ToLower().Contains(SearchBox.Text.ToLower()))
                            | (Convert.ToString(p.Tax).ToLower().Contains(SearchBox.Text.ToLower()))
                            | (Convert.ToString(p.KindOfAmount).ToLower().Contains(SearchBox.Text.ToLower())))
                        {
                            return(true);
                        }
                    }

                    return(false);
                };
            }
            catch (Exception ex)
            {
                Buchhaltung.Log(ex.Message + ex.StackTrace);
            }
        }
Esempio n. 10
0
        //Saves the product to Buchhaltung
        public void SaveProduct()
        {
            bool doIt = false;

            try
            {
                string tax = TaxOfProduct.Text, price = PriceOfProduct.Text;
                if (tax.Contains("%"))
                {
                    tax = tax.Replace("%", "");
                }
                if (price.Contains("€"))
                {
                    price = price.Replace("€", "");
                }

                tax   = tax.Trim();
                price = price.Trim();

                double dTax = Convert.ToDouble(tax);

                if (dTax > 0 && dTax < 101)
                {
                    doIt = true;
                }

                //adds the product
                if (Buchhaltung.Products.Max() != null && doIt)
                {
                    Product p = new Product(NameOfTheProdukt.Text, Convert.ToDouble(price), Convert.ToInt32(tax), Convert.ToDouble(AmountOfProduct.Text), KindOfAmount.Text, Buchhaltung.Products.Max().Id);
                    Buchhaltung.Products.Add(p);
                }
                else if (doIt)
                {
                    Product p = new Product(NameOfTheProdukt.Text, Convert.ToDouble(price), Convert.ToInt32(tax), Convert.ToDouble(AmountOfProduct.Text), KindOfAmount.Text, 0);
                    Buchhaltung.Products.Add(p);
                }

                if (doIt)
                {
                    Buchhaltung.SaveProducts();
                    Close();
                }
                else
                {
                    Buchhaltung.Log("Prozente überschritten!");
                }
            }
            catch (Exception e)
            {
                Buchhaltung.Log(e.Message);
                Buchhaltung.SaveErrorMsg(e);
            }
        }
Esempio n. 11
0
 private void okBtn_Click(object sender, RoutedEventArgs e)
 {
     if (NameTextBox.Text != "" && (WeekNrTextBox.Text != "" && Convert.ToInt32(WeekNrTextBox.Text) > 0 && Convert.ToInt32(WeekNrTextBox.Text) < 53) && DateTextBox.Text != "" &&
         OldCashTextBox.Text != "")
     {
         UpdateWeek();
         Close();
     }
     else
     {
         Buchhaltung.Log("Fehlerhafte Eingabe!");
     }
 }
Esempio n. 12
0
 public OutputOfProducts()
 {
     try
     {
         InitializeComponent();
         LoadDataInWpfWindow();
     }
     catch (Exception e)
     {
         Buchhaltung.Log(e.Message);
         Buchhaltung.SaveErrorMsg(e);
     }
     Topmost = true;
 }
Esempio n. 13
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!");
            }
        }
Esempio n. 14
0
        public NewProduct()
        {
            InitializeComponent();
            try
            {
                IdOfProduct.Text += Buchhaltung.Products[Buchhaltung.Products.Count - 1].Id + 1;
            }
            catch (Exception e)
            {
                Buchhaltung.Log(e.Message);
                Buchhaltung.SaveErrorMsg(e);
            }

            LoadProducts();
            LoadTaxDropDown();
            LoadChangeOfAmount();
            Topmost = true;
        }
Esempio n. 15
0
 private void LoadChangeOfAmount()
 {
     try
     {
         for (int i = 0; i < _allProductsSplitted.GetLength(0) - 1; i++)
         {
             if (!KindOfAmoutDropDown.Items.Contains(_allProductsSplitted[i, 5]))
             {
                 KindOfAmoutDropDown.Items.Add(_allProductsSplitted[i, 5]);
             }
         }
     }
     catch (Exception e)
     {
         Buchhaltung.Log(e.Message);
         Buchhaltung.SaveErrorMsg(e);
     }
 }
Esempio n. 16
0
 private void LoadTaxDropDown()
 {
     try
     {
         for (int i = 0; i < _allProductsSplitted.GetLength(0) - 1; i++)
         {
             if (!TaxDropDown.Items.Contains(_allProductsSplitted[i, 3] + "%"))
             {
                 TaxDropDown.Items.Add(_allProductsSplitted[i, 3] + "%");
             }
         }
     }
     catch (Exception e)
     {
         Buchhaltung.Log(e.Message);
         Buchhaltung.SaveErrorMsg(e);
     }
 }
Esempio n. 17
0
 //edits the data
 private void EditDataAndSave()
 {
     if (id_input.Text != "" && amount_input.Text != "" && onTheHouse_input.Text != "" && num_input.Text != "")
     {
         bool stopIt = false; //to stop the loop
         try
         {
             foreach (Day d in Buchhaltung.currWeek.DaysInWeek)
             {
                 Product pNew;
                 for (int i = 0; i < Buchhaltung.products.Count; i++)
                 {
                     if (id_input.Text == Convert.ToString(Buchhaltung.products[i].ID)) //Checks the id of the product
                     {
                         //Gives the newEntry the correct information
                         pNew = Buchhaltung.products[i]; //generates new Product for the entry
                         _newEntry.ProductForEntry  = pNew;
                         _newEntry.Amount           = Convert.ToInt32(amount_input.Text);
                         _newEntry.AmountOnTheHouse = Convert.ToInt32(onTheHouse_input.Text);
                         _newEntry.Price            = _originalEntry.Amount * _originalEntry.ProductForEntry.Price; //schon verhaut
                         stopIt = true;
                         break;
                     }
                 }
                 if (stopIt) //stopsLoop
                 {
                     break;
                 }
             }
             OverridesEntryInMainProgramm();
             Buchhaltung.SaveEntrys();
             this.Close();
         }
         catch (Exception e)
         {
             Buchhaltung.Log(e.Message);
             Buchhaltung.SaveErrorMsg(e);
         }
     }
     else
     {
         Buchhaltung.Log("Es wurden Felder leer gelassen");
     }
 }
Esempio n. 18
0
        /// <summary>
        /// Saves All Data into BackUp path
        /// </summary>
        /// <param name="path"></param>
        private void MakeBackUp(string path)
        {
            try
            {
                for (int i = 0; i < 53; i++)
                {
                    //gets the whole week and saves it
                    if (File.Exists(@"Data\" + i + @".week"))
                    {
                        string text;
                        using (StreamReader reader = new StreamReader(@"Data\" + i + @".week")) //reads the file
                        {
                            text = reader.ReadToEnd();
                        }

                        using (StreamWriter writer = new StreamWriter(path + @"\" + i + @".week", append: false)) //saves the file
                        {
                            writer.Write(text);
                        }
                    }
                }

                //gets the products and saves them
                string textPr;
                using (StreamReader reader = new StreamReader(@"Data\products.p")) //reads the file
                {
                    textPr = reader.ReadToEnd();
                }

                using (StreamWriter writer = new StreamWriter(path + @"\products.p", append: false)) //saves the file
                {
                    writer.Write(textPr);
                }

                MessageBox.Show("BackUp erfolgreich erstellt!");
                Close();
            }
            catch (Exception ex)
            {
                Buchhaltung.Log(ex.Message);
                Buchhaltung.SaveErrorMsg(ex);
            }
        }
 private void SearchFunc(object sender, TextChangedEventArgs e)
 {
     try
     {
         ProductTable.Items.Clear();
         if (SearchBox.Text.Trim() != "")
         {
             //items
             foreach (Product p in Buchhaltung.products.FindAll(p => (p.ID.ToString() == SearchBox.Text.Trim())
                                                                | (SearchBox.Text.ToLower()
                                                                   .Contains((p.Name).ToLower()))
                                                                | (SearchBox.Text.ToLower()
                                                                   .Contains(Convert.ToString(p.Price)
                                                                             .ToLower()))
                                                                | (SearchBox.Text.ToLower()
                                                                   .Contains(Convert.ToString(p.Tax)
                                                                             .ToLower()))
                                                                | (p.Name.ToLower()
                                                                   .Contains(SearchBox.Text.ToLower()))
                                                                | (Convert.ToString(p.Price).ToLower()
                                                                   .Contains(SearchBox.Text.ToLower()))
                                                                | (Convert.ToString(p.Tax).ToLower()
                                                                   .Contains(SearchBox.Text.ToLower()))
                                                                | (Convert.ToString(p.KindOfAmount)
                                                                   .ToLower().Contains(
                                                                       SearchBox.Text.ToLower()))
                                                                )
                      )
             {
                 var data = p;
                 ProductTable.Items.Add(data);
             }
         }
         else
         {
             LoadDataInWpfWindow();
         }
     }
     catch (Exception ex)
     {
         Buchhaltung.Log(ex.Message + ex.StackTrace);
     }
 }
Esempio n. 20
0
        /// <summary>
        /// Update Data
        /// </summary>
        private void UpdateWeek()
        {
            try
            {
                string oldCashDeskStr = (OldCashTextBox.Text);

                if (oldCashDeskStr.Contains("€"))
                {
                    oldCashDeskStr = oldCashDeskStr.Replace("€", "");
                }

                Buchhaltung.CurrWeek.WeekNr        = WeekNrTextBox.Text;
                Buchhaltung.CurrWeek.EditName      = NameTextBox.Text;
                Buchhaltung.CurrWeek.LastChashDesk = Convert.ToDouble(oldCashDeskStr);
                Buchhaltung.CurrWeek.ExactTime     = Convert.ToDateTime(DateTextBox.Text);
            }
            catch (Exception ex)
            {
                Buchhaltung.Log(ex.Message);
                Buchhaltung.SaveErrorMsg(ex);
            }
        }
Esempio n. 21
0
        private static double GetSales()
        {
            try
            {
                double sales = 0;
                foreach (Day d in Buchhaltung.CurrWeek.DaysInWeek)
                {
                    foreach (Entry e in d.Entrys)
                    {
                        sales += e.Price;
                    }
                }

                return(sales);
            }
            catch (Exception ex)
            {
                Buchhaltung.Log(ex.Message);
                Buchhaltung.SaveErrorMsg(ex);
            }

            return(0); //error
        }
Esempio n. 22
0
        //Saves the product to Buchhaltung
        public void SaveProduct()
        {
            try
            {
                string tax = TaxOfProduct.Text, price = PriceOfProduct.Text;
                if (tax.Contains("%"))
                {
                    tax = tax.Replace("%", "");
                }
                if (price.Contains("€"))
                {
                    price = price.Replace("€", "");
                }

                tax   = tax.Trim();
                price = price.Trim();
                //adds the product
                if (Buchhaltung.products.Max() != null)
                {
                    Product p = new Product(NameOfTheProdukt.Text, Convert.ToDouble(price), Convert.ToInt32(tax), Convert.ToDouble(AmountOfProduct.Text), KindOfAmount.Text, Buchhaltung.products.Max().ID);
                    Buchhaltung.products.Add(p);
                }
                else
                {
                    Product p = new Product(NameOfTheProdukt.Text, Convert.ToDouble(price), Convert.ToInt32(tax), Convert.ToDouble(AmountOfProduct.Text), KindOfAmount.Text, 0);
                    Buchhaltung.products.Add(p);
                }
                Buchhaltung.SaveProducts();
                MessageBox.Show("Erfolgreich gespeichert!");
                this.Close();
            }
            catch (Exception e)
            {
                Buchhaltung.Log(e.Message);
                Buchhaltung.SaveErrorMsg(e);
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Checks the input and saves it into Buchhaltung
        /// </summary>
        public void SaveProduct()
        {
            bool taxCheck   = false;
            bool closeCheck = false;

            try
            {
                //removes the % and € symbol from the input
                string tax = TaxOfProduct.Text, price = PriceOfProduct.Text;
                if (tax.Contains("%"))
                {
                    tax = tax.Replace("%", "");
                }
                if (price.Contains("€"))
                {
                    price = price.Replace("€", "");
                }
                if (tax.Contains("."))
                {
                    tax = tax.Replace(".", ",");
                }
                if (price.Contains("."))
                {
                    price = price.Replace(".", ",");
                }

                //trims them down
                tax   = tax.Trim();
                price = price.Trim();

                double dTax = Convert.ToDouble(tax);

                if (dTax > 0 && dTax < 101)
                {
                    taxCheck = true;
                }

                //adds the product (Checks the product id)
                if (Buchhaltung.Products.Max() != null && taxCheck)
                {
                    Product p = new Product(NameOfTheProdukt.Text, Convert.ToDouble(price), Convert.ToInt32(tax),
                                            Convert.ToDouble(AmountOfProduct.Text), KindOfAmount.Text, Buchhaltung.Products.Max().Id,
                                            Group.Text);

                    if (CheckIfProductExists(p))
                    {
                        if (Buchhaltung.ShowYesNoMessageBox(
                                "Das Produkt existiert bereits! Bist du sicher das du es trotzdem hinzufügen möchtest?",
                                "Produkt existiert schon"))
                        {
                            Buchhaltung.Products.Add(p);
                            closeCheck = true;
                        }
                    }
                    else
                    {
                        Buchhaltung.Products.Add(p);
                        closeCheck = true;
                    }
                }
                else if (taxCheck)
                {
                    Product p = new Product(NameOfTheProdukt.Text, Convert.ToDouble(price), Convert.ToInt32(tax),
                                            Convert.ToDouble(AmountOfProduct.Text), KindOfAmount.Text, 0, Group.Text);

                    if (CheckIfProductExists(p))
                    {
                        if (Buchhaltung.ShowYesNoMessageBox(
                                "Das Produkt existiert bereits! Bist du sicher das du es trotzdem hinzufügen möchtest?",
                                "Produkt existiert schon"))
                        {
                            Buchhaltung.Products.Add(p);
                            closeCheck = true;
                        }
                    }
                    else
                    {
                        Buchhaltung.Products.Add(p);
                        closeCheck = true;
                    }
                }

                if (taxCheck && closeCheck)
                {
                    Buchhaltung.SaveProducts();
                    Close();
                }
                else
                {
                    Buchhaltung.Log("Ungültige Prozente!");
                }
            }
            catch (Exception e)
            {
                Buchhaltung.Log(e.Message);
                Buchhaltung.SaveErrorMsg(e);
            }
        }