Example #1
0
 partial void Deleteitems_table(items_table instance);
Example #2
0
 partial void Insertitems_table(items_table instance);
Example #3
0
 partial void Updateitems_table(items_table instance);
Example #4
0
        public void AddNewItem(string itemId, string categoryName, double cost, string description)
        {
            var db = new dbDataContext();
            lock (db)
            {
                var match = (from i in db.GetTable<items_table>()
                    where i.item_id == itemId
                    select i).SingleOrDefault();
                if (match == null)
                {
                    Table<items_table> itemsTable = db.GetTable<items_table>();
                    var item = new items_table
                    {
                        item_id = itemId,
                        item_num = db.GetTable<items_table>().Count(),
                        number_left = 300,
                        category_name = categoryName,
                        cost = cost,
                        item_description = description
                    };

                    itemsTable.InsertOnSubmit(item);
                    db.SubmitChanges();
                }
                else
                {
                    MessageBox.Show(ErrorsAndWarningsMessages.ErrorsAndWarningsInstance().GetError(42));
                }
            }
        }