Exemplo n.º 1
0
        /// <summary>
        /// Starts the programm with the data needed
        /// </summary>
        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, Username, IsAdmin);
                        b.Show();
                    }
                    else
                    {
                        //If one if is not correct writes error and returns
                        if (OldCashDesk.Text.Length == 0)
                        {
                            Buchhaltung.Log("Kein alter Kassenstand eingetragen!");
                            return;
                        }
                        if (NameInput.Text.Length == 0)
                        {
                            Buchhaltung.Log("Kein Name eingetragen!");
                            return;
                        } //end of return if

                        string oldCashDeskStr = OldCashDesk.Text;
                        if (oldCashDeskStr.Contains("€"))
                        {
                            oldCashDeskStr = oldCashDeskStr.Replace('€', ' ').Trim();
                        }
                        Buchhaltung b = new Buchhaltung(WeekNrTextBox.Text, NameInput.Text,
                                                        Convert.ToDateTime(DateTextBox.Text), Convert.ToDouble(oldCashDeskStr), Username, IsAdmin);
                        b.Show();
                    }

                    Close();
                }
                else
                {
                    Buchhaltung.Log("Ungültige Woche");
                }
            }
            catch (Exception e)
            {
                Buchhaltung.SaveErrorMsg(e);
                Buchhaltung.Log(e.Message);
            }
        }