Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Text;
- using System.Threading.Tasks;
- namespace db_fill
- {
- class Program
- {
- static int PostId(ref Random rand)
- {
- return rand.Next(1, 3);
- }
- static string GetGraph(ref Random rand)
- {
- return (rand.Next(1, 7)).ToString() + '/' + (rand.Next(1, 7)).ToString();
- }
- static int GetDepart(ref Random rand)
- {
- return rand.Next(1, 11);
- }
- static string BirthDate(ref Random rand)
- {
- string date;
- date = String.Format("{0}-{1}-{2}", rand.Next(1940, 2016), rand.Next(1, 12), rand.Next(1, 28));
- return date;
- }
- static void Main(string[] args)
- {
- //using (StreamWriter sw = new StreamWriter("output.txt", false))
- //{
- // sw.WriteLine("insert into Staff (postId, name, DOB, graph, deptId) values ");
- // using (StreamReader sr = new StreamReader("input.txt"))
- // {
- // for (int i = 0; i < 5000; i++)
- // {
- // Random rand = new Random();
- // string stringName = sr.ReadLine();
- // int postId = PostId(ref rand);
- // if (postId == 2)
- // {
- // sw.WriteLine("('{0}', '{1}', '{2}', '{3}', '{4}'),",
- // postId, stringName, BirthDate(ref rand), GetGraph(ref rand), GetDepart(ref rand));
- // }
- // else
- // {
- // sw.WriteLine("('{0}', '{1}', '{2}', '{3}', null),",
- // postId, stringName, BirthDate(ref rand), GetGraph(ref rand));
- // }
- // System.Threading.Thread.Sleep(50);
- // }
- // }
- //}
- using (StreamWriter sw2 = new StreamWriter("output2.txt", false))
- {
- Random rand = new Random();
- //sw2.WriteLine("insert into Products (productName, productCost) values ");
- //for (int i = 0; i < 5000; i++)
- // sw2.WriteLine("( {0}, {1} ),", i, rand.Next(1, 10000));
- sw2.WriteLine("insert into Products (staffId, discountId, orderPrice, dateOrder) values");
- for (int i = 0; i < 2000; i++)
- sw2.WriteLine("( {0}, null, {1}, '{2}' ),", rand.Next(2, 4500), rand.Next(50, 15000), BirthDate(ref rand));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement