예제 #1
0
        public async Task <IActionResult> OnPostAsync(IFormFile Excel)
        {
            using (var reader = new StreamReader(Excel.OpenReadStream()))
            {
                while (!reader.EndOfStream)
                {
                    var line   = reader.ReadLine();
                    var values = line.Split(',');
                    if (values[0] != null)
                    {
                        _context.Department.AddRange(
                            new Department
                        {
                            DepartmentName = values[0],
                            Image          = values[1],
                            Status         = "Using"
                        }
                            );
                    }
                    else
                    {
                        break;
                    }
                }
            }

            _context.SaveChanges();

            return(RedirectToPage("./Index"));
        }
예제 #2
0
        public async Task <IActionResult> OnPostAsync(IFormFile Excel)
        {
            using (var reader = new StreamReader(Excel.OpenReadStream()))
            {
                while (!reader.EndOfStream)
                {
                    var line   = reader.ReadLine();
                    var values = line.Split(',');
                    if (values[0] != null)
                    {
                        _context.Supplier.AddRange(
                            new Supplier
                        {
                            SupplierName = values[0],
                            ContactName  = values[1],
                            Address      = values[2],
                            Email        = values[3],
                            URL          = values[4],
                            Note         = values[5],
                            Image        = values[6],
                            Status       = "Using"
                        }
                            );
                    }
                    else
                    {
                        break;
                    }
                }
            }

            _context.SaveChanges();

            return(RedirectToPage("./Index"));
        }
예제 #3
0
        public async Task <IActionResult> OnPostAsync(IFormFile Excel)
        {
            using (var reader = new StreamReader(Excel.OpenReadStream()))
            {
                while (!reader.EndOfStream)
                {
                    var line   = reader.ReadLine();
                    var values = line.Split(',');
                    if (values[0] != null)
                    {
                        _context.Model.AddRange(
                            new Model
                        {
                            ModelName     = values[0],
                            Note          = values[1],
                            Status        = "Using",
                            Brand_BrandID = Int32.Parse(values[2])
                        }
                            );
                    }
                    else
                    {
                        break;
                    }
                }
            }

            _context.SaveChanges();

            return(RedirectToPage("./Index"));
        }
예제 #4
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new tbkk_ACContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <tbkk_ACContext> >()))
            {
                // Look for any movies.
                if (context.Brand.Any())
                {
                    return;   // DB has been seeded
                }

                context.Brand.AddRange(
                    new Brand
                {
                    BrandName = "Intel",
                    Image     = "Intel_Inside.jpg",
                    Status    = "Using",
                }



                    );
                context.SaveChanges();
            }
        }
예제 #5
0
        public async Task <IActionResult> OnPostImportAsync(IFormFile Excel)
        {
            try
            {
                using (var reader = new StreamReader(Excel.OpenReadStream()))
                {
                    while (!reader.EndOfStream)
                    {
                        var line   = reader.ReadLine();
                        var values = line.Split(',');
                        if (values[0] != null)
                        {
                            _context.Asset.AddRange(
                                new Asset
                            {
                                AssetName               = values[0],
                                SerailNumber            = values[1],
                                MACAddr                 = values[2],
                                InstallDate             = DateTime.Parse(values[3]),
                                PurchaseDate            = DateTime.Parse(values[4]),
                                ExpireDate              = DateTime.Parse(values[5]),
                                PONumber                = values[6],
                                Price                   = values[7],
                                Warranty                = Int32.Parse(values[8]),
                                Category                = Int32.Parse(values[9]),
                                Note                    = values[10],
                                Image                   = values[11],
                                Company_CompanyID       = Int32.Parse(values[12]),
                                Location_LocationID     = Int32.Parse(values[13]),
                                Department_DepartmentID = Int32.Parse(values[14]),
                                Supplier_SupplierID     = Int32.Parse(values[15]),
                                Model_ModelID           = Int32.Parse(values[16]),
                                Status                  = "InStock"
                            }
                                );
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            catch (InvalidCastException e)
            {
            }

            _context.SaveChanges();

            return(RedirectToPage("./Index"));
        }
예제 #6
0
        public async Task <IActionResult> OnPostAsync(IFormFile Excel)
        {
            using (var reader = new StreamReader(Excel.OpenReadStream()))
            {
                while (!reader.EndOfStream)
                {
                    var line   = reader.ReadLine();
                    var values = line.Split(',');
                    if (values[0] != null)
                    {
                        _context.Employee.AddRange(
                            new Employee
                        {
                            FirstName                   = values[0],
                            LastName                    = values[1],
                            Gender                      = values[2],
                            Email                       = values[3],
                            Call                        = values[4],
                            Line                        = values[5],
                            Image                       = values[6],
                            Addr                        = values[7],
                            Date                        = DateTime.Parse(values[8]),
                            Status                      = "Using",
                            Company_CompanyID           = Int32.Parse(values[9]),
                            Department_DepartmentID     = Int32.Parse(values[10]),
                            Location_LocationID         = Int32.Parse(values[11]),
                            EmployeeType_EmployeeTypeID = Int32.Parse(values[12]),
                            Position_PositionID         = Int32.Parse(values[13])
                        }
                            );
                    }
                    else
                    {
                        break;
                    }
                }
            }

            _context.SaveChanges();

            return(RedirectToPage("./Index"));
        }
예제 #7
0
        public async Task <IActionResult> OnPostAsync(IFormFile Excel)
        {
            using (var reader = new StreamReader(Excel.OpenReadStream()))
            {
                while (!reader.EndOfStream)
                {
                    var line   = reader.ReadLine();
                    var values = line.Split(',');
                    if (values[0] != null)
                    {
                        _context.License.AddRange(
                            new License
                        {
                            LicenseName             = values[0],
                            SoftewareName           = values[1],
                            PurchaseDate            = DateTime.Parse(values[2]),
                            StartDate               = DateTime.Parse(values[3]),
                            ExpireDate              = DateTime.Parse(values[4]),
                            PONumber                = values[5],
                            Attachfiles             = values[6],
                            Note                    = values[7],
                            Status                  = "Using",
                            Supplier_SupplierID     = Int32.Parse(values[8]),
                            Department_DepartmentID = Int32.Parse(values[9]),
                            Company_CompanyID       = Int32.Parse(values[10])
                        }
                            );
                    }
                    else
                    {
                        break;
                    }
                }
            }

            _context.SaveChanges();

            return(RedirectToPage("./Index"));
        }
예제 #8
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new tbkk_ACContext(
                       serviceProvider.GetRequiredService <DbContextOptions <tbkk_ACContext> >()))
            {
                // Look for any movies.

                if (context.EmployeeType.Any())
                {
                    return;   // DB has been seeded
                }

                context.Brand.AddRange(
                    new Brand
                {
                    BrandName = "Intel",
                    Image     = "pingpong.jpeg",
                    Status    = "In stock"
                }
                    );
                context.Brand.AddRange(
                    new Brand
                {
                    BrandName = "Microsoft",
                    Image     = "pingpong.jpeg",
                    Status    = "In stock"
                }
                    );
                context.Category.AddRange(
                    new Category
                {
                    CategoryName = "Mouse",
                    Image        = "pingpong.jpeg",
                    TypeName     = "Accessory",
                    Status       = "In stock"
                }
                    );
                context.Category.AddRange(
                    new Category
                {
                    CategoryName = "Microsoft Office",
                    Image        = "pingpong.jpeg",
                    TypeName     = "License",
                    Status       = "In stock"
                }
                    );
                context.Company.AddRange(
                    new Company
                {
                    CompanyName = "Branch 1",
                    Image       = "pingpong.jpeg",
                    Status      = "Using"
                }
                    );
                context.Company.AddRange(
                    new Company
                {
                    CompanyName = "Branch 2",
                    Image       = "pingpong.jpeg",
                    Status      = "Using"
                }
                    );
                context.Department.AddRange(
                    new Department
                {
                    DepartmentName = "IT Service",
                    Image          = "pingpong.jpeg",
                    Status         = "Using"
                }
                    );
                context.Department.AddRange(
                    new Department
                {
                    DepartmentName = "Human Resourse",
                    Image          = "pingpong.jpeg",
                    Status         = "Using"
                }
                    );
                context.EmployeeType.AddRange(
                    new EmployeeType
                {
                    EmployeeTypeName = "Full-time",
                    Status           = "Using"
                }
                    );
                context.EmployeeType.AddRange(
                    new EmployeeType
                {
                    EmployeeTypeName = "Part-time",
                    Status           = "Using"
                }
                    );
                context.Location.AddRange(
                    new Location
                {
                    LocationName = "building 1, Floor 2",
                    Note         = "-",
                    Status       = "Using"
                }
                    );
                context.Location.AddRange(
                    new Location
                {
                    LocationName = "building 2, Floor 2",
                    Note         = "-",
                    Status       = "Using"
                }
                    );
                context.Network.AddRange(
                    new Network
                {
                    NetworkName = "B2-F2",
                    IpAddr      = "8888.8888.8888",
                    Note        = "-",
                    Password    = "******",
                    Status      = "Using"
                }
                    );
                context.Network.AddRange(
                    new Network
                {
                    NetworkName = "B2-F1",
                    IpAddr      = "8888.8888.8888",
                    Note        = "-",
                    Password    = "******",
                    Status      = "Using"
                }
                    );
                context.Position.AddRange(
                    new Position
                {
                    PositionName = "personnel",
                    Status       = "Using"
                }
                    );
                context.Position.AddRange(
                    new Position
                {
                    PositionName = "head",
                    Status       = "Using"
                }
                    );
                context.Supplier.AddRange(
                    new Supplier
                {
                    SupplierName = "nan",
                    ContactName  = "-",
                    Address      = "-",
                    Email        = "-",
                    URL          = "-",
                    Image        = "pingpong.jpeg",
                    Status       = "Using"
                }
                    );
                context.Supplier.AddRange(
                    new Supplier
                {
                    SupplierName = "boom",
                    ContactName  = "-",
                    Address      = "-",
                    Email        = "-",
                    URL          = "-",
                    Image        = "pingpong.jpeg",
                    Status       = "Using"
                }
                    );
                context.SaveChanges();
            }
            using (var context = new tbkk_ACContext(
                       serviceProvider.GetRequiredService <DbContextOptions <tbkk_ACContext> >()))
            {
                // Look for any movies.

                if (context.Model.Any())
                {
                    return;   // DB has been seeded
                }
                context.Model.AddRange(
                    new Model
                {
                    ModelName           = "9300 dpi",
                    Note                = "-",
                    Brand_BrandID       = 1,
                    Category_CategoryID = 1,
                    Status              = "Using"
                }
                    );
                context.Model.AddRange(
                    new Model
                {
                    ModelName           = "-",
                    Note                = "-",
                    Brand_BrandID       = 2,
                    Category_CategoryID = 2,
                    Status              = "Using"
                }
                    );

                context.SaveChanges();
            }
            using (var context = new tbkk_ACContext(
                       serviceProvider.GetRequiredService <DbContextOptions <tbkk_ACContext> >()))
            {
                // Look for any movies.

                if (context.Employee.Any())
                {
                    return;   // DB has been seeded
                }
                context.Employee.AddRange(
                    new Employee
                {
                    FirstName                   = "Nattatida",
                    LastName                    = "Srisa",
                    Gender                      = "Female",
                    Email                       = "*****@*****.**",
                    Call                        = "092-381-3880",
                    Line                        = "xxxxxx",
                    Image                       = "pingpong.jpeg",
                    Addr                        = "Bangsean",
                    Date                        = DateTime.Parse("1989-2-12"),
                    Status                      = "Using",
                    Company_CompanyID           = 1,
                    Department_DepartmentID     = 1,
                    Location_LocationID         = 1,
                    EmployeeType_EmployeeTypeID = 1,
                    Position_PositionID         = 1
                }
                    );
                context.Employee.AddRange(
                    new Employee
                {
                    FirstName                   = "Chanon",
                    LastName                    = "Srisa",
                    Gender                      = "Male",
                    Email                       = "*****@*****.**",
                    Call                        = "092-381-3881",
                    Line                        = "xxxxxx1",
                    Image                       = "pingpong.jpeg",
                    Addr                        = "Samutprakarn",
                    Date                        = DateTime.Parse("1989-2-11"),
                    Status                      = "Using",
                    Company_CompanyID           = 2,
                    Department_DepartmentID     = 2,
                    Location_LocationID         = 2,
                    EmployeeType_EmployeeTypeID = 2,
                    Position_PositionID         = 2
                }
                    );
                context.License.AddRange(
                    new License
                {
                    LicenseName             = "xxx-xxx-xx",
                    SoftewareName           = "office",
                    PurchaseDate            = DateTime.Parse("2019-2-10"),
                    StartDate               = DateTime.Parse("2019-2-20"),
                    ExpireDate              = DateTime.Parse("2024-2-10"),
                    PONumber                = "xxxxxx-xxx",
                    Attachfiles             = "null",
                    Note                    = "-",
                    Status                  = "Using",
                    Model_ModelID           = 2,
                    Supplier_SupplierID     = 2,
                    Department_DepartmentID = 2,
                    Company_CompanyID       = 2
                }
                    );
                context.License.AddRange(
                    new License
                {
                    LicenseName             = "xxx-xxx-xx",
                    SoftewareName           = "access",
                    PurchaseDate            = DateTime.Parse("2019-2-10"),
                    StartDate               = DateTime.Parse("2019-2-20"),
                    ExpireDate              = DateTime.Parse("2024-2-20"),
                    PONumber                = "xxxxxx-xxx",
                    Attachfiles             = "null",
                    Note                    = "-",
                    Status                  = "Using",
                    Model_ModelID           = 2,
                    Supplier_SupplierID     = 2,
                    Department_DepartmentID = 2,
                    Company_CompanyID       = 2
                }
                    );
                context.Asset.AddRange(
                    new Asset
                {
                    AssetName               = "PC-001",
                    SerailNumber            = "xxx-xxx-xx1",
                    MACAddr                 = "xxx.xxx.xxx",
                    InstallDate             = DateTime.Parse("2019-2-20"),
                    PurchaseDate            = DateTime.Parse("2019-2-10"),
                    ExpireDate              = DateTime.Parse("2024-2-10"),
                    PONumber                = "xxx-xxx-xxx",
                    Price                   = "19,200",
                    Warranty                = 3,
                    Type                    = "Asset",
                    Note                    = "-",
                    Status                  = "Using",
                    Company_CompanyID       = 2,
                    Location_LocationID     = 2,
                    Department_DepartmentID = 2,
                    Supplier_SupplierID     = 2,
                    Employee_EmployeeID     = 1,
                    Image                   = "pingpong.jpeg"
                }
                    );
                context.Asset.AddRange(
                    new Asset
                {
                    AssetName               = "KB-001",
                    SerailNumber            = "xxx-xxx-xx1",
                    MACAddr                 = "xxx.xxx.xxx",
                    InstallDate             = DateTime.Parse("2019-2-12"),
                    PurchaseDate            = DateTime.Parse("2019-2-10"),
                    ExpireDate              = DateTime.Parse("2024-2-12"),
                    PONumber                = "xxx-xxx-xxx",
                    Price                   = "1,200",
                    Warranty                = 1,
                    Type                    = "Accessory",
                    Note                    = "-",
                    Status                  = "Using",
                    Company_CompanyID       = 2,
                    Location_LocationID     = 2,
                    Department_DepartmentID = 2,
                    Supplier_SupplierID     = 2,
                    Employee_EmployeeID     = 1,
                    Image                   = "pingpong.jpeg"
                }
                    );
                context.SaveChanges();
            }
            using (var context = new tbkk_ACContext(
                       serviceProvider.GetRequiredService <DbContextOptions <tbkk_ACContext> >()))
            {
                // Look for any movies.

                if (context.Login.Any())
                {
                    return;   // DB has been seeded
                }
                context.Login.AddRange(
                    new Login
                {
                    Username            = "******",
                    Password            = "******",
                    Employee_EmployeeID = 1
                }
                    );


                context.SaveChanges();
            }
        }