Example #1
0
        public static void pictureBoxLike_Clicking1(String Text, bool isLike)
        {
            List <String> textesAut = SQLClass.Select("SELECT Author, Category FROM " + Tables.ARTICLES + " WHERE `Header` = '" + Text + "'");

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

            if (isLike)
            {
                if (likes.Count > 0)
                {
                    SQLClass.Update("UPDATE " + Tables.LIKES +
                                    " SET LikesCount = LikesCount + 1" +
                                    " WHERE Article = '" + Text + "'");
                }
                else
                {
                    SQLClass.Insert(
                        "INSERT INTO " + Tables.LIKES +
                        "(Article, Author, Category, LikesCount, DisCount)" +
                        " VALUES (" +
                        "'" + Text + "'" +
                        ", '" + textesAut[0] + "'" +
                        ", '" + textesAut[1] + "'" +
                        ",1" +
                        ",0)");
                }
            }
            else
            {
                SQLClass.Update("UPDATE " + Tables.LIKES +
                                " SET LikesCount = LikesCount - 1" +
                                " WHERE Article = '" + Text + "'");
            }
        }
        /// <summary>
        /// Кнопка добавления статьи
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        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;
            }
        }
        /// <summary>
        ///  нопка отправки статьи на рассмотрение
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        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();
        }
        /// <summary>
        /// Функция сохранения юзерконтрола на форму и базу.
        /// </summary>
        public static void SaveUserControl(object sender, EventArgs e)
        {
            UserControl pb       = (UserControl)((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl;
            string      FormName = pb.FindForm().Name;

            MessageBox.Show(pb.Location.X.ToString());
            SQLClass.Insert("INSERT INTO `block`(`form`,`Parent`, `x`, `y`, `name`, Dock) VALUES ('" + FormName + "','" + pb.Parent.Name + "'," + pb.Location.X + ", " + pb.Location.Y + ",'" + pb.Name + "','" + pb.Dock + "')");
        }
Example #5
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 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();
            }
        }
        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 " + Tables.ARTICLES + " WHERE `Header` = '" + str + "'))");
            }
        }
        /// <summary>
        /// Добавление информации о блоке в БД
        /// </summary>
        public static void InsertBlockToDB(object sender, UserControl a1, string par)
        {
            Control c = ((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl;

            c.Controls.Add(a1);
            //Program.CONTROLY.Add(a1);
            SQLClass.Insert("INSERT INTO block(form,Parent,x,y,name,Params, Dock) VALUES ('" +
                            c.FindForm().Name + "', '" + c.Name + "', '" + a1.Location.X + "','" + a1.Location.Y + "','" + a1.Name + "','" + par + "', '" + c.Dock + "')");

            List <String> str = SQLClass.Select("SELECT MAX(id) FROM block");

            a1.Tag = str[0];
        }
Example #9
0
 public static void UpdateLabelDesignInDb(Control pb)
 {
     SQLClass.Delete("DELETE FROM " + Tables.UNIQUE +
                     " WHERE type = 'Label'" +
                     " AND name = '" + pb.Name +
                     "' AND FormFrom = '" + pb.FindForm().Name + "'");
     SQLClass.Insert("INSERT INTO " + Tables.UNIQUE +
                     " (type, design, author, name, FormFrom) VALUES " +
                     "('Label', " +
                     "'ForeColor = " + ButtonUniqueForm.ColorToJSON(pb.ForeColor) +
                     ", FontName = " + pb.Font.Name +
                     ", FontSize = " + pb.Font.Size +
                     ", Text = " + pb.Text +
                     "', 'admin', '" + pb.Name + "', '" + pb.FindForm().Name + "')");
 }
 /// <summary>
 /// Обновление дизайна конкретной кнопки в БД
 /// </summary>
 public static void UpdateButtonDesignInDb(Button pb)
 {
     SQLClass.Delete("DELETE FROM " + Tables.UNIQUE +
                     " WHERE type = 'Button'" +
                     " AND name = '" + pb.Name +
                     "' AND FormFrom = '" + pb.FindForm().Name + "'");
     SQLClass.Insert("INSERT INTO " + Tables.UNIQUE +
                     " (type, design, author, name, FormFrom) VALUES " +
                     "('Button', " +
                     "'Color = " + ColorToJSON(pb.BackColor) +
                     ", Visible = " + pb.Visible +
                     ", BackgroundImage = " + pb.BackgroundImage +
                     ", Text = " + pb.Text +
                     ", Dock = " + pb.Dock.ToString() +
                     ", FlatStyle = " + pb.FlatStyle +
                     "', 'admin', '" + pb.Name + "', '" + pb.FindForm().Name + "')");
 }
Example #11
0
        public void pictureBoxLike_Clicking(object sender, EventArgs e)
        {
            if (isDisLike)
            {
                pictureBoxDislike_Click(sender, e);
            }
            isLike = !isLike;
            pictureBoxLike.Image = (isLike) ?
                                   Properties.Resources.Like2 :
                                   Properties.Resources.like;

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

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

            GetStata(labelLike, labeldis, Maintext.Text);
        }
        public static Dictionary <string, JObject> typeSerialize()
        {
            Dictionary <string, JObject> AllTypesData = new Dictionary <string, JObject>();

            #region Button
            Dictionary <string, string> ButtonData = new Dictionary <string, string>();
            if (DesignClass.BUTTON_BACKGROUND_IMG_ADRESS != null)
            {
                ButtonData.Add("BackgroundImage", DesignClass.BUTTON_BACKGROUND_IMG_ADRESS.ToString());
            }

            //ButtonData.Add("BackgroundImageLayout", button1.BackgroundImageLayout.ToString());

            if (DesignClass.BUTTON_TEXT_COLOR != null)
            {
                ButtonData.Add("ForeColor", ButtonUniqueForm.ColorToJSON(DesignClass.BUTTON_TEXT_COLOR));//DesignClass.BUTTON_TEXT_COLOR.ToString());
            }
            if (DesignClass.BUTTON_FONT != null)
            {
                ButtonData.Add("Font", DesignClass.BUTTON_FONT.ToString());
            }
            if (DesignClass.BUTTON_COLOR != null)
            {
                ButtonData.Add("Color", ButtonUniqueForm.ColorToJSON(DesignClass.BUTTON_COLOR));//.ToString());
            }

            ButtonData.Add("ImageAlign", DesignClass.BUTTONIMAGE_ALLINE.ToString());   //.ToString());
            ButtonData.Add("FlatStyle", Convert.ToString(DesignClass.FLAT_OF_BUTTON)); //.ToString());

            #endregion
            AllTypesData.Add("button", JObject.FromObject(ButtonData));

            foreach (string type in AllTypesData.Keys)
            {
                SQLClass.Delete("DELETE FROM " + Tables.DEFAULT + " WHERE type = '" + type + "'");
                SQLClass.Insert(String.Format("INSERT INTO " + Tables.DEFAULT + "(type, design, author) VALUES ('{0}','{1}','{2}')",
                                              type, AllTypesData[type].ToString(), "test"));
            }

            return(AllTypesData);
        }
        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);
        }
Example #14
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 Author = '" + textBox_login.Text +
                                    "' WHERE Author = '" + login + "'");

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

                SQLClass.Update("UPDATE " + Tables.AUTHORS +
                                " SET UserName = '******', Pic = '" + textBox_pic.Text +
                                "', Information_about_author = '" + textBox_about_me.Text +
                                "' WHERE UserName = '******'");
            }

            Close();
        }
 private void button1_Click(object sender, EventArgs e)
 {
     SQLClass.Insert("INSERT INTO " + Tables.COLLECTION + " (`id_art`, `Coll_text`) VALUES ('" + textBox1.Text + "', " + "'" + New.Text + "')");
 }