コード例 #1
0
        private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            SQLClass.Delete("DELETE FROM " + Tables.COLLECTION + " WHERE Coll_Text = '" + comboBox1.Text + "'");

            for (int index = 0; index < checkedListBox1.CheckedItems.Count; index++)
            {
                String str = checkedListBox1.CheckedItems[index].ToString();

                SQLClass.Insert("INSERT INTO " + Tables.COLLECTION + "(Coll_Text, id_art) VALUES ('" + comboBox1.Text + "'," +
                                "(SELECT artic_id FROM `Articles1` WHERE `Header` = '" + str + "'))");
            }
        }
コード例 #2
0
        public void update()
        {
            List <String> AuthorBalance = SQLClass.Select("SELECT Summa FROM " + Tables.BALANCE +
                                                          " WHERE `Author` = '" + name + "'");

            if (AuthorBalance.Count > 0)
            {
                label4.Text = AuthorBalance[0].ToString();
            }

            Balance_Author_Load(null, null);
        }
コード例 #3
0
        public StastisticsForm(String login)
        {
            InitializeComponent();

            List <String> AuthorsList = SQLClass.Select("SELECT UserName FROM " + Tables.AUTHORS);

            foreach (String Author in AuthorsList)
            {
                list_of_author.Items.Add(Author);
            }

            list_of_author.Text = login;
        }
コード例 #4
0
        private void list_of_author_SelectedIndexChanged(object sender, EventArgs e)
        {
            List <String> AuthorData = SQLClass.Select("SELECT * FROM " + Tables.AUTHORS +
                                                       " WHERE UserName = '******'");

            if (AuthorData.Count > 3)
            {
                ViewsCount.Text    = AuthorData[1].ToString();
                LikesCount.Text    = AuthorData[2].ToString();
                DisLikesCount.Text = AuthorData[3].ToString();
                name_stiatii.Text  = list_of_author.Text;
            }
        }
コード例 #5
0
 public void AddOneDay_Click(object sender, EventArgs e)
 {
     foreach (Reklama rekl in mn_reklamy)
     {
         if (sender.Equals(rekl.AddOneDayButton))
         {
             SQLClass.Update(
                 "UPDATE " + Tables.ADVERTISMENT +
                 " SET Data_to = '" + rekl.date_to.AddDays(1).ToString("dd.MM.yyyy") + "'" +
                 " WHERE id = " + rekl.id);
         }
     }
 }
コード例 #6
0
 public void prinit(object sender, EventArgs e)
 {
     foreach (Reklama rekl in mn_reklamy)
     {
         if (sender.Equals(rekl.prinitButton))
         {
             SQLClass.Update(
                 "UPDATE " + Tables.ADVERTISMENT +
                 " SET New = '" + "0" + "'" +
                 " WHERE id = " + rekl.id);
         }
     }
 }
コード例 #7
0
        private void Add_Statia_Load(object sender, EventArgs e)
        {
            this.Font      = Configs.USER_FONT;
            this.ForeColor = Configs.USER_COLOR;

            comboBox_kategorii.Items.Clear();
            List <String> Categories = SQLClass.Select("SELECT name FROM " + Tables.CATEGORIES);

            foreach (String cat in Categories)
            {
                comboBox_kategorii.Items.Add(cat);
            }
        }
コード例 #8
0
        public GhostMainForm()
        {
            InitializeComponent();
            Configs.ZAGOLOVOK_FONT   = popularArticlesLabel.Font;
            label_Author_header.Font = Configs.ZAGOLOVOK_FONT;

            label_cats_header.Font = Configs.ZAGOLOVOK_FONT;
            //label_popular.Text = stat.kategorita_statii;
            SQLClass.OpenConnection();

            AdmButton.Visible = false;
            AutButton.Visible = false;
        }
コード例 #9
0
        private void button_delete_Click(object sender, EventArgs e)
        {
            foreach (categories cat in CategoriesList)
            {
                if (sender.Equals(cat.del))
                {
                    SQLClass.Delete("DELETE FROM " + Tables.CATEGORIES +
                                    " WHERE `Name`= '" + cat.name + "'");
                }
            }

            update();
        }
コード例 #10
0
        void LoadPages()
        {
            this.Font      = Configs.USER_FONT;
            this.ForeColor = Configs.USER_COLOR;
            this.Controls.Clear();
            this.Controls.Add(new Label()
            {
                Text     = "Новый",
                Location = new Point(0, 0),
                Size     = new Size(50, 20)
            });
            this.Controls.Add(new Label()
            {
                Text     = "Название",
                Location = new Point(100, 0)
            });

            List <String> articlesList = SQLClass.Select("SELECT header, new FROM " + Tables.ARTICLES);

            int PosY = 20;

            for (int artIndex = 0; artIndex < articlesList.Count; artIndex += 2)
            {
                newPage Page = new newPage();
                Page.Header = articlesList[artIndex];

                Page.CheckBox_          = new CheckBox();
                Page.CheckBox_.Location = new Point(10, PosY);
                Page.CheckBox_.Size     = new Size(50, 30);
                Page.CheckBox_.Click   += new System.EventHandler(cbnewpage);
                Page.CheckBox_.Checked  = (articlesList[artIndex + 1] == "1");


                Page.Label_          = new Label();
                Page.Label_.Location = new Point(100, PosY);
                Page.Label_.Size     = new Size(250, 30);
                Page.Label_.Text     = articlesList[artIndex];

                Page.Label_.Click += new System.EventHandler(Label_Click);
                if (articlesList[artIndex + 1] == "0")
                {
                    Page.Label_.ForeColor = Color.Gray;
                }

                ListOfPages.Add(Page);
                this.Controls.Add(Page.CheckBox_);
                this.Controls.Add(Page.Label_);
                PosY += 30;
            }
        }
コード例 #11
0
        /// <summary>
        /// Разблокировка пользователя
        /// </summary>
        private void ras_Click(object sender, EventArgs e)
        {
            foreach (users i in list_of_users)
            {
                if (sender.Equals(i.ras))
                {
                    SQLClass.Update("UPDATE " + Tables.POLZOVATELI +
                                    " SET ban = 0 WHERE login = '******'");
                    SQLClass.Update("UPDATE " + Tables.AUTHORS +
                                    " SET ban = 0 WHERE UserName = '******'");
                }
            }

            Users_Load(null, null);
        }
コード例 #12
0
        public static void GetStata(Label lblLike, Label lblDisLike, String text)
        {
            List <String> likes = SQLClass.Select("SELECT LikesCount, DisCount FROM " + Tables.LIKES +
                                                  " WHERE Article = '" + text + "'");

            if (likes.Count > 1)
            {
                lblLike.Text    = likes[0];
                lblDisLike.Text = likes[1];
            }
            else
            {
                lblLike.Text    = "0";
                lblDisLike.Text = "0";
            }
        }
コード例 #13
0
        private void AdvertisingForm_Load(object sender, EventArgs e)
        {
            this.Font      = Configs.USER_FONT;
            this.ForeColor = Configs.USER_COLOR;

            List <String> catsList = SQLClass.Select("SELECT Name FROM " + Tables.CATEGORIES + " LIMIT 0, 7");

            for (int artIndex = 0; artIndex < catsList.Count; artIndex++)
            {
                checkedListBox1.Items.Add(catsList[artIndex].ToString());
            }
            List <String> s = Advertising.GetRandom();

            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            pictureBox1.LoadAsync(s[0]);
            pictureBox1.Tag = s[1];
        }
コード例 #14
0
        static void Main()
        {
            LogFile.WriteLine("main", "читаем конфиг");
            IniParser.Parser.IniDataParser aa = new IniParser.Parser.IniDataParser();
            Tables.ADVERTISMENT = aa.Parse(File.ReadAllText("config.ini"))["db"]["ADVERTISMENT"].ToString();
            Tables.ARTICLES     = aa.Parse(File.ReadAllText("config.ini"))["db"]["ARTICLES"].ToString();
            Tables.AUTHORS      = aa.Parse(File.ReadAllText("config.ini"))["db"]["AUTHORS"].ToString();
            Tables.BALANCE      = aa.Parse(File.ReadAllText("config.ini"))["db"]["BALANCE"].ToString();
            Tables.CATEGORIES   = aa.Parse(File.ReadAllText("config.ini"))["db"]["CATEGORIES"].ToString();



            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            SQLClass.OpenConnection();

            Application.Run(new GhostMainForm());
            SQLClass.CloseConnection();
        }
コード例 #15
0
 void cbnewpage(object sender, EventArgs e)
 {
     foreach (newPage a in ListOfPages)
     {
         if (sender.Equals(a.CheckBox_))
         {
             if (a.Label_.ForeColor == Color.Gray)
             {
                 SQLClass.Update("UPDATE " + Tables.ARTICLES +
                                 " SET `new`= 1 WHERE header = '" + a.Header + "'");
             }
             else
             {
                 SQLClass.Update("UPDATE " + Tables.ARTICLES +
                                 " SET `new`= 0 WHERE header = '" + a.Header + "'");
             }
         }
     }
     LoadPages();
 }
コード例 #16
0
        public void sdfsdf(Panel panel1)
        {
            int           uy    = 0;
            List <String> Auths = SQLClass.Select("SELECT UserName, Pic, Information_about_author FROM " + Tables.AUTHORS);

            for (int index = 0; index < Auths.Count; index += 3)
            {
                LinkLabel linklabel1 = new LinkLabel();
                linklabel1.Size     = new Size(70, 20);
                linklabel1.Location = new Point(50, 10 + 30 * uy);
                linklabel1.Text     = Auths[index].ToString();
                linklabel1.Click   += new System.EventHandler(Click_na_link);

                pic.Add(Auths[index + 1].ToString());
                Information.Add(Auths[index + 2].ToString());

                panel1.Controls.Add(linklabel1);
                loginy_avtorov.Add(linklabel1);
                uy++;
            }
        }
コード例 #17
0
        private void Collections_Load(object sender, EventArgs e)
        {
            this.Font      = Configs.USER_FONT;
            this.ForeColor = Configs.USER_COLOR;

            checkedListBox1.Items.Clear();
            List <String> Collection_List = SQLClass.Select("SELECT DISTINCT `Coll_text` FROM  " + Tables.COLLECTION);

            foreach (String list in Collection_List)
            {
                comboBox1.Items.Add(list);
            }

            List <String> ArticlesList = SQLClass.Select("SELECT Header FROM " + Tables.ARTICLES);

            foreach (String article in ArticlesList)
            {
                checkedListBox1.Items.Add(article);
            }
            New.Visible = false;
        }
コード例 #18
0
        private void button_login_Click(object sender, EventArgs e)
        {
            Dictionary <String, String> dict = new Dictionary <string, string>();

            dict.Add("STR", textBox_login.Text);
            dict.Add("PASS", textBox_password.Text);
            Users.CURRENT_USER = textBox_login.Text;

            List <String> AuthorLoginData = SQLClass.Select
                                                ("SELECT COUNT(*) FROM " + Tables.AUTHORS +
                                                " WHERE UserName = @STR " +
                                                " AND UserName IN (SELECT Login FROM " + Tables.POLZOVATELI +
                                                " WHERE Login = @STR and Parol = @PASS)", dict);

            List <String> Polzovatel = SQLClass.Select
                                           ("SELECT COUNT(*) FROM " + Tables.POLZOVATELI +
                                           " WHERE Login = @STR and Parol = @PASS", dict);



            if (AuthorLoginData[0] != "0")
            {
                Users.CURRENT_USER = textBox_login.Text;
                aut = true;
                Form1_Load(sender, e);
            }
            else if (label_password.Text != "" && To_come_in.LogIntoAdminZone(textBox_login.Text, textBox_password.Text))
            {
                adm = true;
                Form1_Load(sender, e);
            }
            else if (Polzovatel[0] != "0")
            {
                Form1_Load(sender, e);
            }
            else
            {
                MessageBox.Show("Вас в безе нет (Не верен пароль или логин)");
            }
        }
コード例 #19
0
        private void pictureBoxDislike_Click(object sender, EventArgs e)
        {
            isDisLike = !isDisLike;
            pictureBoxDislike.Image = (isDisLike) ?
                                      Properties.Resources.DisLike2 :
                                      Properties.Resources.Dislike;

            List <String> dislikes = SQLClass.Select("SELECT Article FROM " + Tables.LIKES + " WHERE Article = '" + Maintext.Text + "'");

            if (isDisLike)
            {
                if (dislikes.Count > 0)
                {
                    SQLClass.Update("UPDATE " + Tables.LIKES +
                                    " SET DisCount = DisCount + 1" +
                                    " WHERE Article = '" + Maintext.Text + "'");
                }
                else
                {
                    SQLClass.Insert(
                        "INSERT INTO " + Tables.LIKES +
                        "(Article, Author, Category, LikesCount, DisCount)" +
                        " VALUES (" +
                        "'" + Maintext.Text + "'" +
                        ", '" + Authortext.Text + "'" +
                        ", '" + Kategoriatext.Text + "'" +
                        ",0" +
                        ",1)");
                }
            }
            else
            {
                SQLClass.Update("UPDATE " + Tables.LIKES +
                                " SET DisCount = DisCount - 1" +
                                " WHERE Article = '" + Maintext.Text + "'");
            }

            GetStata(labelLike, labeldis, Maintext.Text);
        }
コード例 #20
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            isLike            = !isLike;
            pictureBox1.Image = (isLike) ?
                                Properties.Resources.Like2 :
                                Properties.Resources.like;

            List <String> likes = SQLClass.Select("SELECT Article FROM " + Tables.LIKES + " WHERE Article = '" + name.Text + "'");

            if (isLike)
            {
                if (likes.Count > 0)
                {
                    SQLClass.Update("UPDATE " + Tables.LIKES +
                                    " SET LikesCount = LikesCount + 1" +
                                    " WHERE Article = '" + name.Text + "'");
                }
                else
                {
                    SQLClass.Insert(
                        "INSERT INTO " + Tables.LIKES +
                        "(Article, Author, Category, LikesCount, DisCount)" +
                        " VALUES (" +
                        "'" + name.Text + "'" +
                        ", '" + label2.Text + "'" +
                        ", '" + kategoriy.Text + "'" +
                        ",1" +
                        ",0)");
                }
            }
            else
            {
                SQLClass.Update("UPDATE " + Tables.LIKES +
                                " SET LikesCount = LikesCount - 1" +
                                " WHERE Article = '" + name.Text + "'");
            }

            GetStata(label3, label4, name.Text);
        }
コード例 #21
0
 private void button2_Click(object sender, EventArgs e)
 {
     SQLClass.Delete("DELETE FROM " + Tables.COLLECTION + " WHERE Coll_Text = '" + comboBox1.Text + "'");
 }
コード例 #22
0
 private void GhostMainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     SQLClass.CloseConnection();
 }
コード例 #23
0
 private void button1_Click(object sender, EventArgs e)
 {
     SQLClass.Insert("INSERT INTO `Colection` (`id_art`, `Coll_text`) VALUES ('" + textBox1.Text + "', " + "'" + New.Text + "')");
 }
コード例 #24
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!ob)
            {
                #region Добавляем пользователя
                List <String> byl = SQLClass.Select(
                    "SELECT COUNT(*) FROM " + Tables.POLZOVATELI + " WHERE Login='******'");
                bool userBylUzhe = (byl[0].ToString() != "0");

                if (userBylUzhe)
                {
                    MessageBox.Show("Ты был уже. Регистрируйся заново");
                    return;
                }

                SQLClass.Insert("INSERT INTO " + Tables.POLZOVATELI +
                                "(`Login`, `Parol`, `ban`, `aboutme`, admin)" +
                                " VALUES ('" + textBox_login.Text + "'," +
                                "'" + textBox_password.Text + "'," +
                                "0" + ",'" + textBox_about_me.Text + "', 0)");
                #endregion


                if (checkBox_I_author.Checked == true)
                {
                    #region Добавляем автора
                    List <String> isAdminData = SQLClass.Select(
                        "SELECT COUNT(*) FROM " + Tables.AUTHORS + " WHERE `UserName`=\"" + textBox_login.Text +
                        "\"");
                    bool BylUzhe = (isAdminData[0].ToString() != "0");

                    if (BylUzhe)
                    {
                        MessageBox.Show("Ты был уже. Регистрируйся заново");
                        return;
                    }

                    SQLClass.Insert("INSERT INTO " + Tables.AUTHORS +
                                    "(UserName, Information_about_author, Pic) " +
                                    "VALUES ('" + textBox_login.Text + "','" +
                                    textBox_about_me.Text + "', '" +
                                    textBox_pic + "')");
                    #endregion
                }
            }
            else
            {
                if (infoObAvtore[0] != textBox_login.Text)
                {
                    List <String> isAdminData = SQLClass.Select(
                        "SELECT COUNT(*) FROM " + Tables.AUTHORS + " WHERE `UserName`=\"" + textBox_login.Text +
                        "\"");
                    bool BylUzhe = (isAdminData[0].ToString() != "0");

                    if (BylUzhe)
                    {
                        MessageBox.Show("Ты вообще не оригинальный");
                        return;
                    }


                    isAdminData = SQLClass.Select(
                        "SELECT COUNT(*) FROM " + Tables.AUTHORS + " WHERE `UserName`=\"" + textBox_login.Text +
                        "\"");
                    BylUzhe = (isAdminData[0].ToString() != "0");

                    if (BylUzhe)
                    {
                        MessageBox.Show("Такой пользователь уже есть");
                        return;
                    }



                    SQLClass.Update("UPDATE " + Tables.ARTICLES +
                                    " SET Author = '" + textBox_login.Text +
                                    "' WHERE Author = '" + login + "'");

                    SQLClass.Update("UPDATE " + Tables.POLZOVATELI +
                                    " SET Login = '******' WHERE Login = '******'");

                    SQLClass.Update("UPDATE " + Tables.BALANCE +
                                    " SET Login = '******' WHERE Login = '******'");


                    SQLClass.Update("UPDATE " + Tables.LIKES +
                                    " SET Login = '******' WHERE Login = '******'");
                }


                SQLClass.Update("UPDATE " + Tables.AUTHORS +
                                " SET UserName = '******', Pic = '" + textBox_pic.Text +
                                "', Information_about_author = '" + textBox_about_me.Text +
                                "' WHERE UserName = '******'");
            }
            Close();
        }
コード例 #25
0
        public static void getAuthorInfo(string name_avtor, string pic_avtor, string infa_ob_avtore, Panel panel1)
        {
            panel1.Controls.Clear();
            Label label1 = new Label();

            label1.Size     = new Size(300, 30);
            label1.Location = new Point(50, 15);
            label1.Font     = Configs.ZAGOLOVOK_FONT;
            label1.Text     = "Информация о " + name_avtor;
            panel1.Controls.Add(label1);

            Label label2 = new Label();

            label2.Size     = new Size(200, 13);
            label2.Location = new Point(50, 50);
            panel1.Controls.Add(label2);

            Label label4 = new Label();

            label4.Size     = new Size(200, 13);
            label4.Location = new Point(300, 0);
            label4.Text     = "Статьи, которые он написал";
            panel1.Controls.Add(label4);

            List <String> Stat = SQLClass.Select("SELECT DISTINCT Header FROM " + Tables.ARTICLES +
                                                 " WHERE Author = '" + name_avtor + "'");

            for (int index = 0; index < Stat.Count; index++)
            {
                Label label3 = new Label();
                label3.Size     = new Size(500, 13);
                label3.Location = new Point(300, 50 * (index + 1));
                label3.Text     = Stat[index];
                panel1.Controls.Add(label3);
                label3.Click += new System.EventHandler(Label3_Click);
            }

            PictureBox pictureBox1 = new PictureBox();

            pictureBox1.Size     = new Size(225, 199);
            pictureBox1.Location = new Point(70, 76);
            panel1.Controls.Add(pictureBox1);

            String[]  chasti_stroki = pic_avtor.Split(new char[] { ' ', '/' });
            WebClient client        = new WebClient();
            Uri       uri           = new Uri(pic_avtor);

            try
            {
                pictureBox1.Image = new Bitmap(chasti_stroki[chasti_stroki.Length - 1]);

                pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            }
            catch (Exception)
            {
                try
                {
                    pictureBox1.Load(pic_avtor);

                    pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                    client.DownloadFileAsync(uri, chasti_stroki[chasti_stroki.Length - 1]);
                }
                catch (Exception)
                {
                    pictureBox1.Image = new Bitmap("defolt_avtor.jpg");

                    pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                }
            }

            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            label2.Text          = infa_ob_avtore;
        }
コード例 #26
0
 private void SQLParamsForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     SQLClass.OpenConnection();
 }
コード例 #27
0
        private void Form1_Load(object sender, EventArgs e)
        {
            arts.Clear();
            Right_panel.Controls.Clear();
            //Right_panel.Controls.Add(button_add_reklama);
            //Right_panel.Controls.Add(button1);

            // button_add_reklama.Visible = false;

            lable_name_of_polzovatel.Text = Users.CURRENT_USER;
            AdmButton.Visible             = adm;
            AutButton.Visible             = aut;

            if (lable_name_of_polzovatel.Text != "NONAME")
            {
                lable_name_of_polzovatel.Text = "Вы вошли как " + Users.CURRENT_USER;
                Right_panel.Controls.Add(lable_name_of_polzovatel);

                Right_panel.Controls.Add(tableLayoutPanel2);
                button_add_reklama.Visible = true;
                button1.Visible            = true;
            }

            #region Обновление списка категорий
            Right_panel.Controls.Add(label_cats_header);
            Right_panel.Controls.Add(categories_linklabel);

            List <String> catsList = SQLClass.Select("SELECT Name FROM " + Tables.CATEGORIES + " LIMIT 0, 7");

            int catY = 210;
            for (int artIndex = 0; artIndex < catsList.Count; artIndex++)
            {
                Label label1 = new Label();
                label1.Location = new Point(0, catY);
                label1.Size     = new Size(100, 20);
                label1.Text     = catsList[artIndex].ToString();
                label1.Click   += new System.EventHandler(Author_Or_Category_CLick);
                Right_panel.Controls.Add(label1);
                catY += 28;
            }
            #endregion

            #region Обновление списка авторов

            Right_panel.Controls.Add(label_Author_header);
            Right_panel.Controls.Add(label_author);

            List <String> authorsList = SQLClass.Select("SELECT UserName FROM " + Tables.AUTHORS + " LIMIT 0, 3");

            int authorsY = 75;
            for (int artIndex = 0; artIndex < authorsList.Count; artIndex++)
            {
                Label label1 = new Label();
                label1.Location = new Point(0, authorsY);
                label1.Size     = new Size(100, 20);
                label1.Text     = authorsList[artIndex].ToString();
                label1.Click   += new System.EventHandler(Author_Or_Category_CLick);
                Right_panel.Controls.Add(label1);
                authorsY += 25;
            }
            #endregion

            #region Advertising

            List <String> s = Advertising.GetRandom();
            reclama.SizeMode = PictureBoxSizeMode.StretchImage;
            reclama.LoadAsync(s[0]);
            reclama.Tag = s[1];


            s = Advertising.GetRandom();
            reclama2.SizeMode = PictureBoxSizeMode.StretchImage;
            reclama2.LoadAsync(s[0]);
            reclama3.Tag = s[1];

            s = Advertising.GetRandom();
            reclama3.SizeMode = PictureBoxSizeMode.StretchImage;
            reclama3.LoadAsync(s[0]);
            reclama3.Tag = s[1];
            #endregion

            textBox_search.Text = "";
            butto_search_Click(sender, e);


            textBox_search.Text = "Поиск";
        }
コード例 #28
0
        private void Users_Load(object sender, EventArgs e)
        {
            this.Font      = Configs.USER_FONT;
            this.ForeColor = Configs.USER_COLOR;


            list_of_users.Clear();
            panel1.Controls.Clear();
            panel1.Controls.Add(comboBox1);


            /*else
             * {
             *  zapros = "SELECT `UserName`, 'locked' FROM " + Tables.AUTHORS;
             * }*/

            //FIXED
            zapolnenie();
            List <String> UsersData = SQLClass.Select(zapros);

            int CurrentY = 20;

            for (int userIndex = 0; userIndex < UsersData.Count; userIndex += 3)
            {
                LinkLabel linklabel1 = new LinkLabel();
                linklabel1.Size     = new Size(70, 20);
                linklabel1.Location = new Point(10, CurrentY);
                linklabel1.Text     = UsersData[userIndex].ToString();
                panel1.Controls.Add(linklabel1);

                Label label22 = new Label();
                label22.Size     = new Size(20, 20);
                label22.Location = new Point(80, CurrentY);
                label22.Text     = UsersData[userIndex + 2].ToString();
                panel1.Controls.Add(label22);

                Label label2 = new Label();
                label2.Size     = new Size(70, 20);
                label2.Location = new Point(100, CurrentY);
                label2.Text     = UsersData[userIndex + 1].ToString();
                panel1.Controls.Add(label2);

                Button button_ban = new Button();
                button_ban.Size     = new Size(70, 20);
                button_ban.Location = new Point(190, CurrentY);
                button_ban.Text     = "Забанить";


                Button button_ras = new Button();
                button_ras.Size     = new Size(70, 20);
                button_ras.Location = new Point(260, CurrentY);
                button_ras.Text     = "Разблочить";

                users newUser = new users();
                newUser.login = linklabel1.Text;
                newUser.ban   = Boolean.Parse(label2.Text);

                newUser.btn        = button_ban;
                newUser.btn.Click += new System.EventHandler(Click);
                panel1.Controls.Add(newUser.btn);

                newUser.ras        = button_ras;
                newUser.ras.Click += new System.EventHandler(ras_Click);
                panel1.Controls.Add(newUser.ras);

                list_of_users.Add(newUser);
                CurrentY += 20;
            }
        }
コード例 #29
0
        private void dalee_Click(object sender, EventArgs e)
        {
            Dictionary <String, String> dict = new Dictionary <string, string>();

            dict.Add("STR", "%" + textBox_search.Text + "%");
            List <String> PopularArticles =
                SQLClass.Select
                    ("SELECT Header, Picture, " +
                    "(SELECT likesCount FROM " + Tables.LIKES + " WHERE Header = Article) likesCount, " +
                    "(SELECT discount FROM " + Tables.LIKES + " WHERE Header = Article) discount, " +
                    "(SELECT COUNT(*) FROM " + Tables.READ_OF_ARTICLES + " WHERE Header = name_of_article) A" +
                    " FROM " + Tables.ARTICLES +
                    " WHERE new = 0 AND (header like @STR OR category like @STR OR author like @STR)" +
                    getKak() +
                    " LIMIT " + Convert.ToString(kolvo_nazatiy * 3) + ", 3", dict);


            for (int artIndex = 0; artIndex < PopularArticles.Count; artIndex += 5)
            {
                #region Article header
                Panel articleHeaderPanel = new Panel();
                articleHeaderPanel.Size     = new Size(Centr_panel.Width, 30);
                articleHeaderPanel.Dock     = (kolvo_nazatiy > 0) ? DockStyle.Bottom : DockStyle.Top;
                articleHeaderPanel.TabIndex = (kolvo_nazatiy > 0) ? 3 * kolvo_nazatiy : 3 * kolvo_nazatiy + 2;

                LinkLabel label1 = new LinkLabel();
                label1.Location = new Point(0, 0);
                label1.Size     = new Size(180, 20);
                label1.Text     = PopularArticles[artIndex].ToString();
                label1.Click   += new System.EventHandler(ArticleClick);
                articleHeaderPanel.Controls.Add(label1);

                PictureBox likesPB = new PictureBox();
                likesPB.Size     = new Size(20, 20);
                likesPB.Location = new Point(200, 0);
                likesPB.Image    = Properties.Resources.like;
                articleHeaderPanel.Controls.Add(likesPB);

                Label likesLabel = new Label();
                likesLabel.Location = new Point(230, 0);
                likesLabel.Size     = new Size(20, 20);
                articleHeaderPanel.Controls.Add(likesLabel);

                Label dislikesLabel = new Label();
                dislikesLabel.Location = new Point(290, 0);
                dislikesLabel.Size     = new Size(20, 20);
                articleHeaderPanel.Controls.Add(dislikesLabel);

                StatiyaForm.GetStata(likesLabel, dislikesLabel, label1.Text);
                #endregion

                //Video
                if (PopularArticles[artIndex + 1].ToString().Contains("www.youtube.com"))
                {
                    String url = PopularArticles[artIndex + 1].ToString().Replace("watch?v=", "embed/");

                    String embed = "<html><head>" +
                                   "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge\"/>" +
                                   "</head><body>" +
                                   "<iframe width=\"" + Centr_panel.Width + "\" src=\"{0}\"" +
                                   "frameborder = \"0\" allow = \"autoplay; encrypted-media\" allowfullscreen></iframe>" +
                                   "</body></html>";

                    WebBrowser web = new WebBrowser();
                    web.TabIndex     = 3 * kolvo_nazatiy + 1;
                    web.Dock         = (kolvo_nazatiy > 0) ? DockStyle.Bottom : DockStyle.Top;
                    web.DocumentText = string.Format(embed, url);
                    web.Location     = new Point(0, articleY + 25);

                    if (kolvo_nazatiy > 0)
                    {
                        Centr_panel.Controls.Add(web);
                        Centr_panel.Controls.Add(articleHeaderPanel);
                    }
                    else
                    {
                        Centr_panel.Controls.Add(articleHeaderPanel);
                        Centr_panel.Controls.Add(web);
                    }
                }
                //Picture
                else
                {
                    String[] chasti_stroki = PopularArticles[artIndex + 1].ToString().Split(new char[] { ' ', '/' });

                    PictureBox artImage = new PictureBox();
                    artImage.Location = new Point(0, articleY + 25);
                    artImage.Tag      = label1.Text;
                    artImage.Size     = new Size(Centr_panel.Width, 150);
                    artImage.Dock     = (kolvo_nazatiy > 0) ? DockStyle.Bottom : DockStyle.Top;
                    artImage.Click   += new System.EventHandler(clik_na_pic);
                    artImage.SizeMode = PictureBoxSizeMode.StretchImage;
                    artImage.TabIndex = 3 * kolvo_nazatiy + 1;

                    try
                    {
                        artImage.Image = new Bitmap(chasti_stroki[chasti_stroki.Length - 1]);
                    }
                    catch (Exception)
                    {
                        try
                        {
                            artImage.LoadAsync(PopularArticles[artIndex + 1].ToString());
                            Uri uri = new Uri(PopularArticles[artIndex + 1].ToString());
                            client.DownloadFileAsync(uri, chasti_stroki[chasti_stroki.Length - 1]);
                        }
                        catch (Exception)
                        {
                            artImage.Image = new Bitmap("defolt_statiy.jpg");
                        }
                    }

                    if (kolvo_nazatiy > 0)
                    {
                        Centr_panel.Controls.Add(artImage);
                        Centr_panel.Controls.Add(articleHeaderPanel);
                    }
                    else
                    {
                        Centr_panel.Controls.Add(articleHeaderPanel);
                        Centr_panel.Controls.Add(artImage);
                    }

                    piccc.Add(artImage);
                }

                Centr_panel.Controls.Add(dalee);
                arts.Add(label1);
                articleY += 180;
            }

            kolvo_nazatiy++;
        }
コード例 #30
0
        private void AuthorMainFormLoad(object sender, EventArgs e)
        {
            this.Font      = Configs.USER_FONT;
            this.ForeColor = Configs.USER_COLOR;


            List <String> AuthorInfo = SQLClass.Select(
                "SELECT Information_about_author, Articles, Pic FROM " + Tables.AUTHORS +
                " WHERE `UserName` = '" + login + "'");

            List <String> mesto = SQLClass.Select("SELECT SUM(`LikesCount`) - SUM(`DisCount`) FROM " + Tables.LIKES +
                                                  " WHERE `Author` = '" + login + "'");

            label4.Text = "Место автора " + mesto[0];

            Button_Balance.Text = string.Format("Баланс: {0}", SQLClass.Select("SELECT `Summa` FROM " + Tables.BALANCE + " WHERE `Author`= '" + login + "'")[0]);



            for (int infoIndex = 0; infoIndex < AuthorInfo.Count; infoIndex += 3)
            {
                List <String> likes = SQLClass.Select(string.Format("SELECT SUM(`LikesCount`), SUM(`DisCount`) FROM `Likes` WHERE `Author` = '{0}'", login));
                aboutAuthorLabel.Text = AuthorInfo[infoIndex].ToString() + string.Format(" Лайков: {0}, Дизлайков: {1}", likes[0], likes[1]);
                String[] chasti_stroki = AuthorInfo[infoIndex + 2].ToString().Split(new char[] { ' ', '/' });

                try
                {
                    Avatar_author.Image = new Bitmap(chasti_stroki[chasti_stroki.Length - 1]);
                }
                catch (Exception)
                {
                    try
                    {
                        Avatar_author.Load(AuthorInfo[infoIndex + 2].ToString());
                        Uri uri = new Uri(AuthorInfo[infoIndex + 2].ToString());
                        client.DownloadFileAsync(uri, chasti_stroki[chasti_stroki.Length - 1]);
                    }
                    catch (Exception)
                    {
                        Avatar_author.Image = new Bitmap("defolt_avtor.jpg");
                    }
                }

                Avatar_author.SizeMode = PictureBoxSizeMode.StretchImage;
            }

            List <String> AuthorArticles = SQLClass.Select("SELECT Header, Picture FROM " + Tables.ARTICLES +
                                                           " WHERE `Author` = '" + login + "'");

            int articleY = 50;

            for (int artIndex = 0; artIndex < AuthorArticles.Count; artIndex += 2)
            {
                LinkLabel label1 = new LinkLabel();
                label1.Location = new Point(0, articleY);
                label1.Size     = new Size(panel1.Width, 20);
                label1.Text     = AuthorArticles[artIndex].ToString();
                label1.Dock     = DockStyle.Top;
                label1.Click   += new System.EventHandler(ArticleClick);
                panel1.Controls.Add(label1);

                PictureBox image1 = new PictureBox();
                image1.Location = new Point(0, articleY + 25);
                image1.Size     = new Size(panel1.Width, 150);
                image1.Image    = new Bitmap("defolt_statiy.jpg");
                image1.SizeMode = PictureBoxSizeMode.StretchImage;
                image1.Dock     = DockStyle.Top;
                panel1.Controls.Add(image1);

                String[] chasti_stroki = AuthorArticles[artIndex + 1].ToString().Split(new char[] { ' ', '/' });

                try
                {
                    image1.Image = new Bitmap(chasti_stroki[chasti_stroki.Length - 1]);
                }
                catch (Exception)
                {
                    try
                    {
                        image1.Load(AuthorArticles[artIndex + 1].ToString());
                        Uri uri = new Uri(AuthorArticles[artIndex + 1].ToString());
                        client.DownloadFileAsync(uri, chasti_stroki[chasti_stroki.Length - 1]);
                    }
                    catch (Exception)
                    {
                    }
                }

                arts.Add(label1);
                articleY += 180;
            }

            //FIXME!!! Show region
            #region Advertising
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            List <string> s = Advertising.GetRandom();
            pictureBox1.LoadAsync(s[0]);
            pictureBox1.Tag = s[1];

            pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage;
            s = Advertising.GetRandom();
            pictureBox2.LoadAsync(s[0]);
            pictureBox2.Tag = s[1];

            #endregion
        }