public stockItemMethods(bool isSpecial) { if (isSpecial) { stockTableName = TableNames.StockTables.StockItems_Specials; } else { stockTableName = TableNames.StockTables.StockItems; } }
//public DataTable getTemplateStockItems(Supplier s, Templates selectedTemplate, bool specialsOverride) //{ // DataTable dataset = new DataTable(); // if (specialsOverride) // { // TableNames.StockTables tempStockTableName = stockTableName; // //get the two datasets // DataTable normalItems = getTemplateStockItemsMaster(s, selectedTemplate); // normalItems.Columns.Add("SpecialOverride"); // stockTableName = TableNames.StockTables.StockItems_Specials; // DataTable specialItems = getTemplateStockItemsMaster(s, selectedTemplate); // specialItems.Columns.Add("SpecialOverride"); // stockTableName = tempStockTableName; // //specials will override normal items // DataTable combinedItems = normalItems.Clone(); // for (int i = 0; i < normalItems.Rows.Count; i++) // { // DataRow matchRow = specialItems.NewRow(); // bool foundMatch = false; // string checkNormalItem = normalItems.Rows[i]["productCode_Orig"].ToString(); // for (int j = 0; j < specialItems.Rows.Count; j++) // { // if (specialItems.Rows[j]["productCode_Orig"].ToString() == checkNormalItem) // { // matchRow = specialItems.Rows[j]; // matchRow["SpecialOverride"] = true; // foundMatch = true; // } // } // if (foundMatch) // { // combinedItems.ImportRow(matchRow); // } // else // { // combinedItems.ImportRow(normalItems.Rows[i]); // } // } // dataset = combinedItems; // } // else // { // dataset = getTemplateStockItemsMaster(s, selectedTemplate); // } // return dataset; //} public DataTable getTemplateStockItems(Supplier s, Templates selectedTemplate, bool specialsOverride) { DataTable dataset = new DataTable(); if (specialsOverride) { stockTableName = TableNames.StockTables.StockItems_Specials; } else { stockTableName = TableNames.StockTables.StockItems; } dataset = getTemplateStockItemsMaster(s, selectedTemplate); return(dataset); }
private void createDBColumnMaster(string columnName, columnTypes colType, TableNames.StockTables tableName) { //format columnName columnName = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(columnName.ToLower()); columnName = columnName.Replace(" ", ""); //determines the column type string scolType = "VARCHAR(500)"; switch (colType) { case columnTypes.DECIMAL_18_2: { scolType = "DECIMAL(18, 2)"; } break; case columnTypes.DECIMAL_18_3: { scolType = "DECIMAL(18, 3)"; } break; case columnTypes.DECIMAL_18_4: { scolType = "DECIMAL(18, 4)"; } break; case columnTypes.DECIMAL_18_5: { scolType = "DECIMAL(18, 5)"; } break; } //creates the column string query = @" IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" + tableName + "' AND COLUMN_NAME = '" + columnName + @"') ALTER TABLE [DBO]." + tableName + " ADD " + columnName + @" " + scolType + @" NULL "; try { db.write(query); } catch (Exception ee) { throw new DataException("Unable to create database column: " + ee.Message, ee); } }
public stockItemMethods() { stockTableName = TableNames.StockTables.StockItems; }