コード例 #1
0
        static DatabaseInstance()
        {
            Database          = new ObjectDatabase.ObjectDatabase("SysDev2019.accdb", logCallback: OnLog);
            ProductTable      = new DataTable <Product>("商品");
            ManufacturerTable = new DataTable <Manufacturer>("メーカー");
            DepartmentTable   = new DataTable <Department>("部署");
            EmployeeTable     = new DataTable <Employee>("社員");
            OrderTable        = new DataTable <Order>("受注");
            OrderingTable     = new DataTable <Ordering>("発注");
            StockTable        = new DataTable <Stock>("在庫");
            Database.AddTable(ManufacturerTable);
            Database.AddTable(ProductTable);
            Database.AddTable(DepartmentTable);
            Database.AddTable(EmployeeTable);
            Database.AddTable(OrderingTable);
            Database.AddTable(OrderTable);
            Database.AddTable(StockTable);

            ProductTable.Union(ManufacturerTable);
            EmployeeTable.Union(DepartmentTable);
            OrderTable.Union(EmployeeTable, "EmployeeId");
            OrderTable.Union(ProductTable, "ProductId");
            OrderingTable.Union(ProductTable, "ProductId");
            OrderingTable.Union(EmployeeTable, "EmployeeId");
            StockTable.Union(ProductTable);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: hiroki19990625/SysDev2019
        static void Main(string[] args)
        {
            string cmd = Console.ReadLine();

            Database                 database          = new Database("../../../SysDev2019/SysDev2019.accdb", logCallback: OnLog);
            DataTable <Product>      productTable      = new DataTable <Product>("商品");
            DataTable <Manufacturer> manufacturerTable = new DataTable <Manufacturer>("メーカー");
            DataTable <Department>   departmentTable   = new DataTable <Department>("部署");
            DataTable <Employee>     employeeTable     = new DataTable <Employee>("社員");
            DataTable <Order>        orderTable        = new DataTable <Order>("受注");
            DataTable <Ordering>     orderingTable     = new DataTable <Ordering>("発注");
            DataTable <Stock>        stockTable        = new DataTable <Stock>("在庫");

            database.AddTable(manufacturerTable);
            database.AddTable(productTable);
            database.AddTable(departmentTable);
            database.AddTable(employeeTable);
            database.AddTable(orderingTable);
            database.AddTable(orderTable);
            database.AddTable(stockTable);

            productTable.Union(manufacturerTable);
            employeeTable.Union(departmentTable);
            orderTable.Union(employeeTable, "EmployeeId");
            orderTable.Union(productTable, "ProductId");
            orderingTable.Union(productTable, "ProductId");
            orderingTable.Union(employeeTable, "EmployeeId");
            stockTable.Union(productTable);

            database.GenerateCode("SysDev2019");

            if (cmd == "seed")
            {
                // All Delete
                stockTable.Delete(p => true);
                productTable.Delete(p => true);
                manufacturerTable.Delete(p => true);

                List <Manufacturer> manufacturers = new List <Manufacturer>();
                for (int i = 0; i < 100; i++)
                {
                    manufacturers.Add(new Manufacturer
                    {
                        ManufacturerId   = i.ToString(),
                        ManufacturerName = $"化粧品メーカー_{i}"
                    });
                }

                manufacturerTable.Insert(manufacturers.ToArray());

                Random         r        = new Random();
                List <Product> products = new List <Product>();
                for (int i = 0; i < 12000; i++)
                {
                    var price = r.Next(100, 1000) * 10;

                    products.Add(new Product
                    {
                        ProductId      = i.ToString(),
                        ManufacturerId = r.Next(0, 100).ToString(),
                        ProductName    = price >= 6000 ? $"高級化粧品_{i}" : $"化粧品_{i}",
                        UnitPrice      = price
                    });
                }

                productTable.Insert(products.ToArray());

                stockTable.Insert(new Stock
                {
                    StockId       = Guid.NewGuid().ToString(),
                    ProductId     = "0",
                    StockQuantity = 1000,
                    ReorderPoint  = 400,
                    OrderQuantity = 1000
                });
                stockTable.Insert(new Stock
                {
                    StockId       = Guid.NewGuid().ToString(),
                    ProductId     = "1",
                    StockQuantity = 600,
                    ReorderPoint  = 500,
                    OrderQuantity = 1000
                });
                stockTable.Insert(new Stock
                {
                    StockId       = Guid.NewGuid().ToString(),
                    ProductId     = "2",
                    StockQuantity = 100,
                    ReorderPoint  = 10,
                    OrderQuantity = 100
                });
                stockTable.Insert(new Stock
                {
                    StockId       = Guid.NewGuid().ToString(),
                    ProductId     = "3",
                    StockQuantity = 3000,
                    ReorderPoint  = 400,
                    OrderQuantity = 1000
                });
            }
            else if (cmd == "user")
            {
                Console.Write("ID >> ");
                string id = Console.ReadLine();
                Console.Write("Name >> ");
                string name = Console.ReadLine();
                Console.Write("Pass >> ");
                string pass = ToSha256(Console.ReadLine());
                Console.Write("DeptId >> ");
                string dept = Console.ReadLine();
                Console.WriteLine("PasswordHash: " + pass);

                Employee employee = new Employee {
                    EmployeeId = id, Name = name, Password = pass, DepartmentId = dept
                };
                employeeTable.Insert(employee);
            }
        }
コード例 #3
0
        static DatabaseInstance()
        {
            Database               = new ObjectDatabase.ObjectDatabase("../../DB/db.accdb", logCallback: OnLog);
            ProductTable           = new DataTable <Product>("商品");
            ShopTable              = new DataTable <Shop>("ショップ");
            StatusTable            = new DataTable <Status>("ステータス");
            AffiliationTable       = new DataTable <Affiliation>("所属");
            MakerTable             = new DataTable <Maker>("メーカー");
            PigeonTable            = new DataTable <Pigeon>("ハト");
            StockTable             = new DataTable <Stock>("在庫");
            ReciveOrderTable       = new DataTable <ReciveOrder>("受注");
            SalesOfficeTable       = new DataTable <SalesOffice>("営業所");
            EmployeeTable          = new DataTable <Employee>("社員");
            ReciveOrderDetailTable = new DataTable <ReciveOrderDetail>("受注明細");
            IssueTabele            = new DataTable <Issue>("出庫");
            OrderTable             = new DataTable <Order>("発注");
            OrderDetailTable       = new DataTable <OrderDetail>("発注明細");
            SettingTable           = new DataTable <Setting>("設定");
            StoringTable           = new DataTable <Storing>("入庫");

            Database.AddTable(ProductTable);
            Database.AddTable(ShopTable);
            Database.AddTable(StatusTable);
            Database.AddTable(AffiliationTable);
            Database.AddTable(MakerTable);
            Database.AddTable(PigeonTable);
            Database.AddTable(StockTable);
            Database.AddTable(ReciveOrderTable);
            Database.AddTable(SalesOfficeTable);
            Database.AddTable(EmployeeTable);
            Database.AddTable(ReciveOrderDetailTable);
            Database.AddTable(IssueTabele);
            Database.AddTable(OrderTable);
            Database.AddTable(OrderDetailTable);
            Database.AddTable(SettingTable);
            Database.AddTable(StoringTable);

            ProductTable.Union(MakerTable, nameof(Maker.MakerId));
            ProductTable.Union(SettingTable, nameof(Setting.SettingId));
            PigeonTable.Union(StatusTable, nameof(Status.StatusId));
            StockTable.Union(ProductTable);
            ReciveOrderTable.Union(EmployeeTable, nameof(Employee.EmployeeId));
            ReciveOrderTable.Union(SalesOfficeTable, nameof(SalesOffice.SalesOfficeId));
            ReciveOrderTable.Union(ShopTable, nameof(Shop.ShopId));
            EmployeeTable.Union(AffiliationTable);
            ReciveOrderDetailTable.Union(ReciveOrderTable, nameof(ReciveOrder.ReciveOrderId));
            ReciveOrderDetailTable.Union(ProductTable, nameof(Product.ProductId));
            IssueTabele.Union(ReciveOrderDetailTable, nameof(ReciveOrderDetail.ReciveOrderDetailId));
            IssueTabele.Union(EmployeeTable, nameof(Employee.EmployeeId));
            OrderTable.Union(EmployeeTable);
            OrderDetailTable.Union(OrderTable, nameof(Order.OrderId));
            OrderDetailTable.Union(ProductTable, nameof(Product.ProductId));
            StoringTable.Union(OrderDetailTable, nameof(OrderDetail.OrderDetailId));
            StoringTable.Union(EmployeeTable, nameof(Employee.EmployeeId));
        }