public static void Get() { IBillingRepository <Product> products = new BillingRepository <Product>(Help.Context); IBillingRepository <Stock> stocks = new BillingRepository <Stock>(Help.Context); IBillingRepository <Category> categories = new BillingRepository <Category>(Help.Context); DataTable rawData = Help.OpenExcel("Products"); int N = 0; foreach (DataRow row in rawData.Rows) { int oldId = Help.getInteger(row, 0); Product prod = new Product() { Name = Help.getString(row, 1), Unit = Help.getString(row, 2), Price = Help.getDouble(row, 4), Category = categories.Get(Help.dicCatt[Help.getInteger(row, 3)]) }; N++; products.Insert(prod); products.Commit(); stocks.Insert(new Stock() { Id = prod.Id }); products.Commit(); Help.dicProd.Add(oldId, prod.Id); } Console.WriteLine(N); }
public static void Get() { IBillingRepository <Shipper> shippers = new BillingRepository <Shipper>(Help.Context); IBillingRepository <Town> towns = new BillingRepository <Town>(Help.Context); DataTable rawData = Help.OpenExcel("Shippers"); int N = 0; foreach (DataRow row in rawData.Rows) { int oldId = Help.getInteger(row, 0); string zip = Help.getString(row, 1); Town town = towns.Get().FirstOrDefault(x => x.Zip == zip); Shipper ship = new Shipper() { Name = Help.getString(row, 2), Address = Help.getString(row, 3), Town = town }; N++; shippers.Insert(ship); shippers.Commit(); Help.dicShip.Add(oldId, ship.Id); } Console.WriteLine(N); }
public static void Get() { IBillingRepository <Town> towns = new BillingRepository <Town>(Help.Context); DataTable rawData = Help.OpenExcel("Towns"); int N = 0; foreach (DataRow row in rawData.Rows) { try { Town town = new Town() { Zip = Help.getString(row, 0), Name = Help.getString(row, 1), Region = (Region)Help.getInteger(row, 2) }; N++; towns.Insert(town); } catch (Exception ex) { Console.WriteLine(ex.Message); } } towns.Commit(); Console.WriteLine(N); }
public static void Get() { IBillingRepository <Customer> customers = new BillingRepository <Customer>(Help.Context); IBillingRepository <Town> towns = new BillingRepository <Town>(Help.Context); DataTable rawData = Help.OpenExcel("Customers"); int N = 0; foreach (DataRow row in rawData.Rows) { try { int oldId = Help.getInteger(row, 0); string zip = Help.getString(row, 2); Customer customer = new Customer() { Name = Help.getString(row, 1), Address = Help.getString(row, 3), Town = towns.Get().FirstOrDefault(x => x.Zip == zip) }; customers.Insert(customer); customers.Commit(); N++; Help.dicCust.Add(oldId, customer.Id); } catch (Exception ex) { Console.WriteLine(ex.Message); } } Console.WriteLine(N); }
public static void Get() { IBillingRepository <Category> categories = new BillingRepository <Category>(Help.Context); DataTable rawData = Help.OpenExcel("Categories"); int N = 0; foreach (DataRow row in rawData.Rows) { try { int oldId = Help.getInteger(row, 0); Category cat = new Category() { Name = Help.getString(row, 1) }; N++; categories.Insert(cat); categories.Commit(); Help.dicCatt.Add(oldId, cat.Id); } catch (Exception ex) { Console.WriteLine(ex.Message); } } Console.WriteLine(N); }
public static void Get() { IBillingRepository <Invoice> invoices = new BillingRepository <Invoice>(Help.Context); IBillingRepository <Shipper> shippers = new BillingRepository <Shipper>(Help.Context); IBillingRepository <Agent> agents = new BillingRepository <Agent>(Help.Context); IBillingRepository <Customer> customers = new BillingRepository <Customer>(Help.Context); DataTable rawData = Help.OpenExcel("Invoices"); int N = 0; foreach (DataRow row in rawData.Rows) { Shipper shipper = shippers.Get(Help.dicShip[Help.getInteger(row, 3)]); Agent agent = agents.Get(Help.dicAgen[Help.getInteger(row, 4)]); Customer customer = customers.Get(Help.dicCust[Help.getInteger(row, 5)]); Invoice invoice = new Invoice() { InvoiceNo = Help.getString(row, 0), Date = Help.getDate(row, 1), ShippedOn = Help.getDate(row, 2), Shipper = shipper, Agent = agent, Customer = customer, Vat = Help.getDouble(row, 6), Shipping = Help.getDouble(row, 7) }; N++; invoices.Insert(invoice); } invoices.Commit(); Console.WriteLine(N); }
public static void Get() { IBillingRepository <Item> items = new BillingRepository <Item>(Help.Context); IBillingRepository <Invoice> invoices = new BillingRepository <Invoice>(Help.Context); IBillingRepository <Product> products = new BillingRepository <Product>(Help.Context); DataTable rawData = Help.OpenExcel("Items"); int N = 0; foreach (DataRow row in rawData.Rows) { string invoiceNo = Help.getString(row, 0); Invoice invoice = invoices.Get().FirstOrDefault(x => x.InvoiceNo == invoiceNo); Product product = products.Get(Help.dicProd[Help.getInteger(row, 1)]); Item item = new Item() { Invoice = invoice, Product = product, Quantity = Help.getInteger(row, 2), Price = Help.getDouble(row, 3) }; N++; items.Insert(item); } items.Commit(); Console.WriteLine(N); }
public static void Get() { IBillingRepository <Procurement> procurements = new BillingRepository <Procurement>(Help.Context); IBillingRepository <Supplier> suppliers = new BillingRepository <Supplier>(Help.Context); IBillingRepository <Product> products = new BillingRepository <Product>(Help.Context); DataTable rawData = Help.OpenExcel("Procurements"); int N = 0; foreach (DataRow row in rawData.Rows) { Supplier supplier = suppliers.Get(Help.dicSupp[Help.getInteger(row, 2)]); Product product = products.Get(Help.dicProd[Help.getInteger(row, 3)]); Procurement procurement = new Procurement() { Document = Help.getString(row, 0), Date = Help.getDate(row, 1), Supplier = supplier, Product = product, Quantity = Help.getInteger(row, 4), Price = Help.getDouble(row, 5) }; N++; procurements.Insert(procurement); } procurements.Commit(); Console.WriteLine(N); }
public static void Get() { IBillingRepository <Event> histories = new BillingRepository <Event>(Help.Context); IBillingRepository <Invoice> invoices = new BillingRepository <Invoice>(Help.Context); int N = 0; DataTable rawData = Help.OpenExcel("Histories"); foreach (DataRow row in rawData.Rows) { try { string invoiceNo = Help.getString(row, 0); Event item = new Event() { Invoice = invoices.Get().FirstOrDefault(x => x.InvoiceNo == invoiceNo), Date = Help.getDate(row, 1), Status = (Status)Help.getInteger(row, 2) }; histories.Insert(item); N++; } catch (System.Exception ex) { System.Console.WriteLine(ex.Message); } } histories.Commit(); Console.WriteLine(N); }
public static void Get() { IBillingRepository <Agent> agents = new BillingRepository <Agent>(Help.Context); IBillingRepository <Town> towns = new BillingRepository <Town>(Help.Context); DataTable rawData = Help.OpenExcel("Agents"); int N = 0; foreach (DataRow row in rawData.Rows) { int oldId = Help.getInteger(row, 0); Agent agent = new Agent() { Name = Help.getString(row, 1) }; N++; string[] Zone = Help.getString(row, 2).Split('.'); foreach (string Z in Zone) { Region R = (Region)Convert.ToInt32(Z); var area = towns.Get().Where(x => x.Region == R).ToList(); foreach (var city in area) { agent.Towns.Add(city); } } agents.Insert(agent); agents.Commit(); Help.dicAgen.Add(oldId, agent.Id); } Console.WriteLine(N); }
public static void Get() { IBillingRepository <Product> products = new BillingRepository <Product>(Help.Context); IBillingRepository <Category> categories = new BillingRepository <Category>(Help.Context); IBillingRepository <Stock> stocks = new BillingRepository <Stock>(Help.Context); Random r = new Random(); DataTable rawData = Help.OpenExcel("Products"); int N = 0; foreach (DataRow row in rawData.Rows) { try { int oldId = Help.getInteger(row, 0); Category category = categories.Get(Help.dicCatt[Help.getInteger(row, 3)]); Product product = new Product() { Name = Help.getString(row, 1), Unit = Help.getString(row, 2), Price = Help.getDouble(row, 4), Category = category, }; N++; products.Insert(product); products.Commit(); stocks.Insert(new Stock() { Id = product.Id, Input = r.Next(100, 300), Output = r.Next(0, 100) }); products.Commit(); Help.dicProd.Add(oldId, product.Id); } catch (Exception ex) { Console.WriteLine(ex.Message); } } Console.WriteLine(N); }
public static void Get() { IBillingRepository <ApiUser> apiUsers = new BillingRepository <ApiUser>(Help.Context); apiUsers.Insert(new ApiUser() { Name = "Billing", AppId = "R2lnaVNjaG9vbA==", Secret = "TWlzdHJhbFRhbGVudHM=" }); apiUsers.Commit(); }
public static void Get() { IBillingRepository <Agent> agents = new BillingRepository <Agent>(Help.Context); IBillingRepository <Town> towns = new BillingRepository <Town>(Help.Context); int N = 0; DataTable rawData = Help.OpenExcel("Agents"); foreach (DataRow row in rawData.Rows) { try { int oldId = Help.getInteger(row, 0); Agent agent = new Agent() { Name = Help.getString(row, 1) }; string[] zones = Help.getString(row, 2).Split(','); foreach (string zone in zones) { Region r = (Region)Convert.ToInt32(zone); var areas = towns.Get().Where(x => x.Region == r).ToList(); foreach (var city in areas) { agent.Towns.Add(city); } } agents.Insert(agent); agents.Commit(); N++; Help.dicAgen.Add(oldId, agent.Id); } catch (Exception ex) { Console.WriteLine(ex.Message); } } Console.WriteLine(N); }