Beispiel #1
0
        private async void Load_Purchases()
        {
            try
            {
                FirebaseResponse resp = await client.GetTaskAsync("purchases/");

                Dictionary <string, PurchaseOrder_class> dict = resp.ResultAs <Dictionary <string, PurchaseOrder_class> >();

                //Adding invoice keys to Array salesKeys
                foreach (KeyValuePair <string, PurchaseOrder_class> ele1 in dict)
                {
                    purchasesKeys.Add(ele1.Key);
                }

                //traversing list keys to fetch invoice details
                for (int i = 0; i < purchasesKeys.Count; i++)
                {
                    FirebaseResponse resp2 = await client.GetTaskAsync("purchases/" + purchasesKeys[i]);

                    PurchaseOrder_class order = resp2.ResultAs <PurchaseOrder_class>();
                    purchasesList.Add(order);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Error connecting to the database. Check your internet connection and restart the application.");
            }
        }
Beispiel #2
0
        private async void updateOrders()
        {
            try
            {
                FirebaseResponse resp = await client.GetTaskAsync("purchases/");

                Dictionary <string, PurchaseOrder_class> dict = resp.ResultAs <Dictionary <string, PurchaseOrder_class> >();


                //Adding product keys to Array Keys
                foreach (KeyValuePair <string, PurchaseOrder_class> ele1 in dict)
                {
                    keys.Add(ele1.Key);
                }

                //traversing list keys to fetch product details
                for (int i = 0; i < keys.Count; i++)
                {
                    FirebaseResponse resp2 = await client.GetTaskAsync("purchases/" + keys[i]);

                    PurchaseOrder_class order = resp2.ResultAs <PurchaseOrder_class>();

                    orderList.Add(order);


                    //Adding firebase data to the data grid
                    DataRow row = dt.NewRow();
                    row["Purchase Order #"] = orderList[i].orderNo;
                    row["TimeStamp"]        = orderList[i].orderDate;
                    row["Total Bill"]       = orderList[i].totalBill;
                    row["Punched By"]       = orderList[i].punchedBy;

                    dt.Rows.Add(row);
                    //   Console.WriteLine("Row added");
                }
            }
            catch (Exception e)
            {
                // MessageBox.Show("Failed to download purchase orders OR there are no purchase orders.\nCheck your INTERNET and/or create a purchase order to show.");
                MessageBox.Show(e.Message);
            }
        }
Beispiel #3
0
        private async void createOrder_btn_Click(object sender, EventArgs e)
        {
            if (products_grid.Rows[0].Cells[0].Value == null)
            {
                MessageBox.Show("Please select a product first");
            }
            else
            {
                try
                {
                    Vendor_class v = vendorList[vendor_list.SelectedIndex];

                    List <Products_class> newList = new List <Products_class>();

                    newList = selectedProductsList.Concat(newProductList).ToList();

                    PurchaseOrder_class po = new PurchaseOrder_class
                    {
                        vendor      = v,
                        orderNo     = orderNo_editText.Text,
                        orderDate   = orderDate_editText.Text,
                        totalBill   = totalBill_label.Text,
                        productList = newList,
                        punchedBy   = Form1.loggedInUser.name
                    };

                    try
                    {
                        PushResponse response = await client.PushTaskAsync("purchases", po);

                        PurchaseOrder_class p2 = response.ResultAs <PurchaseOrder_class>();
                        for (int i = 0; i < newProductList.Count; i++)
                        {
                            PushResponse res = await client.PushTaskAsync("products", newProductList[i]);

                            Products_class pp = res.ResultAs <Products_class>();
                        }

                        for (int i = 0; i < selectedProductsListUPDATE.Count; i++)
                        {
                            FirebaseResponse response2 = await client.UpdateTaskAsync("products/" + keysUPDATE[i], selectedProductsListUPDATE[i]);

                            Products_class product = response2.ResultAs <Products_class>();
                        }
                    }

                    catch (Exception)
                    {
                        MessageBox.Show("Error connecting to FIREBASE. Please check your internet connection!");
                    }

                    MessageBox.Show("Order added successfully");

                    this.Hide();
                    Purchasing p = new Purchasing();
                    p.Show();
                }
                catch (Exception)
                {
                    MessageBox.Show("Please Select a vendor first!");
                }
            }
        }