//GET SKU# LIST (QUERY) private List <string> GetSkuList() { DataTable dt; List <string> skuList = new List <string>(); try { //string query = "SELECT DISTINCT in_item_number AS SKU FROM view_IN_alternate LIMIT 5"; string query = "SELECT DISTINCT in_item_number AS SKU FROM view_IN_alternate"; //cboMySku.ItemsSource = EpicorDB.MySqlDataToDataTable(query).DefaultView; dt = EpicorDB.MySqlDataToDataTable(query); //save query as data table skuList = new List <string>(); //pass list to combobox for (int i = 0; i < dt.Rows.Count; i++) { string sku = dt.Rows[i]["SKU"].ToString(); sku = sku.Replace(" ", ""); //remove whitespace skuList.Add(sku); //add each SKU to list } } catch (MySqlException ex2) { MessageBox.Show("There was a problem with the selection, please pick another sku#", "Error: MySQL Exception"); //MessageBox.Show("There was an error" + "\nMessage: " + ex2.Message + "\nStack: " + ex2.StackTrace, "Error: MySQL Exception"); } catch (Exception ex1) { MessageBox.Show("There was a problem with the selection, please pick another sku#", "Error: General Exception"); //MessageBox.Show("There was an error" + "\nMessage: " + ex1.Message + "\nStack: " + ex1.StackTrace, "Error: General Exception"); } return(skuList); }
//LOAD DATAGRID VIEW private void LoadDataGrid(string query) { try { //string query = "SELECT * FROM dw_customer LIMIT 3"; //add to grid dgvMySql.ItemsSource = EpicorDB.MySqlDataToDataTable(query).DefaultView; } catch (MySqlException ex2) { MessageBox.Show("There was a problem with the selection, please pick another sku#", "Error: MySQL Exception"); //MessageBox.Show("There was an error" + "\nMessage: " + ex2.Message + "\nStack: " + ex2.StackTrace, "Error: MySQL Exception"); } catch (Exception ex1) { MessageBox.Show("There was a problem with the selection, please pick another sku#", "Error: General Exception"); //MessageBox.Show("There was an error" + "\nMessage: " + ex1.Message + "\nStack: " + ex1.StackTrace, "Error: General Exception"); } }
//LOAD DATAGRID VIEW (BY SKU) private void LoadDataGridBySku(string sku) { try { //string query = "SELECT DISTINCT in_item_number AS SKU FROM view_IN_alternate"; //mysql query string query = "SELECT DISTINCT in_prime_department AS DeptNo, " + "in_item_number AS SKU, " + "in_item_description AS Description, " + "in_item_weight AS Attr1, " + "in_weight_unit AS Unit, " + "in_retail_price AS Retail, " + "in_quantity_on_hand AS QOH, " + "in_quantity_on_order AS QOO " + "FROM view_IN_alternate " + // "WHERE in_item_number=" + sku + ";"; "where in_sds_seq_all_stores_id=1 " + //filters to only show one entry (need to confirm this is correct) "and in_item_number=" + sku + ";"; //input sku# here (parameterized query?)(needs to be a number) //data table (get data from query) DataTable dt = new DataTable(); dt = EpicorDB.MySqlDataToDataTable(query); //add (row#) column DataColumn col2 = dt.Columns.Add("#", typeof(Int32)); col2.SetOrdinal(0); //set to left column //---------- //autoincrement columns int index = 0; foreach (DataRow row in dt.Rows) { row.SetField(col2, ++index); } //set autoincrement (new rows...) col2.AutoIncrement = true; col2.AutoIncrementSeed = ++index; col2.AutoIncrementStep = 1; col2.ReadOnly = true; //read-only //---------- //set table to read-only //dgvMySql.IsReadOnly = true; //set the whole table (can't change checkbox column?) for (int i = 0; i < dt.Columns.Count; i++) { dt.Columns[i].ReadOnly = true; //make all columns (read-only) } //add (checkbox) column for selecting DataColumn col = dt.Columns.Add("Selection", typeof(bool)); col.SetOrdinal(0); //set to left column col.ReadOnly = false; //make this column (accessible only) //add to grid //dgvMySql.ItemsSource = EpicorDB.MySqlDataToDataTable(query).DefaultView; dgvMySql.ItemsSource = dt.DefaultView; } catch (MySqlException ex2) { MessageBox.Show("There was a problem with the selection, please pick another sku#", "Error: MySQL Exception"); //MessageBox.Show("There was an error" + "\nMessage: " + ex2.Message + "\nStack: " + ex2.StackTrace, "Error: MySQL Exception"); } catch (Exception ex1) { MessageBox.Show("There was a problem with the selection, please pick another sku#", "Error: General Exception"); //MessageBox.Show("There was an error" + "\nMessage: " + ex1.Message + "\nStack: " + ex1.StackTrace, "Error: General Exception"); } }