Пример #1
0
        private void StatiyaForm1_Load(object sender, EventArgs e)
        {
            this.Font      = Configs.USER_FONT;
            this.ForeColor = Configs.USER_COLOR;

            List <string> s = Advertising.GetRandom();

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

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


            List <String> countRecords = SQLClass.Select(
                "SELECT COUNT(*) FROM " + Tables.READ_OF_ARTICLES +
                " WHERE `name_of_article` = '" + Maintext.Text + "'");

            label1.Text = "Просмотров: " + countRecords[0];


            SQLClass.Insert(
                "INSERT INTO " + Tables.READ_OF_ARTICLES +
                "(name_of_article, reader, dt)" +
                "VALUES (" +
                "'" + Maintext.Text + "'" +
                ", '" + Users.CURRENT_USER + "'" +
                ", DATE_FORMAT(NOW(), '%Y-%m-%d'))");

            #region Деньги за показанную рекламу
            int money = 2;

            List <String> AuthorExist = SQLClass.Select("SELECT COUNT(*) FROM " + Tables.BALANCE +
                                                        " WHERE AUTHOR = '" + Authortext.Text + "'");

            if (AuthorExist[0] != "0")
            {
                SQLClass.Update(" UPDATE " + Tables.BALANCE +
                                " SET Summa = Summa + " + money.ToString() +
                                " WHERE Author = '" + Authortext.Text + "'");
            }
            else
            {
                SQLClass.Insert(
                    "INSERT INTO " + Tables.BALANCE +
                    " (Summa, Author)" +
                    " VALUES (" +
                    money.ToString() + ", " +
                    "'" + Authortext.Text + "')");
            }
            #endregion
        }
        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];
        }
Пример #3
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
        }
Пример #4
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 = "Поиск";
        }