Ejemplo n.º 1
0
        public void UpdateAssetType(AssetTypeData newitem)
        {
            hasError = false;
            try
            {
                using (TraditionAssetEntities db = new TraditionAssetEntities())
                {
                    var assettype_ = db.asset_type.FirstOrDefault(x => x.asset_type_id == newitem.asset_type_id);
                    if (assettype_ != null)
                    {
                        assettype_.asset_type_name = newitem.asset_type_name;
                        assettype_.is_active       = newitem.is_active;
                        assettype_.modified_date   = DateTime.Now;

                        db.asset_type.AddOrUpdate(assettype_);
                        db.SaveChanges();
                        MessageBox.Show("Update complete");
                    }
                    else
                    {
                        MessageBox.Show("Can not update");
                    }
                }
            }
            catch (Exception ex)
            {
                errorMessage = "Update error, " + ex.Message;
                hasError     = true;
            }
        }
Ejemplo n.º 2
0
        public ObservableCollection <AssetTypeData> GetAssetType()
        {
            hasError = false;
            ObservableCollection <AssetTypeData> _asset_type = new ObservableCollection <AssetTypeData>();

            try
            {
                TraditionAssetEntities db = new TraditionAssetEntities();
                var query = db.asset_type.ToList();
                foreach (var item in query)
                {
                    AssetTypeData pTemp = new AssetTypeData(/*item*/);
                    pTemp.asset_type_id   = item.asset_type_id;
                    pTemp.asset_type_name = item.asset_type_name;
                    pTemp.is_active       = (bool)item.is_active;
                    pTemp.create_date     = (DateTime)item.create_date;
                    pTemp.modified_date   = (DateTime)item.modified_date;

                    _asset_type.Add(pTemp);
                }
            }
            catch (Exception ex)
            {
                errorMessage = "GetAsset() error, " + ex.Message;
                hasError     = true;
            }
            return(_asset_type);
        }
Ejemplo n.º 3
0
        public ObservableCollection <AssetTypeData> GetAssetTypeFromAsset(AssetData item)
        {
            hasError = false;
            ObservableCollection <AssetTypeData> _result = new ObservableCollection <AssetTypeData>();

            try
            {
                TraditionAssetEntities db = new TraditionAssetEntities();

                var query = db.asset_type.FirstOrDefault(x => x.asset_type_id == item.Asset_type_id);

                if (query != null)
                {
                    AssetTypeData pTemp = new AssetTypeData(/*item*/);
                    pTemp.asset_type_id   = query.asset_type_id;
                    pTemp.asset_type_name = query.asset_type_name;

                    _result.Add(pTemp);
                }
                else
                {
                    MessageBox.Show("NOT FOUND");
                }
            }
            catch (Exception ex)
            {
                errorMessage = "GetAssetTypeFromAsset() error, " + ex.Message;
                hasError     = true;
            }
            return(_result);
        }
Ejemplo n.º 4
0
 public void AddAssetType(AssetTypeData item)
 {
     hasError = false;
     try
     {
         TraditionAssetEntities db = new TraditionAssetEntities();
         var data = new asset_type()
         {
             asset_type_name = item.asset_type_name,
             is_active       = item.is_active,
             create_date     = DateTime.Now,
             modified_date   = DateTime.Now
         };
         db.asset_type.Add(data);
         db.SaveChanges();
         MessageBox.Show("Insert complete");
     }
     catch (Exception ex)
     {
         errorMessage = "Add error, " + ex.Message;
         hasError     = true;
     }
 }