private void btnOrder_Click(object sender, EventArgs e) { //copy the items from inventory to soldItems table foreach (DataRow row in cartDataSet.Tables[0].Rows) { string sql = @"INSERT INTO soldItems SELECT * FROM inventory WHERE InventoryNumber = " + row["InventoryNumber"].ToString(); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, main.m_dbConnection); da.Fill(ds); } //delete them from the inventory database foreach (DataRow row in cartDataSet.Tables[0].Rows) { string sql = @"DELETE FROM inventory WHERE InventoryNumber = " + row["InventoryNumber"].ToString(); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, main.m_dbConnection); da.Fill(ds); } main.updateInventoryGrid(); cartDataSet.Clear(); updateTotals(); }
public void removeFromInventory(int inventoryNum, mainForm main) { string sql = @"DELETE FROM inventory WHERE InventoryNumber = " + inventoryNum.ToString(); SQLiteCommand command = new SQLiteCommand(sql, main.m_dbConnection); command.ExecuteNonQuery(); MessageBox.Show("Item " + inventoryNum.ToString() + " removed from inventory!"); //update datasource for the changed dataset main.updateInventoryGrid(); }
public string dateCreated; //date the item was added to inventory /*class methods*/ public virtual void addToInventory(mainForm main) { string sql = @"insert into inventory (Type, InventoryNumber, Condition, Location, DateCreated, Cost, Price) values (" + "'General Craft'" + "," + Convert.ToInt16(this.number.ToString()) + "," + "'" + this.condition.ToString() + "'" + "," + "'" + this.location.ToString() + "'" + "," + "'" + this.dateCreated.ToString() + "'" + "," + Convert.ToDouble(this.cost.ToString()) + "," + Convert.ToDouble(this.price.ToString()) + ")"; SQLiteCommand command = new SQLiteCommand(sql, main.m_dbConnection); command.ExecuteNonQuery(); main.updateInventoryGrid(); }
public string charm; //describes the color of the ribbon public override void addToInventory(mainForm main) { string sql = @"insert into inventory (Type, InventoryNumber, FabricFront, FabricBack, Charm, Condition, Location, DateCreated, Cost, Price) values (" + "'Bookmark'" + "," + Convert.ToInt16(this.number.ToString()) + "," + "'" + this.frontFabric.ToString() + "'" + "," + "'" + this.backFabric.ToString() + "'" + "," + "'" + this.charm.ToString() + "'" + "," + "'" + this.condition.ToString() + "'" + "," + "'" + this.location.ToString() + "'" + "," + "'" + this.dateCreated.ToString() + "'" + "," + Convert.ToDouble(this.cost.ToString()) + "," + Convert.ToDouble(this.price.ToString()) + ")"; SQLiteCommand command = new SQLiteCommand(sql, main.m_dbConnection); command.ExecuteNonQuery(); main.updateInventoryGrid(); }