//THIS IS A DELETE public bool commitDelete(Guid _BouquetID) { giftShopStoreClassDataContext objBou = new giftShopStoreClassDataContext(); try { var objDelBou = objBou.brdhc_GiftShopStores.Single(x => x.BouquetID == _BouquetID); objBou.brdhc_GiftShopStores.DeleteOnSubmit(objDelBou); //if you want to delete all best to drop the table objBou.SubmitChanges(); //this will commit the changes return true; //boolean } catch (Exception e) { clsCommon.saveError(e); return false; } }
//THIS IS AN UPDATE public bool commitUpdate(Guid _BouquetID, string _Name, string _Picture, string _Price) { giftShopStoreClassDataContext objBou = new giftShopStoreClassDataContext(); try { //updating a single row at a time which row depends on the _id var objUpBou = objBou.brdhc_GiftShopStores.Single(x => x.BouquetID == _BouquetID); objUpBou.Name = _Name; objUpBou.Picture = _Picture; objUpBou.Price = _Price; objBou.SubmitChanges(); //this will commit the changes return true; //boolean } catch (Exception e) { clsCommon.saveError(e); return false; } }
//THIS IS AN INSERT public bool commitInsert(Guid _bouquetId, string _Name, string _Picture, string _Price) { giftShopStoreClassDataContext objBou = new giftShopStoreClassDataContext(); try { brdhc_GiftShopStore objNewBou = new brdhc_GiftShopStore(); objNewBou.BouquetID = _bouquetId; objNewBou.Name = _Name; objNewBou.Picture = _Picture; objNewBou.Price = _Price; objBou.brdhc_GiftShopStores.InsertOnSubmit(objNewBou); objBou.SubmitChanges(); //this will commit the changes return true; //boolean } catch (Exception e) { clsCommon.saveError(e); return false; } }