Пример #1
0
        public void UpdateOs(OsData newitem)
        {
            hasError = false;
            try
            {
                using (TraditionAssetEntities db = new TraditionAssetEntities())
                {
                    var os_ = db.os.FirstOrDefault(x => x.os_id == newitem.os_id);
                    if (os_ != null)
                    {
                        os_.os_name       = newitem.os_name;
                        os_.is_active     = newitem.is_active;
                        os_.modified_date = DateTime.Now;

                        db.os.AddOrUpdate(os_);
                        db.SaveChanges();
                        MessageBox.Show("Update complete");
                    }
                    else
                    {
                        MessageBox.Show("Can not update");
                    }
                }
            }
            catch (Exception ex)
            {
                errorMessage = "Update error, " + ex.Message;
                hasError     = true;
            }
        }
Пример #2
0
        public ObservableCollection <OsData> GetOs()
        {
            hasError = false;
            ObservableCollection <OsData> _os = new ObservableCollection <OsData>();

            try
            {
                TraditionAssetEntities db = new TraditionAssetEntities();
                var query = db.os.ToList();
                foreach (var item in query)
                {
                    OsData pTemp = new OsData(/*item*/);
                    pTemp.os_id         = item.os_id;
                    pTemp.os_name       = item.os_name;
                    pTemp.is_active     = (bool)item.is_active;
                    pTemp.create_date   = (DateTime)item.create_date;
                    pTemp.modified_date = (DateTime)item.modified_date;

                    _os.Add(pTemp);
                }
            }
            catch (Exception ex)
            {
                errorMessage = "GetAsset() error, " + ex.Message;
                hasError     = true;
            }
            return(_os);
        }
Пример #3
0
        public ObservableCollection <OsData> GetOsFromAsset(AssetData item)
        {
            hasError = false;
            ObservableCollection <OsData> _result = new ObservableCollection <OsData>();

            try
            {
                TraditionAssetEntities db = new TraditionAssetEntities();

                var query = db.os.FirstOrDefault(x => x.os_id == item.Os_id);

                if (query != null)
                {
                    OsData pTemp = new OsData(/*item*/);
                    pTemp.os_id   = query.os_id;
                    pTemp.os_name = query.os_name;

                    _result.Add(pTemp);
                }
                else
                {
                    MessageBox.Show("NOT FOUND");
                }
            }
            catch (Exception ex)
            {
                errorMessage = "GetAssetTypeFromAsset() error, " + ex.Message;
                hasError     = true;
            }
            return(_result);
        }
Пример #4
0
 public void AddOs(OsData item)
 {
     hasError = false;
     try
     {
         TraditionAssetEntities db = new TraditionAssetEntities();
         var data = new os()
         {
             os_name       = item.os_name,
             is_active     = item.is_active,
             create_date   = DateTime.Now,
             modified_date = DateTime.Now
         };
         db.os.Add(data);
         db.SaveChanges();
         MessageBox.Show("Insert complete");
     }
     catch (Exception ex)
     {
         errorMessage = "Add error, " + ex.Message;
         hasError     = true;
     }
 }