/// <summary> /// Случайная реклама /// </summary> public static List <String> GetRandom() { List <String> pics = new List <String>(); String reklPic = "https://i.imgur.com/eQ4wEpO.gif"; String ss = "https://i.imgur.com/eQ4wEpO.gif"; Random rnd = new Random(); List <String> reklPics = SQLClass.Select( "SELECT pic FROM " + Tables.ADVERTISMENT + " WHERE pic != ''" + " AND STR_TO_DATE(Date_From, '%d.%m.%Y') <= now()" + " AND STR_TO_DATE(Data_to, '%d.%m.%Y')>= now() AND 'new' = 0"); List <String> ssData = SQLClass.Select( "SELECT text FROM " + Tables.ADVERTISMENT + " WHERE pic != ''" + " AND STR_TO_DATE(Date_From, '%d.%m.%Y') <= now()" + " AND STR_TO_DATE(Data_to, '%d.%m.%Y')>= now() AND 'new' = 0"); int v = rnd.Next(1, reklPics.Count); if (reklPics[v - 1] != "") { ss = ss[v - 1].ToString(); reklPic = reklPics[v - 1].ToString(); } pics.Add(reklPic); pics.Add(ss); return(pics); }
private void StastisticsForm_Load(object sender, EventArgs e) { this.Font = Configs.USER_FONT; this.ForeColor = Configs.USER_COLOR; List <String> AuthorsData = SQLClass.Select("SELECT UserName, Views, Likes, Dislikes " + " FROM " + Tables.AUTHORS + " ORDER BY UserName"); authorsDGV.Rows.Clear(); for (int index = 0; index < AuthorsData.Count; index += 4) { authorsDGV.Rows.Add(); authorsDGV.Rows[index / 4].Cells[0].Value = AuthorsData[index]; authorsDGV.Rows[index / 4].Cells[1].Value = AuthorsData[index + 1]; authorsDGV.Rows[index / 4].Cells[2].Value = AuthorsData[index + 2]; authorsDGV.Rows[index / 4].Cells[3].Value = AuthorsData[index + 3]; } this.Controls.Clear(); if (true == true) { this.Controls.Add(authorsDGV); } else { this.Controls.Add(tableLayoutPanel1); } }
private void Registration_Load(object sender, EventArgs e) { this.Font = Configs.USER_FONT; this.ForeColor = Configs.USER_COLOR; if (ob) { infoObAvtore = SQLClass.Select("SELECT UserName, Pic, Information_about_author FROM " + Tables.AUTHORS + " WHERE UserName = '******'"); if (infoObAvtore.Count > 2) { button_come.Text = "Обновить данные"; textBox_login.Text = infoObAvtore[0]; textBox_pic.Text = infoObAvtore[1]; textBox_zapas.Enabled = false; try { pictureBox1.LoadAsync(textBox_pic.Text); } catch (Exception) { pictureBox1.Image = new Bitmap("defolt_avtor.jpg"); } textBox_about_me.Text = infoObAvtore[2]; textBox_password.Enabled = false; checkBox_agree.Visible = false; checkBox_I_author.Visible = false; } else { } } else { button2.Visible = false; } }
/// <summary> /// Вход в систему под админом /// </summary> public static bool LogIntoAdminZone(String Login, String Password) { //Проверка на администратора List <String> isAdminData = SQLClass.Select( "SELECT COUNT(*) FROM " + Tables.POLZOVATELI + " WHERE `Login`=\"" + Login + "\" AND `admin` = 1"); String IsAdmin = isAdminData[0].ToString(); if (IsAdmin != "0") { List <String> loginSuccessData = SQLClass.Select( "SELECT * FROM " + Tables.POLZOVATELI + " WHERE `Login`=\"" + Login + "\" AND `Parol`=\"" + Password + "\""); if (loginSuccessData.Count > 0) { return(true); } else { MessageBox.Show("password"); } } return(false); }
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; } }
public static void GetListOfArtic(ref Panel comp, string cat) { comp.Controls.Clear(); comp.Controls.Add(pictureBox1); pictureBox1.Location = new Point(300, 10); pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; List <String> ArticlesList = SQLClass.Select("SELECT `Header` FROM " + Tables.ARTICLES + " WHERE `Category` = '" + cat + "'"); int artY = 10; foreach (String Article in ArticlesList) { Label label1 = new Label(); label1.Size = new Size(200, 20); label1.Location = new Point(50, artY + 50); label1.Text = Article; label1.Click += new System.EventHandler(lable1_Click); label1.MouseEnter += new System.EventHandler(label1_MouseEnter); label1.MouseLeave += new System.EventHandler(label1_MouseLeave); comp.Controls.Add(label1); artY += 30; } if (artY == 10) { Label label1 = new Label(); label1.Size = new Size(200, 20); label1.Location = new Point(50, artY + 50); label1.Text = "Тут ничего нет"; comp.Controls.Add(label1); } }
private void ArticleClick(object sender, EventArgs e) { foreach (LinkLabel lab in arts) { if (sender.Equals(lab)) { List <String> ArticleInfo = SQLClass.Select( "SELECT Header, Author, Category, Text, Picture FROM " + Tables.ARTICLES + " WHERE header = '" + lab.Text + "'"); for (int artIndex = 0; artIndex < ArticleInfo.Count; artIndex += 5) { statiya stat = new statiya(); stat.name_statiya = ArticleInfo[artIndex].ToString(); stat.name_author = ArticleInfo[artIndex + 1].ToString(); stat.kategorita_statii = ArticleInfo[artIndex + 2].ToString(); stat.text_statii = ArticleInfo[artIndex + 3].ToString(); //FIXME!!! Show ternarny operator stat.picture = (ArticleInfo[artIndex + 4].ToString() != "") ? ArticleInfo[artIndex + 4].ToString() : null; StatiyaForm OknoStatiya = new StatiyaForm(stat, true); OknoStatiya.ShowDialog(); } } } }
private void VipStatiy_Load(object sender, EventArgs e) { GetStata(label3, label4, name.Text); String[] d = s.Split('\n'); for (int i = 0; i < d.Length; i++) { if (d[d.Length - 1 - i].Contains("http://") || d[d.Length - 1 - i].Contains("https://")) { LinkLabel label1 = new LinkLabel(); label1.Location = new Point(0, 0); label1.Size = new Size(180, 20); label1.Text = d[d.Length - 1 - i]; label1.Click += new System.EventHandler(labelClick); label1.Dock = DockStyle.Top; panel1.Controls.Add(label1); PictureBox artImage = new PictureBox(); artImage.Location = new Point(0, 25); artImage.Size = new Size(panel1.Width, 150); artImage.Dock = DockStyle.Top; artImage.SizeMode = PictureBoxSizeMode.StretchImage; panel1.Controls.Add(artImage); String[] chasti_stroki = d[d.Length - 1 - i].Split(new char[] { ' ', '/' }); try { artImage.Image = new Bitmap(chasti_stroki[chasti_stroki.Length - 1]); } catch (Exception) { try { artImage.LoadAsync(d[d.Length - 1 - i]); Uri uri = new Uri(d[d.Length - 1 - i]); client.DownloadFileAsync(uri, chasti_stroki[chasti_stroki.Length - 1]); } catch (Exception) { artImage.Dispose(); } } } else { Label label1 = new Label(); label1.Location = new Point(0, 0); label1.Size = new Size(180, 20); label1.Text = d[d.Length - 1 - i]; label1.Dock = DockStyle.Top; panel1.Controls.Add(label1); } } List <String> countRecords = SQLClass.Select( "SELECT COUNT(*) FROM " + Tables.READ_OF_ARTICLES + " WHERE `name_of_article` = '" + name.Text + "'"); label1.Text = "Просмотров: " + countRecords[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 }
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); }
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; } }
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; }
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); } }
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; } }
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"; } }
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]; }
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; }
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++; } }
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("Вас в безе нет (Не верен пароль или логин)"); } }
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); }
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); }
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 = "Поиск"; }
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; }
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++; }
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; } }
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(); }
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 }