Beispiel #1
0
 CommodityChapters(Guest19.Database.CommodityChapters commodityChapters)
 {
     Id = commodityChapters.Id;
     CommoditySectionId = commodityChapters.CommoditySectionId;
     Code        = commodityChapters.Code;
     Name        = commodityChapters.Name;
     Description = commodityChapters.Description;
     Active      = commodityChapters.Active;
 }
Beispiel #2
0
        //public List<CommodityRoots> Children { get; set; }


        #endregion

        #region Methods

        public bool Save()
        {
            bool saved;

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

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

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

                        context.CommodityChapters.InsertOnSubmit(newDbItem);//insert new records in db
                        context.SubmitChanges();
                        saved = true;
                    }
                }
            }
            catch (Exception ex)
            {
                saved = false;
            }
            return(saved);
        }
Beispiel #3
0
 partial void DeleteCommodityChapters(CommodityChapters instance);
Beispiel #4
0
 partial void UpdateCommodityChapters(CommodityChapters instance);
Beispiel #5
0
 partial void InsertCommodityChapters(CommodityChapters instance);