public async void updateVendorList() { try { FirebaseResponse resp = await client.GetTaskAsync("vendors/"); Dictionary <string, Vendor_class> dict = resp.ResultAs <Dictionary <string, Vendor_class> >(); //Adding vendor keys to Array vendorKeys foreach (KeyValuePair <string, Vendor_class> ele1 in dict) { vendorKeys.Add(ele1.Key); // Console.WriteLine("{0} and {1}", // ele1.Key, ele1.Value); } //traversing list vendorkeys to fetch vendor details for (int i = 0; i < vendorKeys.Count; i++) { FirebaseResponse resp2 = await client.GetTaskAsync("vendors/" + vendorKeys[i]); Vendor_class vendor = resp2.ResultAs <Vendor_class>(); vendor_list.Items.Add(vendor.name); vendorList.Add(vendor); } } catch (Exception) { MessageBox.Show("Cant download available vendors. Add a vendor and/or check your internet connection."); } }
public Modal_Purchases_Detail(int temp, List <PurchaseOrder_class> orderList, Vendor_class vendor) { index = temp; this.orderList = orderList; this.vendor = vendor; InitializeComponent(); }
private async void add_btn_Click(object sender, EventArgs e) { if (name_editText.Text != "" && name_editText.Text != null) { if (mobileNo_editText.Text.Count() == 11) { try { vendor = new Vendor_class { name = name_editText.Text, mobileNo = mobileNo_editText.Text }; PushResponse response = await client.PushTaskAsync("vendors", vendor); Vendor_class result = response.ResultAs <Vendor_class>(); MessageBox.Show("Vendor Added Successfully!"); this.Hide(); New_Purchase np = new New_Purchase(); np.Show(); } catch (Exception) { //inserted = false; MessageBox.Show("Failed to add vendor. Check your internet connectivity."); } } else { MessageBox.Show("Mobile Number invalid!"); } } else { MessageBox.Show("Name invalid!"); } }
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!"); } } }