private void CreateAdmin_Btn_Click(object sender, EventArgs e) { using (MyModel adb = new MyModel()) { string AFname = AdminFName_tbox.Text; string ALname = AdminLName_tbox.Text; string Aphone = AdminPhone_tbox.Text; string Aemail = AdminEmail_tbox.Text; string ABDate = AdminBDate_tbox.Text; string UcAlogin = AdminLogin_tbox.Text; string UcAPass = AdminPassword_tbox.Text; string Alogin = ""; string Apass = ""; if (ValidateLogin(UcAlogin, out UcAlogin) == true) { Alogin = UcAlogin; if (ValidatePassword(UcAPass, out UcAPass) == true) { Apass = UcAPass; MessageBox.Show("Admin Created!"); Close(); } else { MessageBox.Show("Error wrong password input"); } } else { MessageBox.Show("Error wrong login input"); } Admins NewAdmin = new Admins(); Login login = new Login(); NewAdmin.CreateAdmin(AFname, ALname, ABDate, Aphone, Aemail); login.SetLogin(Alogin, Apass, NewAdmin); NewAdmin.SetAdminLogin(login); adb.Logins.Add(login); adb.Admins.Add(NewAdmin); try { adb.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
static void Main() { Database.SetInitializer(new DropCreateDatabaseAlways <MyModel>()); using (MyModel adb = new MyModel()) { Admins admins = new Admins(); Login login = new Login(); admins.CreateAdmin("Admintor", "RootAdmin", "02.03.2020", "+380555556399", "*****@*****.**"); login.SetLogin("Admin123", "pass1234", admins); admins.SetAdminLogin(login); adb.Logins.Add(login); adb.Admins.Add(admins); Clients clients = new Clients(); Login login1 = new Login(); clients.CreateClient("Client01", "Jugo", "20.02.2012", "+380223256477", "*****@*****.**"); login1.SetLogin("user1234", "pass9876", clients); clients.SetClientLogin(login1); adb.Logins.Add(login1); adb.Clients.Add(clients); Products products = new Products(); products.SetProduct("Engine", "Audi", 2500.00, 200); adb.Products.Add(products); Products products1 = new Products(); products1.SetProduct("Box", "Demo", 150.00, 500); adb.Products.Add(products1); Products products2 = new Products(); products2.SetProduct("Flames", "NOS", 500.00, 150); adb.Products.Add(products2); Orders orders = new Orders(); List <Products> Prod = new List <Products> { products, products1, products2 }; orders.CreateOrder("ForJugo", clients, Prod); adb.Orders.Add(orders); adb.SaveChanges(); Clients clients1 = new Clients(); Login login2 = new Login(); clients1.CreateClient("Client02", "Jugorasa", "20.02.2012", "+380223256477", "*****@*****.**"); login2.SetLogin("user6789", "pass6789", clients1); clients1.SetClientLogin(login2); adb.Logins.Add(login2); adb.Clients.Add(clients1); Products products3 = new Products(); products3.SetProduct("Enginesa", "Audisa", 25000.00, 300); adb.Products.Add(products3); Products products4 = new Products(); products4.SetProduct("Boxsa", "Demosa", 1500.00, 1500); adb.Products.Add(products4); Products products5 = new Products(); products5.SetProduct("Flamessa", "NOSsa", 700.00, 250); adb.Products.Add(products5); Orders orders1 = new Orders(); List <Products> Prod1 = new List <Products> { products3, products4, products5 }; orders1.CreateOrder("ForJugo2sa", clients1, Prod1); adb.Orders.Add(orders1); adb.SaveChanges(); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }