private async void ExtractButton_Click(object sender, EventArgs e) { if (SelectCourseComboBox.Text != "Select Course") { MessageBox.Show("Please select an Empty folder."); using (FolderBrowserDialog dialog = new FolderBrowserDialog()) { DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(dialog.SelectedPath)) { extractPath = dialog.SelectedPath; } } (string selectedLang2, string exten) = GetLanguage(); ext = exten; if (ext != "") { if (extractPath != "") { if (CheckDirectoryEmpty_Fast(extractPath) == true) { if (!String.IsNullOrEmpty(zipPath)) { ExtractFiles1(zipPath, extractPath); getFilesRecursive(extractPath); String[] str = flaggedStudents.ToArray(); await File.WriteAllLinesAsync("blacklist.txt", str); var data = new Data { Students = str }; PushResponse response = await client.PushTaskAsync("Submission Flags/" + GetCourseSelected() + "/" + selectedYear.Text + "/", data); } else { MessageBox.Show("Please select an Archive."); } } else { MessageBox.Show("Folder you selected is not empty."); } } else { MessageBox.Show("Folder Not selected."); } } else { MessageBox.Show("Please Select a Language before Extraction."); } } else { MessageBox.Show("Please Select a Course"); } }
public async void InsertClient(Client c, ClientTicket ticket, bool isChecked) { ClientNeeded cn = new ClientNeeded { address = c.address, email = c.email, barCode = c.barCode, isDeleted = c.isDeleted, comments = c.comments, insertedDate = c.insertedDate, name = c.name, personalIdentity = c.personalIdentity, photo = c.photo, telefon = c.telefon }; PushResponse response = await client.PushTaskAsync("Clients", cn); if (isChecked) { Dictionary <string, string> dict = new Dictionary <string, string>(); dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(response.Body); ticket.clientId = dict["name"]; InsertClientTicket(ticket); } }
public async Task pushDataAsync(string path, Coins data) { //PushResponse response = await firebaseClient.PushTaskAsync(path, data); DateTime date = DateTime.Now; //DateTime utcdate = DateTime.Now; PushResponse response = await firebaseClient.PushTaskAsync("test", date); }
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 createInvoice_btn_Click(object sender, EventArgs e) { Invoices_class invoice = new Invoices_class { cashier = cashier_editText.Text, timestamp = invoiceDate_editText.Text, invoiceNo = invoiceNo_editText.Text, totalBill = totalBill_label.Text, productList = selectedProductList }; PushResponse response = await client.PushTaskAsync("invoices", invoice); for (int i = 0; i < selectedKeys.Count; i++) { int finalQuantity = Int32.Parse(selectedQuantity[i]) - Int32.Parse(selectedProductList[i].quantity); selectedProductList[i].quantity = "" + finalQuantity; FirebaseResponse response2 = await client.UpdateTaskAsync("products/" + keys[i], selectedProductList[i]); } MessageBox.Show("Invoice Added Successfully!"); this.Hide(); }
private async void add_btn_Click(object sender, EventArgs e) { if (name_editText.Text == "" || name_editText == null) { MessageBox.Show("Fill Name field first."); } else if (price_editText.Text == "" || price_editText == null) { MessageBox.Show("Fill price field first."); } else if (description_editText.Text == "" || description_editText == null) { MessageBox.Show("Fill description field first."); } else if (quantity_editText.Text == "" || quantity_editText == null) { MessageBox.Show("Fill quantity field first."); } else { bool check = false; for (int i = 0; i < productList.Count; i++) { if (name_editText.Text.ToLower() == productList[i].name.ToLower()) { check = true; break; } } if (!check) { bool temp1, temp2; if (featured_list.GetItemText(featured_list.SelectedItem) == "false") { temp1 = false; } else { temp1 = true; } if (prescription_list.GetItemText(prescription_list.SelectedItem) == "false") { temp2 = false; } else { temp2 = true; } //Adding product to firebase Products_class product = new Products_class(description_editText.Text, discount_editText.Text, temp1, image_editText.Text + "", name_editText.Text, temp2, double.Parse(price_editText.Text), int.Parse(quantity_editText.Text), DateTime.Now.ToString()); PushResponse response = await client.PushTaskAsync("products", product); productList.Add(product); FirebaseResponse resp = await client.GetTaskAsync("products/"); Dictionary <string, Products_class> dict = resp.ResultAs <Dictionary <string, Products_class> >(); //Adding new key to keys array foreach (KeyValuePair <string, Products_class> ele1 in dict) { if (!keys.Contains(ele1.Key)) { keys.Add(ele1.Key); break; } } //Console.WriteLine("response: "+response.Result.ToString()); //adding new row to DT DataRow row = dt.NewRow(); row["Name"] = product.name; row["Price"] = product.price; row["Quantity"] = product.quantity; row["Discount"] = product.discount; row["Description"] = product.description; row["Featured"] = product.featured; row["Prescription"] = product.prescription; row["Date"] = product.timestamp; dt.Rows.Add(row); } else { MessageBox.Show("Product already exists in the inventory."); } } }
public async Task <ActionResult> UploadAsync([FromForm] FormProduct formData) { string output = ""; LoadFirebase(); try { bool checkFile = true; if ("Create".Equals(formData.Button)) { if (formData.File == null) { return(new UnsupportedMediaTypeResult()); } } else if ("Update".Equals(formData.Button)) { if (formData.File == null) { checkFile = false; } } PushResponse response = null; if (checkFile) { string filename = formData.File.FileName; #region algorithm to check file exists. if true, rename file if (System.IO.File.Exists(fileUploadPath + filename)) { while (System.IO.File.Exists(fileUploadPath + filename)) { int lastIndex = filename.LastIndexOf("."); string input = filename.Substring(lastIndex - 3, 3); if (Regex.IsMatch(input, "^\\(\\d+\\)$")) { string number = filename.Substring(lastIndex - 2, 1); int num = Int32.Parse(number); num++; filename = filename.Replace("(" + number + ")", "(" + num + ")"); } else { filename = filename.Insert(lastIndex, "(1)"); } } string oldPath = Path.Combine(fileUploadPath, formData.File.FileName); string newPath = Path.Combine(fileUploadPath, filename); System.IO.File.Move(oldPath, newPath); } #endregion #region save file to path project var fileExtension = MimeTypeMap.GetExtension(formData.File.ContentType); using var stream = System.IO.File.Create(Path.Combine(fileUploadPath, formData.File.FileName)); formData.File.CopyToAsync(stream).Wait(); stream.Close(); #endregion #region upload file on Firebase - Realtime Database string base64 = GetBase64StringForImage(GetFilePath(filename, fileUploadPath)); output = base64; var data = new ImageModel { Img = base64 }; response = await client.PushTaskAsync("Image/", data); ImageModel result = response.ResultAs <ImageModel>(); #endregion } TempForm tempForm = new TempForm(); if ("Create".Equals(formData.Button)) { tempForm.ImageLocation = response.Result.Name; } else if ("Update".Equals(formData.Button)) { tempForm.ProductId = formData.ProductId; if (formData.File != null) { tempForm.ImageLocation = response.Result.Name; } } tempForm.ProductName = formData.ProductName; tempForm.Quantity = formData.Quantity; tempForm.Price = formData.Price; tempForm.CategoryId = formData.CategoryId; string serialize = System.Text.Json.JsonSerializer.Serialize <TempForm>(tempForm); HttpContext.Session.SetString("tempForm", serialize); return(Redirect("Product/addProduct")); } catch (Exception) { throw; } return(BadRequest()); }
private async void add_btn_Click(object sender, EventArgs e) { if (name_editText.Text != "" && password_editText.Text != "") { int temp = role_list.SelectedIndex; string role; //cashier is selected if (temp == 0) { role = "Cashier"; } else { role = "Admin"; } Pos_Users user = new Pos_Users() { name = name_editText.Text, password = password_editText.Text, role = role }; try { PushResponse response = await client.PushTaskAsync("posUsers", user); Pos_Users result = response.ResultAs <Pos_Users>(); usersList.Add(user); FirebaseResponse resp = await client.GetTaskAsync("posUsers/"); Dictionary <string, Pos_Users> dict = resp.ResultAs <Dictionary <string, Pos_Users> >(); //Adding new key to keys array foreach (KeyValuePair <string, Pos_Users> ele1 in dict) { if (!keys.Contains(ele1.Key)) { keys.Add(ele1.Key); break; } } //adding new row to DT DataRow row = dt.NewRow(); row["Name"] = user.name; row["Password"] = user.password; row["Role"] = user.role; dt.Rows.Add(row); } catch (Exception) { MessageBox.Show("Failed to connect to database. Check your internet connection and try again."); } } else { MessageBox.Show("Please fill the fields first."); } }
public async void AddProductToInventory(Products_class product) { PushResponse response = await client.PushTaskAsync("products", product); }
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!"); } } }