Exemple #1
0
 CommodityRoots(Guest19.Database.CommodityRoots commodityRoots)
 {
     Id = commodityRoots.Id;
     CommodityChapterId = commodityRoots.CommodityChapterId;
     Code        = commodityRoots.Code;
     Name        = commodityRoots.Name;
     Description = commodityRoots.Description;
     Active      = commodityRoots.Active;
 }
Exemple #2
0
        public bool Save()
        {
            bool saved;

            try
            {
                using (var context = new Guest19DataContext())
                {
                    var dbItem = context.CommodityRoots.SingleOrDefault(i => i.Id == this.Id);

                    //update
                    if (dbItem != null)
                    {
                        dbItem.Active             = this.Active;
                        dbItem.Code               = this.Code;
                        dbItem.CommodityChapterId = this.CommodityChapterId;
                        dbItem.Description        = this.Description;
                        dbItem.Name               = this.Name;

                        context.SubmitChanges();//update il db
                        saved = true;
                    }
                    //new
                    else
                    {
                        var newDbItem = new Guest19.Database.CommodityRoots();
                        newDbItem.Active             = this.Active;
                        newDbItem.Code               = this.Code;
                        newDbItem.CommodityChapterId = this.CommodityChapterId;
                        newDbItem.Description        = this.Description;
                        newDbItem.Name               = this.Name;

                        context.CommodityRoots.InsertOnSubmit(newDbItem);//insert new records in db
                        context.SubmitChanges();
                        saved = true;
                    }
                }
            }
            catch (Exception ex)
            {
                saved = false;
            }
            return(saved);
        }
Exemple #3
0
 partial void DeleteCommodityRoots(CommodityRoots instance);
Exemple #4
0
 partial void UpdateCommodityRoots(CommodityRoots instance);
Exemple #5
0
 partial void InsertCommodityRoots(CommodityRoots instance);
Exemple #6
0
 private void detach_CommodityRoots(CommodityRoots entity)
 {
     this.SendPropertyChanging();
     entity.CommodityChapters = null;
 }