Esempio n. 1
0
        public WorkingMenu()
        {
            InitializeComponent();

            tablesListBox.Visible   = false;
            productsListBox.Visible = false;

            SetAreasMenu();
            SetCategoriesMenu(pageCategories);

            try
            {
                ReadWriteFiles.ReadProductsOnTableFromFile(tablesInUse);
            }
            catch (FormatException)
            {
                ReadWriteFiles.DeleteProductsOnTableFile();
                MessageBox.Show("An error ocurred when checking occupied tables. All occupied tables were reset.", "Internal Error");
            }

            try
            {
                soldProducts = ReadWriteFiles.ReadSoldProductsFromFile();
            }
            catch (FormatException)
            {
                ReadWriteFiles.DeleteSoldProductsFile();
                MessageBox.Show("An error ocurred when loading the sold products list. The list was reset.", "Internal Error");
            }
        }
Esempio n. 2
0
        protected void Button15_Click(object sender, EventArgs e)
        {//not working
            ReadWriteFiles rw           = new ReadWriteFiles();
            string         fileLocation = "c:\\Users\\Sophy_2\\Documents\\temp.txt";

            rw.CreadFile(fileLocation);
            this.TextBox1.Text = string.Format($"\r\nFile Creaded at {fileLocation}");

/*
 *          SerializeDemo rwB = new SerializeDemo();
 *          this.TextBox1.Text = rwB.WriteToBinary() ;
 */
        }
Esempio n. 3
0
        public ActionResult ClosetheDay()
        {
            try
            {
                // It checks if all tables on the system are empty
                if (soldProductsData.GetAll().Count < 1)
                {
                    List <ISaleModel> sales = saleData.GetSaleList();

                    // Checks if there are sold products on this day
                    if (sales.Count < 1)
                    {
                        log.Info("User tried to close the day without sold products");
                        return(View("NoSoldProducts"));
                    }

                    DateTime time  = DateTime.Now;
                    string   day   = time.ToString("dd-MM-yyyy");
                    string   hours = time.ToString("HH:mm");

                    decimal money = sales.Sum(x => x.Price);

                    try
                    {
                        // Creates and adds data to files about time, money income and list of sold products
                        ReadWriteFiles.AddFileOfTodaySoldProducts(sales, time);
                        ReadWriteFiles.WriteInDailyIncomeFile(day, hours, money);
                    }
                    catch (Exception exFile)
                    {
                        log.Error("Could't write to files", exFile);
                        return(View("ErrorWriteToFile"));
                    }

                    // Deletes all list of sold products on this day from database
                    saleData.EraseDataFromSaleList();

                    return(RedirectToAction("Menu"));
                }
                else
                {
                    log.Info("User tried to close the day with opened tables");
                    return(View("OpenedTables"));
                }
            }
            catch (Exception ex)
            {
                log.Error("Could't load data from Database", ex);
                return(View("ErrorRetriveData"));
            }
        }
Esempio n. 4
0
        private void closeTheDayButton_Click(object sender, EventArgs e)
        {
            List <IUsedTable> usedTables = Factory.InstanceListUsedTable();

            try
            {
                ReadWriteFiles.ReadProductsOnTableFromFile(usedTables);
            }
            catch (FormatException)
            {
                usedTables = null;
                ReadWriteFiles.DeleteProductsOnTableFile();
                MessageBox.Show("An error ocurred when checking if there are still occupied tables. All occupied tables were reset.", "Internal Error");
            }

            if (soldProducts.Count > 0)
            {
                if (usedTables.Count == 0)
                {
                    DialogResult result = MessageBox.Show($"Are you sure you want to close the day and generate the data files?",
                                                          "Close the day", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                    if (result == DialogResult.Yes)
                    {
                        DateTime time = DateTime.Now;

                        string day   = time.ToString("dd-MM-yyyy");
                        string hours = time.ToString("HH:mm");

                        decimal money = soldProducts.Sum(x => x.Price);

                        ReadWriteFiles.WriteInDailyIncomeFile(day, hours, money);
                        ReadWriteFiles.AddFileOfTodaySoldProducts(soldProducts, time);
                        ReadWriteFiles.DeleteSoldProductsFile();

                        soldProductsListBox.DataSource = null;
                        totalTextBox.Text = "0";
                    }
                }
                else
                {
                    MessageBox.Show("You still have occupied tables on the system. Please do the payments or remove the items.", "Occupied tables");
                }
            }
            else
            {
                MessageBox.Show("You haven't sold any product so far.", "Empty List");
            }
        }
Esempio n. 5
0
        public SalesControlForm()
        {
            InitializeComponent();

            try
            {
                soldProducts = ReadWriteFiles.ReadSoldProductsFromFile().OrderByDescending(x => x.Ammount).ToList();
            }
            catch (FormatException)
            {
                ReadWriteFiles.DeleteSoldProductsFile();
                MessageBox.Show("An error ocurred while loading the sold products list. The list was reset.", "Internal Error");
            }

            soldProductsListBox.DataSource    = null;
            soldProductsListBox.DataSource    = soldProducts;
            soldProductsListBox.DisplayMember = "DisplayText3";

            totalTextBox.Text = soldProducts.Sum(x => x.Price).ToString();
        }
Esempio n. 6
0
        public ActionResult DownloadMoneyIncomeFile()
        {
            if (ReadWriteFiles.DailyIncomeFileExist())
            {
                try
                {
                    string file        = AppDomain.CurrentDomain.BaseDirectory + @"\DailyIncome.csv";
                    string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                    return(File(file, contentType, Path.GetFileName(file)));
                }
                catch (Exception ex)
                {
                    log.Error("Could't download DailyIncome.csv", ex);
                    return(View("ErrorDownload"));
                }
            }

            log.Info("DailyIncome.csv doesn't exist");
            return(View("FileNotFound"));
        }
Esempio n. 7
0
 private void WorkingMenu_FormClosing(object sender, FormClosingEventArgs e)
 {
     ReadWriteFiles.WriteProductsOnTableToFile(tablesInUse);
     ReadWriteFiles.WriteSoldProductsToFile(soldProducts);
 }