private void SaveProductsToClipboard() { Stack <ProductToSave> reversed = new Stack <ProductToSave>(); foreach (ProductToSave toSave in mProductsToSave) { reversed.Push(toSave); } StringBuilder outBuf = new StringBuilder(); while (reversed.Count > 0) { ProductToSave toSave = reversed.Pop(); string line = toSave.ProductName + "\t" + toSave.Size + "\t" + toSave.VendorCode + "\t" + "0" + "\t" + (string.IsNullOrEmpty(toSave.CasePrice) ? "0" : toSave.CasePrice) + "\t" + (string.IsNullOrEmpty(toSave.CaseSize) ? "0" : toSave.CaseSize) + "\t" + (string.IsNullOrEmpty(toSave.EachPrice) ? "0" : toSave.EachPrice) + "\t" + toSave.BrandName + "\t" + "\t" + "Y"; outBuf.AppendLine(line); } Clipboard.Clear(); Clipboard.SetText(outBuf.ToString()); }
private void btnUndoSelect_Click(object sender, EventArgs e) { switch (mNextField) { case NextFieldToSave.VendorCode: if (mProductsToSave.Count > 0) { ProductToSave toSave = mProductsToSave.Pop(); txtVendorCode.Text = toSave.VendorCode; txtProductName.Text = toSave.ProductName; txtSize.Text = toSave.Size; txtBrandName.Text = toSave.BrandName; txtCasePrice.Text = toSave.CasePrice; txtCaseSize.Text = toSave.CaseSize; txtEachPrice.Text = toSave.EachPrice; } break; } if (mSelectedElements.Count > 0) { ElementSelect sel = mSelectedElements.Pop(); mNextField = sel.OldNextField; if (sel.Element != null) { sel.Element.Style = sel.OldStyle; } } ShowNextField(); }
private void btnSave_Click(object sender, EventArgs e) { ProductToSave toSave = new ProductToSave(); toSave.VendorCode = txtVendorCode.Text; toSave.ProductName = txtProductName.Text; toSave.Size = txtSize.Text; toSave.BrandName = txtBrandName.Text; toSave.CasePrice = txtCasePrice.Text; toSave.CaseSize = txtCaseSize.Text; toSave.EachPrice = txtEachPrice.Text; mProductsToSave.Push(toSave); SaveProductsToClipboard(); ElementSelect selectedElm = new ElementSelect(); selectedElm.OldNextField = NextFieldToSave.Done; selectedElm.OldStyle = null; selectedElm.Element = null; mSelectedElements.Push(selectedElm); InitNextProduct(); }
public static void UpdateSavedProductsWhenClosingApp() { try { var sortedProducts = new Dictionary <string, ProductionDetailsToSave>(); foreach (string ID in businesses.Keys) { if (!sortedProducts.ContainsKey(ID)) { var productionToSave = new ProductionDetailsToSave() { productSource = new Dictionary <string, ProductToSave>() }; foreach (ProductItem product in businesses[ID].productSource) { var productDetailsToSave = new ProductToSave(); if (product.isEnable == true) { productDetailsToSave.isEnable = "TRUE"; productDetailsToSave.icon = product.sortedStatusIcon; } else if (product.isEnable == false) { productDetailsToSave.isEnable = "FALSE"; productDetailsToSave.icon = ""; } var customerList = new List <CustomerToSave>(); foreach (Customer customer in product.customers) { var customerToSave = new CustomerToSave(); customerToSave.customer_first_name = customer.customer_first_name; customerToSave.customer_last_name = customer.customer_last_name; customerToSave.customer_uid = customer.customer_uid; customerToSave.qty = customer.qty; if (customer.borderColor == Color.Red) { customerList.Add(customerToSave); } } productDetailsToSave.customersSource = customerList; productionToSave.productSource.Add(product.item_uid, productDetailsToSave); } sortedProducts.Add(ID, productionToSave); } } SaveChanges(sortedProducts); }catch (Exception issueOnUpdateSavedProductsWhenClosingApp) { Application.Current.MainPage.DisplayAlert("Oops", issueOnUpdateSavedProductsWhenClosingApp.Message, "OK"); } }
void NavigateToSummaryPage(System.Object sender, System.EventArgs e) { try { var sortedProducts = new Dictionary <string, ProductionDetailsToSave>(); foreach (string ID in businesses.Keys) { if (!sortedProducts.ContainsKey(ID)) { var productionToSave = new ProductionDetailsToSave() { productSource = new Dictionary <string, ProductToSave>() }; foreach (ProductItem product in businesses[ID].productSource) { var productDetailsToSave = new ProductToSave(); if (product.isEnable == true) { productDetailsToSave.isEnable = "TRUE"; } else if (product.isEnable == false) { productDetailsToSave.isEnable = "FALSE"; } productDetailsToSave.icon = product.sortedStatusIcon; var customerList = new List <CustomerToSave>(); foreach (Customer customer in product.customers) { var customerToSave = new CustomerToSave(); customerToSave.customer_first_name = customer.customer_first_name; customerToSave.customer_last_name = customer.customer_last_name; customerToSave.customer_uid = customer.customer_uid; customerToSave.qty = customer.qty; if (customer.borderColor == Color.Red) { customerList.Add(customerToSave); } } productDetailsToSave.customersSource = customerList; productionToSave.productSource.Add(product.item_uid, productDetailsToSave); } sortedProducts.Add(ID, productionToSave); } } SaveChanges(sortedProducts); isProductionSave = "TRUE"; Navigation.PushModalAsync(new SummaryPage()); } catch (Exception issueOnNavigateToSummaryPage) { Application.Current.MainPage.DisplayAlert("Oops", issueOnNavigateToSummaryPage.Message, "OK"); } }