Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,DateOfBuy,DateOfUseStart,Name,Identfier,OriginalValue,DepreciationRate,UpgradeValue,UpdatedOriginalValue,LiquidationDate,LiquidationReason")] FixedAssets fixedAssets)
        {
            if (id != fixedAssets.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(fixedAssets);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FixedAssetsExists(fixedAssets.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(fixedAssets));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("AssetID,AssetName,DepartmentID,DateCreated,LastUsed,UsefulLife,Price,DepreciationRate,DepreciatedAmount")] FixedAssets fixedAssets)
        {
            if (ModelState.IsValid)
            {
                var vidaUtil = fixedAssets.UsefulLife;
                var precio   = fixedAssets.Price;


                var depreRate = 1 / vidaUtil;
                depreRate = depreRate * 2;
                var depreAmount = precio * depreRate;

                fixedAssets.DepreciationRate  = depreRate;
                fixedAssets.DepreciatedAmount = depreAmount;

                fixedAssets.DateCreated = System.DateTime.Today;
                fixedAssets.LastUsed    = System.DateTime.Today;

                _context.Add(fixedAssets);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentID"] = new SelectList(_context.Departments, "DepartmentID", "DepartmentID", fixedAssets.DepartmentID);
            return(View(fixedAssets));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("AssetID,AssetName,DepartmentID,DateCreated,LastUsed,UsefulLife,Price,DepreciationRate,DepreciatedAmount")] FixedAssets fixedAssets)
        {
            if (id != fixedAssets.AssetID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(fixedAssets);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FixedAssetsExists(fixedAssets.AssetID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentID"] = new SelectList(_context.Departments, "DepartmentID", "DepartmentID", fixedAssets.DepartmentID);
            return(View(fixedAssets));
        }
Exemplo n.º 4
0
        private List <FixedAssets> GetSelectedItem()
        {
            List <FixedAssets> items = new List <FixedAssets>();
            FixedAssets        itm   = new FixedAssets();

            itm.lngSerialNo = Convert.ToInt64(DG.CurrentRow.Cells[0].Value.ToString());

            items.Add(itm);
            return(items);
        }
Exemplo n.º 5
0
        // GET: FixedAssets
        public async Task <IActionResult> Index()
        {
            FixedAssets fixedAssets = new FixedAssets();

            fixedAssets.DateOfBuy      = DateTime.Now.Date;
            fixedAssets.DateOfUseStart = DateTime.Now.Date;
            fixedAssets.Identfier      = fixedAssets.getNumber(_context);
            ViewData["FixedAssets"]    = fixedAssets;
            return(View(await _context.FixedAssets.ToListAsync()));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("Id,DateOfBuy,DateOfUseStart,Name,Identfier,OriginalValue,DepreciationRate,UpgradeValue,UpdatedOriginalValue,LiquidationDate,LiquidationReason")] FixedAssets fixedAssets)
        {
            if (ModelState.IsValid)
            {
                _context.Add(fixedAssets);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(fixedAssets));
        }
Exemplo n.º 7
0
        private void EnterButton_Click(object sender, RoutedEventArgs e)
        {
            FixedAssets updFA = (from fa in _db.FixedAssets
                                 where fa.ID == id
                                 select fa).Single();

            updFA.InitialCost            = Convert.ToInt32(InitialCostTextBox.Text);
            updFA.DateOfEntry            = Convert.ToDateTime(DateofEntryDatePicker.Text);
            updFA.ExpirationDate         = Convert.ToDateTime(ExpirationDateDatePicker.Text);
            updFA.GroupName              = GroupNameComboBox.Text;
            updFA.AnnualDepreciationRate = Convert.ToInt32(AnnualDepreciationRateTextBox.Text);
            _db.SaveChanges();
            MenuWindow.fADataGrid.ItemsSource = _db.FixedAssets.ToList();
            this.NavigationService.GoBack();
        }
        private void EnterButton_Click(object sender, RoutedEventArgs e)
        {
            FixedAssets newFA = new FixedAssets()
            {
                InitialCost            = Convert.ToInt32(InitialCostTextBox.Text),
                DateOfEntry            = Convert.ToDateTime(DateofEntryDatePicker.Text),
                ExpirationDate         = Convert.ToDateTime(ExpirationDateDatePicker.Text),
                GroupName              = GroupNameComboBox.Text,
                AnnualDepreciationRate = Convert.ToInt32(AnnualDepreciationRateTextBox.Text)
            };

            _db.FixedAssets.Add(newFA);
            _db.SaveChanges();
            MenuWindow.fADataGrid.ItemsSource = _db.FixedAssets.ToList();
            this.NavigationService.GoBack();
        }
Exemplo n.º 9
0
 public static void AddList(FixedAssets obj)
 {
     assets.Add(obj);
 }