public AdminForm() { InitializeComponent(); db = new DataBaseIM(); Exit.MouseClick += (s, e) => { this.Hide(); AccountLoginForm ac = new AccountLoginForm(); ac.Show(); }; //Border,Size,Location Form StandardFormSettings standartForm = new StandardFormSettings(this); this.BackColor = Color.FromArgb(255, 255, 255); MainPanel.BackColor = Color.FromArgb(255, 255, 255); MainPanel.Location = new Point((this.Width - 1320) / 2, 40); MainPanel.Size = new Size(this.Width - (this.Width - 1320), this.Height - (this.Height - 994)); panelProducts.Visible = true; panelOrders.Visible = false; panelDataCustumer.Visible = false; panelDataMenegers.Visible = false; panelUsers.Visible = false; panelProducts.Location = new Point(294, 150); panelProducts.Size = new Size(1026, 850); db.Products.Load(); dataGridViewPdoructs.DataSource = db.Products.Local.ToBindingList(); dataGridViewPdoructs.Columns[0].Width = 50; dataGridViewPdoructs.Columns[1].Width = 400; dataGridViewPdoructs.Columns[2].Width = 50; dataGridViewPdoructs.Columns[3].Width = 65; dataGridViewPdoructs.Columns[4].Width = 300; dataGridViewPdoructs.Columns[5].Width = 100; }
private async void registrationButton_MouseClick(object sender, MouseEventArgs e) { if (CheckRegistration()) { try { using (DataBaseIM db = new DataBaseIM()) { UsersLogin user = new UsersLogin(); user.Login = registrationName.Text; user.Password = registrationPassword.Text; user.Mail = registrationMail.Text; db.UsersLogins.Add(user); CustomerInformation userInformation = new CustomerInformation(); userInformation.UserLogin = user; db.CustomersInformations.Add(userInformation); await db.SaveChangesAsync(); } } catch (Exception w) { MessageBox.Show("Error Server: " + w.ToString()); } MessageBox.Show("Account Created!"); loginPanel.Visible = true; registrationPanel.Visible = false; } }
private bool UserExist() { try { using (DataBaseIM db = new DataBaseIM()) { var query = from user in db.UsersLogins.AsParallel() where user.Login == registrationName.Text || user.Mail == registrationMail.Text select user; if (query.ToList().Count != 0) { return(true); } else { return(false); } } } catch { MessageBox.Show("Error Server"); return(false); } }
static void Main() { using (DataBaseIM db = new DataBaseIM()) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new AccountLoginForm()); } }
public void OrderPanelСompletedCorrectly_ValueRight_returnedTrue() { //arrenge string orderFamily = "Цезарь", orderName = "Гриша", orderDad = "Александровичь", orderAddres = "Днепр, Шевченка 5, 50"; string orderPhoneNumber = "380952342342", orderEmail = "*****@*****.**", orderDeliveryMetod = "Новой почтой", orderPaymentMthod = "GooglePay", OrderPriceLabel = "6023"; bool expected = true; //act DataBaseIM db = new DataBaseIM(); CustomerForm custumerForm = new CustomerForm(db.CustomersInformations.First()); bool actual = custumerForm.OrderPanelСompletedCorrectly(orderFamily, orderName, orderDad, orderAddres, orderPhoneNumber, orderEmail, orderDeliveryMetod, orderPaymentMthod, OrderPriceLabel); //assert Assert.AreEqual(expected, actual); }
public static async void DestructorProductsDB() { try { using (DataBaseIM db = new DataBaseIM()) { db.Orders.RemoveRange(db.Orders); db.Characteristics.RemoveRange(db.Characteristics); db.Products.RemoveRange(db.Products); await db.SaveChangesAsync(); Console.WriteLine("All products and orders are deleted.\n You can turn off the application"); Console.ReadKey(); } } catch (Exception ex) { Console.WriteLine("Eror :" + ex); } }
public static async void DestructorUsersDB() { try { using (DataBaseIM db = new DataBaseIM()) { db.MenedjersInformations.RemoveRange(db.MenedjersInformations); db.CustomersInformations.RemoveRange(db.CustomersInformations); db.UsersLogins.RemoveRange(db.UsersLogins); db.Orders.RemoveRange(db.Orders); await db.SaveChangesAsync(); Console.WriteLine("All users and orders are deleted.\n You can turn off the application"); Console.ReadKey(); } } catch (Exception ex) { Console.WriteLine("Eror :" + ex); } }
public static async void DestructorDB() { try { using (DataBaseIM db = new DataBaseIM()) { db.MenedjersInformations.RemoveRange(db.MenedjersInformations); db.CustomersInformations.RemoveRange(db.CustomersInformations); db.UsersLogins.RemoveRange(db.UsersLogins); db.Orders.RemoveRange(db.Orders); db.Characteristics.RemoveRange(db.Characteristics); db.Products.RemoveRange(db.Products); await db.SaveChangesAsync(); Console.WriteLine("DB Clear.\n You can turn off the application"); Console.ReadKey(); } } catch (Exception ex) { Console.WriteLine("Eror :" + ex); } }
public static async void FillDataBase() { List <string> ReferenceByTelemart = new List <string>() { "https://telemart.ua/ua/processor/", "https://telemart.ua/ua/motherboard/", "https://telemart.ua/ua/videocard/", "https://telemart.ua/ua/ram/", "https://telemart.ua/ua/hard-drive/", "https://telemart.ua/ua/case/", "https://telemart.ua/ua/powersuply/", "https://telemart.ua/ua/ua/mouse/", "https://telemart.ua/ua/keyboards/", "https://telemart.ua/ua/kovriki/", "https://telemart.ua/ua/microphones/", "https://telemart.ua/ua/earphones/", "https://telemart.ua/ua/web-cam/", "https://telemart.ua/ua/hdmi-dvi-vga-cables/", "https://telemart.ua/ua/monitors/filter/for-office-tasks/", "https://telemart.ua/ua/monitors/filter/for-game/", "https://telemart.ua/ua/monitors/filter/work-with-graphics/", "https://telemart.ua/ua/monitors/", "https://telemart.ua/ua/laptops/filter/1920x1080/", "https://telemart.ua/ua/laptops/filter/geforce-1080/geforce-1660-ti/geforce-2060/geforce-2070/geforce-2080/", "https://telemart.ua/ua/laptops/", "https://telemart.ua/ua/pc/filter/t-gaming/", "https://telemart.ua/ua/pc/filter/t-ultra/", }; List <string> CategoriesNameForReferance = new List <string>() { "Processor", "Motherboard", "Videocard", "Ram", "HardDrive", "Case", "Powersuply", "Mouse", "Keyboard", "Capet", "Microphone", "Headset", "Camera", "Cabel", "MonitorOfice", "MonitorGame", "MonitorDisign", "MonitorAll", "NoutbookOfice", "NoutbookGame", "NoutbookAll", "PcGame", "PcUltra" }; using (DataBaseIM db = new DataBaseIM()) { UsersLogin uL = new UsersLogin(); uL.Admin = true; uL.Login = "******"; uL.Password = "******"; uL.Mail = "*****@*****.**"; MenedjerInformation mInfo = new MenedjerInformation(); mInfo.UserLogin = uL; db.UsersLogins.Add(uL); db.MenedjersInformations.Add(mInfo); Console.WriteLine("Менеджер Admin доданий в базу даних\n"); for (int l = 0; l < ReferenceByTelemart.Count; l++) { List <Product> productList = new List <Product>(); var parser = new Parser(); var result = parser.GetInfo(ReferenceByTelemart[l]).Result; try { for (int i = 0; i < result.Title.Count; i++) { Product p = new Product(); //Categoty p.ProductCategory = CategoriesNameForReferance[l]; p.Title = result.Title[i]; Regex regex = new Regex(@"\s*грн"); string clear = regex.Replace(result.Price[i], ""); regex = new Regex(@"\s+"); clear = regex.Replace(clear, ""); p.Price = clear; //Reference on image p.ImageData = result.Images[i]; //Characteristics string[] s = Regex.Split(result.Characteristics[i], "</div>"); s = Regex.Split(s[1], "<br>"); List <Characteristic> listCharact = new List <Characteristic>(); foreach (var iteDataBaseIM in s) { Characteristic ch = new Characteristic(); string target = ""; regex = new Regex(@"<[^>]*>"); string withoutTags = regex.Replace(iteDataBaseIM, target); regex = new Regex(@"^\s+"); clear = regex.Replace(withoutTags, target); ch.CharacteristicString = clear; listCharact.Add(ch); } p.Characteristics = listCharact; productList.Add(p); } db.Products.AddRange(productList); await db.SaveChangesAsync(); Console.WriteLine("Link : " + l + " uploaded"); } catch (Exception) { Console.WriteLine("Eror by: " + l); } } Console.WriteLine("All links uploaded successfully"); } }
private void loginButton_MouseClick(object sender, MouseEventArgs e) { try { using (DataBaseIM db = new DataBaseIM()) { UsersLogin user = db.UsersLogins.FirstOrDefault(u => (u.Login == loginName.Text || u.Mail == loginName.Text) && u.Password == loginPassword.Text); if (user != null) { CustomerInformation cInfo = db.CustomersInformations.FirstOrDefault(cI => cI.UserLoginId == user.Id); if (cInfo != null) { if (checkBoxUserSave.Checked) { try { SaveSettings(); } catch (Exception exd) { MessageBox.Show("Error Server: " + exd); } } this.Hide(); CustomerForm cF = new CustomerForm(cInfo); cF.Show(); } else { MenedjerInformation mInfo = db.MenedjersInformations.FirstOrDefault(mI => mI.UserLoginId == user.Id); if (mInfo != null) { if (checkBoxUserSave.Checked) { try { SaveSettings(); } catch (Exception exd) { MessageBox.Show("Error Server: " + exd); } } this.Hide(); AdminForm aF = new AdminForm(); aF.Show(); } else { MessageBox.Show("NOT found"); } } } else { MessageBox.Show("No such user found"); } } } catch (Exception ex) { MessageBox.Show("Error Server: " + ex); } }