Exemplo n.º 1
0
        private List <string> GetData(string entity)
        {
            DataTable     dt   = mw.Select($"select [name] from {entity}");
            List <string> data = new List <string>();

            foreach (DataRow dr in dt.Rows)
            {
                data.Add(dr["name"].ToString());
            }
            return(data);
        }
Exemplo n.º 2
0
        private List <string> GetProductsId()
        {
            DataTable     products = mw.Select("select [name] from Products");
            List <string> ids      = new List <string>();

            foreach (DataRow dr in products.Rows)
            {
                ids.Add(dr["name"].ToString());
            }
            return(ids);
        }
Exemplo n.º 3
0
        private void InputListBox()
        {
            DataTable      articles = mainWindow.Select("select id, Articles.[name], [description], [price] from Articles");
            List <Article> items    = new List <Article>();

            foreach (DataRow dr in articles.Rows)
            {
                items.Add(new Article()
                {
                    ID = Convert.ToInt32(dr["id"]), Name = dr["name"].ToString(), Description = dr["description"].ToString(), Price = dr["price"].ToString()
                });
            }
            Items.ItemsSource = items;
        }
Exemplo n.º 4
0
        private Article GetArticle()
        {
            Article   article  = new Article();
            DataTable articles = mw.Select($"select Articles.id, Articles.[name], [description], [price], [year], " +
                                           $"AutoTypes.[name] as [type], AutoOils.[name] as [oil], AutoBrands.[name] as [brand], " +
                                           $"AutoPrivods.[name] as [privod], KPPTypes.[name] as [kpp], TypeBodies.[name] as [body] from Articles " +
                                           $"join AutoTypes on AutoTypes.id = idtype " +
                                           $"join AutoOils on AutoOils.id = idoiltype " +
                                           $"join AutoBrands on AutoBrands.id = idbrand " +
                                           $"join AutoPrivods on AutoPrivods.id = idprivod " +
                                           $"join KPPTypes on KPPTypes.id = idkpp " +
                                           $"join TypeBodies on TypeBodies.id = idbody where Articles.id={IDArticle}");

            foreach (DataRow dr in articles.Rows)
            {
                article = new Article()
                {
                    ID          = Convert.ToInt32(dr["id"]),
                    Name        = dr["name"].ToString(),
                    Description = dr["description"].ToString(),
                    Price       = dr["price"].ToString(),
                    Year        = Convert.ToInt32(dr["year"]),
                    Type        = dr["type"].ToString(),
                    Oil         = dr["oil"].ToString(),
                    Brand       = dr["brand"].ToString(),
                    Privod      = dr["privod"].ToString(),
                    Kpp         = dr["kpp"].ToString(),
                    Body        = dr["body"].ToString()
                };
            }
            return(article);
        }
Exemplo n.º 5
0
 private void LoginClick(object sender, RoutedEventArgs e)
 {
     if (mainWindow.RegexAdmin(Login.Text, Password.Password))
     {
         mainWindow.OpenPage(MainWindow.Pages.admin);
     }
     else if (mainWindow.RegexLogin(Login.Text))
     {
         if (mainWindow.RegexPassword(Password.Password))
         {
             DataTable find = mainWindow.Select($"select * from Users where login='******' and password='******'");
             if (find.Rows.Count > 0)
             {
                 mainWindow.OpenPage(MainWindow.Pages.main);
                 mainWindow.login = Login.Text;
                 MessageBox.Show("Пользователь авторизовался");
             }
             else
             {
                 MessageBox.Show("Такого пользователя не существует");
             }
         }
         else
         {
             MessageBox.Show("Введите пароль");
         }
     }
     else
     {
         MessageBox.Show("Введите логин");
     }
 }
Exemplo n.º 6
0
        private int GetId(string name)
        {
            DataTable dt = mw.Select($"select id from Categories where [name]='{name}'");
            int       id = -1;

            try
            {
                foreach (DataRow dr in dt.Rows)
                {
                    id = Convert.ToInt32(dr["id"]);
                }
                return(id);
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
            }
            return(id);
        }
Exemplo n.º 7
0
        private List <AutoPrivods> GetPrivods()
        {
            DataTable          dt      = mw.Select("select [name] from AutoPrivods");
            List <AutoPrivods> privods = new List <AutoPrivods>();

            foreach (DataRow dr in dt.Rows)
            {
                privods.Add(new AutoPrivods {
                    Name = dr["name"].ToString()
                });
            }
            return(privods);
        }
Exemplo n.º 8
0
        private List <AutoTypes> GetTypes()
        {
            DataTable        dt    = mw.Select("select [name] from AutoTypes");
            List <AutoTypes> types = new List <AutoTypes>();

            foreach (DataRow dr in dt.Rows)
            {
                types.Add(new AutoTypes {
                    Name = dr["name"].ToString()
                });
            }
            return(types);
        }
Exemplo n.º 9
0
        private List <AutoOils> GetOils()
        {
            DataTable       dt   = mw.Select("select [name] from AutoOils");
            List <AutoOils> oils = new List <AutoOils>();

            foreach (DataRow dr in dt.Rows)
            {
                oils.Add(new AutoOils {
                    Name = dr["name"].ToString()
                });
            }
            return(oils);
        }
Exemplo n.º 10
0
        private void InputListBox()
        {
            DataTable      products = mainWindow.Select("select Products.[name], Categories.[name] as category, [description], Prices.[value] as price from Products join Categories on Categories.id=category_id join Prices on Prices.product_id = Products.id");
            List <Product> items    = new List <Product>();

            foreach (DataRow dr in products.Rows)
            {
                items.Add(new Product()
                {
                    Name = dr["name"].ToString(), Category = dr["category"].ToString(), Description = dr["description"].ToString(), Price = dr["price"].ToString()
                });
            }
            Items.ItemsSource = items;
        }