Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (ne_povtor == textBox_Name.Text)
            {
                MessageBox.Show("Скоре всего вы пытаетесь опубликовать ещё раз");
            }
            else
            {
                List <String> ids = SQLClass.Select("SELECT MAX(Artic_ID + 1) FROM  " + Tables.ARTICLES);
                id = ids[0];

                SQLClass.Insert("INSERT INTO " + Tables.ARTICLES +
                                "(Header, Text, Author, Picture, Artic_ID, Category, new)" +
                                " VALUES ('" + textBox_Name.Text + "'," +
                                "'" + textBox_txtStat.Text + "'," +
                                "'" + avtor1 + "'," +
                                "'" + textBox_ssulka.Text + "'," +
                                "" + id + "," +
                                "'" + comboBox_kategorii.Text + "'," +
                                " 1)");
                SQLClass.Update("UPDATE " + Tables.AUTHORS +
                                " SET Articles = Articles + 1 WHERE UserName = '******'");

                ne_povtor = textBox_Name.Text;
            }
        }
Ejemplo n.º 2
0
        private void button_send_Click(object sender, EventArgs e)
        {
            if (checkBox_agree.Checked && checkBox_agree2.Checked)
            {
                MySqlCommand    Dcmd = new MySqlCommand("SELECT MAX(id+1) FROM Advertisment", SQLClass.CONN);
                MySqlDataReader Drdr = Dcmd.ExecuteReader();

                String NewAdvId = "";
                while (Drdr.Read())
                {
                    NewAdvId = Drdr[0].ToString();
                }
                Drdr.Close();

                SQLClass.Insert("INSERT INTO " + Tables.ADVERTISMENT +
                                "(Text, Pic, Date_From, Data_to, id, new)" +
                                " VALUES (" +
                                "'" + text_na_reklame.Text + "'" +
                                ", '" + textBox_adress.Text + "'" +
                                ", '13.10.2018', '20.10.2018', '" + NewAdvId + "', '1')");

                foreach (String item in checkedListBox1.CheckedItems)
                {
                    SQLClass.Insert("INSERT INTO " + Tables.PROMO_CATEGORIES_LINK +
                                    "(id_promo, category, money)" +
                                    " VALUES (" + NewAdvId + ",'" + item + "', 1)");
                }
            }
            MessageBox.Show("Ваша реклама отправлена на рассмотрение");
            this.Close();
        }
Ejemplo n.º 3
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
        }
Ejemplo n.º 4
0
        private void textBox_name_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                SQLClass.Insert("INSERT INTO " + Tables.CATEGORIES +
                                "(`Name`, `Picture`, `Coteg_ID`)" +
                                " VALUES (\"" + textBox_name.Text + "\", \"a\", 0)");

                update();
            }
        }
Ejemplo n.º 5
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 + "'))");
            }
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
 private void button1_Click(object sender, EventArgs e)
 {
     SQLClass.Insert("INSERT INTO `Colection` (`id_art`, `Coll_text`) VALUES ('" + textBox1.Text + "', " + "'" + New.Text + "')");
 }
Ejemplo n.º 9
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();
        }