Exemplo n.º 1
0
        public async void DeleteLabel(TLabel inLabel, List <Customer> customersList)
        {
            try
            {
                int index      = customersList.FindIndex(c => c.Name == inLabel.Name);
                int indexLabel = customersList[index].AllLabels.FindIndex(l => l.Barcode == inLabel.Barcode);
                if (index < 0)
                {
                    return;
                }
                else
                {
                    var name = customersList[index].Name;
                    customersList[index].AllLabels.RemoveAt(indexLabel);
                    customersList[index].AllLabels.RemoveAll(item => item == null);
                    await firebase.Child("Customers").Child(name).PutAsync(customersList[index]);

                    App.CustomerPageViewModel.GenerateCustomerList();
                }
            }
            catch (Exception e)
            {
                var result = PMessageBox.Show("Failed to delete label for " + inLabel.Name + "\n\r Expection: " + e, "Failed to delete label for" + inLabel.Name, System.Windows.Forms.MessageBoxButtons.OK);
                Console.WriteLine(e);
            }
        }
Exemplo n.º 2
0
        public async void DeleteCustomer(Customer inCustomer, List <Customer> customersList)
        {
            try
            {
                int index = customersList.FindIndex(c => c.Name == inCustomer.Name);
                if (index < 0)
                {
                    return;
                }
                else
                {
                    customersList.RemoveAt(index);
                    await firebase.Child("Customers").Child(inCustomer.Name).DeleteAsync();

                    App.CustomerPageViewModel.GenerateCustomerList();
                }
            }
            catch (Exception e)
            {
                var result = PMessageBox.Show("Failed to delete customer " + inCustomer.Name + "\n\r Expection: " + e, "Failed to delete label for" + inCustomer.Name, System.Windows.Forms.MessageBoxButtons.OK);
                Console.WriteLine(e);
            }
        }
        private ToPrint PrinterErrorCheck(string Location)
        {
            var           error    = -1;
            DocumentClass document = new DocumentClass();

            try
            {
                document.Open(Location);

                object[] printers = (object[])document.Printer.GetInstalledPrinters();
                Console.WriteLine("Printers Found");
                foreach (var printer in printers)
                {
                    Console.WriteLine(printer);
                }
                Console.WriteLine("End Printers Found");
                string TemplateMedia = document.GetMediaName();
                string PrinterMedia  = document.Printer.GetMediaName();
                Console.WriteLine("Template Media: " + TemplateMedia + ", Printer Media: " + PrinterMedia);

                if (printers.Length == 0)
                {
                    error = 4258;
                    document.Close();
                    var result = (DialogResult)PMessageBox.Show("Error: e" + error + "No printer aviliable" + ": refer wiki > e" + error,
                                                                "fault in Printers", MessageBoxButtons.RetryCancel);
                    if (result == DialogResult.Retry)
                    {
                        return(ToPrint.Retry);
                    }
                    return(ToPrint.No);
                }
                else if (printers.Length > 0)
                {
                    if (!document.Printer.IsPrinterOnline(printers[0].ToString()))
                    {
                        error = 4261;
                        document.Close();
                        var result = (DialogResult)PMessageBox.Show("Error: e" + error + "\nTheres printer connected" +
                                                                    "\nRefer wiki > e" + error, "No printer connection", MessageBoxButtons.RetryCancel);
                        if (result == DialogResult.Retry)
                        {
                            return(ToPrint.Retry);
                        }
                        return(ToPrint.No);
                    }
                    else if (TemplateMedia != PrinterMedia)
                    {
                        if (PrinterMedia == "")
                        {
                            error = 3465;
                            document.Close();
                            var result = (DialogResult)PMessageBox.Show("Error: e" + error + "No media installed in connected printer" + ": refer wiki > e" + error,
                                                                        "Check Printers", MessageBoxButtons.RetryCancel);
                            if (result == DialogResult.Retry)
                            {
                                return(ToPrint.Retry);
                            }
                            return(ToPrint.No);
                        }
                        else
                        {
                            error = 3461;
                            document.Close();
                            var result = (DialogResult)PMessageBox.Show("Error: e" + error + "\nMedia installed in printer: " + PrinterMedia +
                                                                        "\nIs not equal to document media: " + TemplateMedia + "\nMake sure media in printer is: " + TemplateMedia + "\nRefer wiki > e" + error,
                                                                        "Check Media", MessageBoxButtons.RetryCancel);
                            if (result == DialogResult.Retry)
                            {
                                return(ToPrint.Retry);
                            }
                            return(ToPrint.No);
                        }
                    }
                    error = -1;
                    document.Close();
                    return(ToPrint.Yes);
                }
                return(ToPrint.No);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                error = 4261;
                document.Close();
                var result = (DialogResult)PMessageBox.Show("Error: e" + error + "No Brother printer connected found" + ": refer wiki > e" + error,
                                                            "Check Printers", MessageBoxButtons.RetryCancel);
                if (result == DialogResult.Retry)
                {
                    return(ToPrint.Retry);
                }
                return(ToPrint.No);
            }
        }
Exemplo n.º 4
0
        public void CheckForInternetConnection()
        {
            while (true)
            {
                Console.WriteLine("Check internet " + DateTime.Now.ToLongTimeString().ToString());
                try
                {
                    using (var client = new WebClient())
                        using (client.OpenRead("http://www.microsoft.com"))
                        {
                            if (!previousIsOnline)
                            {
                                IsOnline = true;
                                var result = OfflineExport(OfflineConfig.CustomerList);
                                if (result)
                                {
                                }
                                //Finish - Successful save
                                else
                                {
                                    var Popup = PMessageBox.Show("Error x000054", "Error", null, true, new List <string> {
                                        "Retry", "Ignore"
                                    });
                                    if (Popup.ToString() == "Retry")
                                    {
                                        for (int i = 1; i < 3; i++)
                                        {
                                            var retry = OfflineExport(OfflineConfig.CustomerList);
                                            if (retry)
                                            {
                                                break;
                                            }
                                            else
                                            {
                                                var pop = PMessageBox.Show("Error x000054", "Error", null, true, new List <string> {
                                                    "Retry", "Ignore"
                                                });
                                                if (pop.ToString() == "Retry")
                                                {
                                                    continue;
                                                }
                                                else if (pop.ToString() == "Ignore")
                                                {
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    else if (Popup.ToString() == "Ignore")
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                }
                catch (Exception)
                {
                    if (previousIsOnline)
                    {
                        IsOnline = false;
                        if (previousSave)
                        {
                            //Compare current Data and Previous Data
                        }
                        else
                        {
                            var result = OfflineExport(OfflineConfig.CustomerList);
                            if (result)
                            {
                            }
                            //Finish - Successful save
                            else
                            {
                                var Popup = PMessageBox.Show("Error x000054", "Error", null, true, new List <string> {
                                    "Retry", "Ignore"
                                });
                                if (Popup.ToString() == "Retry")
                                {
                                    for (int i = 1; i < 3; i++)
                                    {
                                        var retry = OfflineExport(OfflineConfig.CustomerList);
                                        if (retry)
                                        {
                                            previousSave = true;
                                            break;
                                        }
                                        else
                                        {
                                            var pop = PMessageBox.Show("Error x000054", "Error", null, true, new List <string> {
                                                "Retry", "Ignore"
                                            });
                                            if (pop.ToString() == "Retry")
                                            {
                                                continue;
                                            }
                                            else if (pop.ToString() == "Ignore")
                                            {
                                                previousSave = false;
                                                break;
                                            }
                                        }
                                    }
                                }
                                else if (Popup.ToString() == "Ignore")
                                {
                                    previousSave = false;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        App.Core.CurrentCustomerList = OfflineImport <List <Customer> >(OfflineConfig.CustomerList);
                    }
                }

                try
                {
                    if (_MainWindow != null)
                    {
                        if (_MainWindow.IsOnlineEllipse != null)
                        {
                            if (IsOnline && !previousIsOnline)
                            {
                                _MainWindow.IsOnlineEllipse.Dispatcher.Invoke(() => (_MainWindow.IsOnlineEllipse.Fill = Brushes.Green));
                                previousIsOnline = true;
                            }
                            else if (!IsOnline && previousIsOnline)
                            {
                                _MainWindow.IsOnlineEllipse.Dispatcher.Invoke(() => (_MainWindow.IsOnlineEllipse.Fill = Brushes.Red));
                                previousIsOnline = false;
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine("unable to changed mainwindow UI");
                }
                Console.WriteLine(IsOnline);
                Thread.Sleep(500);
            }
        }