Ejemplo n.º 1
0
        //public IActionResult OnGet()
        //{
        //ViewData["Company_CompanyID"] = new SelectList(_context.Company, "CompanyID", "CompanyID");
        //ViewData["Department_DepartmentID"] = new SelectList(_context.Department, "DepartmentID", "DepartmentID");
        //ViewData["Model_ModelID"] = new SelectList(_context.Model, "ModelID", "ModelID");
        //ViewData["Supplier_SupplierID"] = new SelectList(_context.Supplier, "SupplierID", "SupplierID");
        //ViewData["License_LicenseID"] = new SelectList(_context.License, "LicenseID", "LicenseID");
        //return Page();
        //}



        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            UpdateLicense.Date                    = DateTime.Now;
            UpdateLicense.LicenseName             = License.LicenseName.ToString();
            UpdateLicense.SoftewareName           = License.SoftewareName.ToString();
            UpdateLicense.PurchaseDate            = License.PurchaseDate;
            UpdateLicense.StartDate               = License.StartDate;
            UpdateLicense.ExpireDate              = License.ExpireDate;
            UpdateLicense.PONumber                = License.PONumber.ToString();
            UpdateLicense.Attachfiles             = License.Attachfiles.ToString();
            UpdateLicense.Note                    = License.Note.ToString();
            UpdateLicense.Status                  = License.Status.ToString();
            UpdateLicense.Model_ModelID           = License.Model_ModelID;
            UpdateLicense.Supplier_SupplierID     = License.Supplier_SupplierID;
            UpdateLicense.Department_DepartmentID = License.Department_DepartmentID;
            UpdateLicense.Company_CompanyID       = License.Company_CompanyID;
            UpdateLicense.License_LicenseID       = License.LicenseID;

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

            _context.Attach(UpdateLicense).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Join_Network_Asset).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Join_Network_AssetExists(Join_Network_Asset.JoinNetAsID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Asset).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AssetExists(Asset.AssetID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            var Update = new Update_Asset();

            Update.UpdateDate              = DateTime.Now;
            Update.Asset_AssetID           = Asset.AssetID;
            Update.Employee_EmpID          = 2012;
            Update.UpdateAssetName         = Asset.AssetName;
            Update.UpdateSerailNumber      = Asset.SerailNumber;
            Update.UpdateMACAddr           = Asset.MACAddr;
            Update.UpdateInstallDate       = Asset.InstallDate;
            Update.UpdatePurchaseDate      = Asset.PurchaseDate;
            Update.UpdateExpireDate        = Asset.ExpireDate;
            Update.UpdatePONumber          = Asset.PONumber;
            Update.UpdatePrice             = Asset.Price;
            Update.UpdateWarranty          = Asset.Warranty;
            Update.Category                = Asset.Category;
            Update.UpdateNote              = Asset.Note;
            Update.UpdateStatus            = Asset.Status;
            Update.UpdateImage             = Asset.Image;
            Update.Company_CompanyID       = Asset.Company_CompanyID;
            Update.Location_LocationID     = Asset.Location_LocationID;
            Update.Department_DepartmentID = Asset.Department_DepartmentID;
            Update.Supplier_SupplierID     = Asset.Supplier_SupplierID;
            Update.Model_ModelID           = Asset.Model_ModelID;
            _context.Update_Asset.Add(Update);
            await _context.SaveChangesAsync();


            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }


            _context.Attach(License).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LicenseExists(License.LicenseID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            var Update = new Update_License();

            Update.Date = DateTime.Now;
            Update.License_LicenseID = License.LicenseID;
            Update.LicenseName       = License.LicenseName;
            Update.SoftewareName     = License.SoftewareName;
            Update.PurchaseDate      = License.PurchaseDate;
            Update.StartDate         = License.StartDate;
            Update.ExpireDate        = License.ExpireDate;
            Update.PONumber          = License.PONumber;
            Update.Attachfiles       = License.Attachfiles;
            Update.Note   = License.Note;
            Update.Status = License.Status;
            Update.Supplier_SupplierID     = License.Supplier_SupplierID;
            Update.Department_DepartmentID = License.Department_DepartmentID;
            Update.Company_CompanyID       = License.Company_CompanyID;
            Update.Employee = 2012;
            _context.Update_License.Add(Update);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Position = await _context.Position.FindAsync(id);

            Position.Status = "Unused";
            if (Position != null)
            {
                _context.Attach(Position).State = EntityState.Modified;
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Join_Asset_Asset = await _context.Join_Asset_Asset.FindAsync(id);

            Join_Asset_Asset.Status = "UNJOIN";
            if (Join_Asset_Asset != null)
            {
                _context.Attach(Join_Asset_Asset).State = EntityState.Modified;
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("../Licenses/Index"));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> OnPostAsync(List <IFormFile> imageFiles)
        {
            long size = imageFiles.Sum(f => f.Length);

            foreach (var formFile in imageFiles)
            {
                if (formFile.Length > 0)
                {
                    var filePath = Path.GetTempFileName();

                    using (var stream = System.IO.File.Create(filePath))
                    {
                        await formFile.CopyToAsync(stream);
                    }
                }
            }

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Asset).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AssetExists(Asset.AssetID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Network).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NetworkExists(Network.NetworkID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            var Update = new Update_Network();

            Update.Date = DateTime.Now;
            Update.Network_NetworkID = Network.NetworkID;
            Update.Employee_EmpID    = 2012;
            Update.NetworkName       = Network.NetworkName;
            Update.IpAddr            = Network.IpAddr;
            Update.Note     = Network.Note;
            Update.Password = Network.Password;
            Update.Status   = Network.Status;
            _context.Update_Network.Add(Update);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Join_Asset_Emp = await _context.Join_Asset_Emp.FindAsync(id);

            Join_Asset_Emp.Status = "UNJOIN";
            var AssetUpdate = await _context.Asset.FindAsync(Join_Asset_Emp.Asset_AssetID);

            AssetUpdate.Status = "InStock";
            await _context.SaveChangesAsync();

            if (Join_Asset_Emp != null)
            {
                _context.Attach(Join_Asset_Emp).State = EntityState.Modified;
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("../Employees/Index"));
        }