private void Form1_Load(object sender, EventArgs e) { metroTextBox1.Enabled = metroTextBox2.Enabled = metroTextBox3.Enabled = textBox1.Enabled = false; metroButton2.Enabled = metroButton4.Enabled = metroButton5.Enabled = false; metroGrid2.Enabled = false; richTextBox1.Clear(); metroLabel6.Text = ""; access_data ad = new access_data(); metroGrid1.DataSource = ad.ReturnWebSiteUrl(); UrlBoxRow = this.metroGrid1.RowCount; if (UrlBoxRow == 0) { textBox1.Enabled = false; metroTextBox1.Enabled = metroTextBox2.Enabled = metroTextBox3.Enabled = false; metroButton4.Enabled = metroButton5.Enabled = metroButton2.Enabled = metroButton10.Enabled = false; metroGrid2.Enabled = false; } DataGridViewButtonColumn bcol = new DataGridViewButtonColumn(); bcol.HeaderText = "Click Me"; bcol.Text = "Check"; bcol.Name = "btnClickMe"; bcol.UseColumnTextForButtonValue = true; metroGrid1.Columns.Add(bcol); string value = ad.CheckUpdateNotificationThroughEmail(); if (value == "yes" && firstTimeForm1 == 0) { if (CheckForInternetConnection() == true) { string email = ad.getemail(); if (ad.getemail() != "empty" && UrlBoxRow >= 1) { string x = ad.SendMail(GetAllTagData()); if (x != String.Empty) { MetroMessageBox.Show(this, x, "Wsh notify", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MetroMessageBox.Show(this, "No internet connection available,please check your internet connection or troubleshoot your internet connection", "WSH notify", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void DynamicThreading() { access_data ad = new access_data(); DataTable t = new DataTable(); t = ad.ReturnWebSiteUrl(); for (int i = 0; i < metroGrid1.Rows.Count; i++) { string x = t.Rows[i]["url"].ToString(); Thread th = new Thread(() => { UseThreadForCheckingUrlTagAndValue(x); }); th.IsBackground = true; th.Start(); } }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { if (backgroundWorker1.CancellationPending) { e.Cancel = true; } else { access_data ad = new access_data(); DataTable t = new DataTable(); t = ad.ReturnWebSiteUrl(); int count = metroGrid1.Rows.Count; int value = 100 / count; int xx = value; for (int i = 0; i < metroGrid1.Rows.Count; i++) { string x = t.Rows[i]["url"].ToString(); Thread th = new Thread(() => { UseThreadForCheckingUrlTagAndValue1(x); }); th.IsBackground = true; th.Start(); Thread.Sleep(2000); this.Invoke(new MethodInvoker(delegate() { metroLabel6.Text = "Checking URL:" + x + " Completed:" + value + " %"; })); backgroundWorker1.ReportProgress(value); value = value + xx; } this.Invoke(new MethodInvoker(delegate() { richTextBox1.AppendText("=========================================\n" + "=========================================\n" + "=========================================\n"); })); this.Invoke(new MethodInvoker(delegate() { metroLabel6.Text = "Completed..........."; })); } }
private void metroButton2_Click(object sender, EventArgs e) { if (metroTextBox1.Text == "") { CheckEmpty(); } else { if (aa == 0) { MetroMessageBox.Show(this, "please edit text first from [url or tag name or tag value or description]", "WSH notify", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { site n = new site(); n.url = metroTextBox1.Text; n.description = textBox1.Text; access_data ad = new access_data(); DialogResult ff = MetroMessageBox.Show(this, "Are you really wants to change the information?", "WSH notify", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (ff == DialogResult.OK) { if (ad.Edit_web_info(n, UrlId) == true) { MetroMessageBox.Show(this, "information successfully update", "WSH notify", MessageBoxButtons.OK, MessageBoxIcon.Information); access_data addd = new access_data(); metroGrid1.DataSource = addd.ReturnWebSiteUrl(); } else { DialogResult dd = MetroMessageBox.Show(this, "something went wrong!", "WSH notify", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); if (dd == DialogResult.Cancel) { Application.Exit(); } } } } } }
private void deleteRecordToolStripMenuItem1_Click(object sender, EventArgs e) { access_data d = new access_data(); if (d.DeleteUrl(url) == true) { MetroMessageBox.Show(this, "Information successfully deleted", "WSH notify", MessageBoxButtons.OK, MessageBoxIcon.Information); metroGrid2.DataSource = null; } metroGrid1.DataSource = d.ReturnWebSiteUrl(); UrlBoxRow = this.metroGrid1.RowCount; if (UrlBoxRow < 1) { textBox1.Enabled = false; metroTextBox1.Enabled = metroTextBox2.Enabled = metroTextBox3.Enabled = false; metroButton4.Enabled = metroButton5.Enabled = metroButton2.Enabled = false; metroGrid2.Enabled = false; } textBox1.Text = ""; metroTextBox1.Text = ""; }