/// <summary> /// Takes user input and returns the products /// systematically mapped location in the warehouse /// </summary> /// <returns>string</returns> public string ItemMapping(string item) { string zone = ""; string position = ""; string shelf = ""; DataTable dt; SQLBuilder sql = new SQLBuilder(); // TODO: implement barcode parsing to return different results switch (parser.parseType(item)) { case BarcodeEnum.KIT: string product = SearchByProductId(Utils.SplitKitBarcode(item)[0]).Rows[0][0].ToString(); sql.add("SELECT"); sql.add("zone, position, shelf"); sql.add("FROM doarni.ci_product_mapping"); sql.add(string.Format("WHERE product_number = '{0}'", product)); dt = postgres.execute(sql.build(), true); zone = dt.Rows[0][0].ToString(); position = dt.Rows[0][1].ToString(); shelf = dt.Rows[0][2].ToString(); break; case BarcodeEnum.UNKNOWN: // Attempt to find the item anyways sql.add("SELECT"); sql.add("zone, position, shelf"); sql.add("FROM doarni.ci_product_mapping"); sql.add(string.Format("WHERE product_number = '{0}'", item)); try { dt = postgres.execute(sql.build(), true); zone = dt.Rows[0][0].ToString(); position = dt.Rows[0][1].ToString(); shelf = dt.Rows[0][2].ToString(); break; } catch (QueryError qError) { // Could not find the item throw ErrorHandler.Throw(ErrorType.INVENTORY, "Unknown barcode / item [" + item + "]"); } default: break; // TODO implement new exception here } return(string.Format("{0}-{1}-{2}", zone, position, shelf)); }
/// <summary> /// Takes user input and returns the products /// systematically mapped location in the warehouse /// </summary> private void itemMapping() { string text = "Enter a kit barcode or kit number to search"; // Create a new ScanInput form using (var f = new ScanInput(text, true, false)) { // Get input from user var result = f.ShowDialog(); if (!(result == DialogResult.OK)) { // User canceled or closed the dialog } else { if (string.IsNullOrWhiteSpace(f.Input) || string.IsNullOrEmpty(f.Input)) { MessageBox.Show("You didn't enter anything!", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } string product; // Make sure the input was a barcode // If not, simply take the imput as a product number if (barcodeParser.parseType(f.Input) == BarcodeEnum.UNKNOWN) { product = f.Input; } else { product = search.SearchByProductId(Utils.SplitKitBarcode(f.Input)[0]).Rows[0][0].ToString(); } try { string map = search.ItemMapping(f.Input); MessageBox.Show( string.Format("{0} Mapped to: {1}{2}", product, Environment.NewLine, map), "Mapping for " + product, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } catch (Exception e) { MessageBox.Show(e.Message, "Search Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } }