public void Getadmins() { string sql = "SELECT * FROM admns"; con_db getadmns = new con_db(); getadmns.OpenConnection(); MySqlDataReader read = getadmns.Readinfo(sql); while (read.Read()) { ListViewItem row = new ListViewItem(); row.SubItems.Add("" + read["usrname"]); row.SubItems.Add("" + read["usrpswrd"]); row.SubItems.Add("" + read["dob"]); row.SubItems.Add("" + read["gender"]); row.SubItems.Add("" + read["email"]); row.SubItems.Add("" + read["phone"]); row.SubItems.Add("Admin"); listView1.Items.Add(row); //listBox2.Items.Add("" + read["usrname"]);// + " |" + read["email"]); //dataGridView1.Rows.Add(read["usrname"]); //listBox1.Items.Add(read["usrname"].ToString()); } getadmns.CloseConnection(); }
private void Getallcharts(string sql, bool decide = true) //Queries for all charts in the system { con_db getcharts = new con_db(); getcharts.OpenConnection(); MySqlDataReader readcharts = getcharts.Readinfo(sql); while (readcharts.Read()) { if (decide) { listCharts.Items.Add(readcharts["chart_number"]); } else { label11.Text = "" + readcharts["chart_number"]; label12.Text = "" + readcharts["st_code"]; //label13.Text= ""+ readcharts["date_digitized"]; label14.Text = "" + readcharts["season"]; string on = "" + readcharts["date_on"]; string off = "" + readcharts["date_off"]; label16.Text = "" + on; label18.Text = "" + off; DateTime don = Convert.ToDateTime(on).Date; DateTime doff = Convert.ToDateTime(off).Date; string diff = doff.Subtract(don).ToString(); label15.Text = "" + diff; } } getcharts.CloseConnection(); }
public void Getallusers() { try { string sql = "SELECT * FROM gnrlusers"; con_db getusers = new con_db(); getusers.OpenConnection(); MySqlDataReader read = getusers.Readinfo(sql); while (read.Read()) { ListViewItem row = new ListViewItem(); row.SubItems.Add("" + read["usrname"]); row.SubItems.Add("" + read["usrpswrd"]); row.SubItems.Add("" + read["dob"]); row.SubItems.Add("" + read["gender"]); row.SubItems.Add("" + read["email"]); row.SubItems.Add("" + read["phone"]); row.SubItems.Add("G/User"); listView1.Items.Add(row); } getusers.CloseConnection(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private bool get_indices() { int[] pointarray = new int[100]; int arrayindex = 0; con_db getindex = new con_db(); string sql = "SELECT chart_index FROM charts ORDER BY chart_index DESC"; getindex.OpenConnection(); MySqlDataReader readindex = getindex.Readinfo(sql); while (readindex.Read()) { pointarray[arrayindex] = int.Parse("" + readindex["chart_index"]); arrayindex++; } if (validate_dates(pointarray)) { return(true); } else { return(false); } }
private void poptoeditchrt(string thequery) { con_db getforedit = new con_db(); getforedit.OpenConnection(); MySqlDataReader readcharts = getforedit.Readinfo(thequery); while (readcharts.Read()) { textBox1.Text = "" + readcharts["chart_number"]; textBox2.Text = "" + readcharts["st_code"]; textBox4.Text = "" + readcharts["season"]; string date_digitized = "" + readcharts["date_digitized"]; string dateon = "" + readcharts["date_on"]; string dateoff = "" + readcharts["date_off"]; DateTime ddgtzd = Convert.ToDateTime(date_digitized).Date; DateTime don = Convert.ToDateTime(dateon).Date; DateTime doff = Convert.ToDateTime(dateoff).Date; dateTimePicker1.Value = ddgtzd; dateTimePicker2.Value = don; dateTimePicker3.Value = doff; string diff = doff.Subtract(don).ToString(); textBox5.Text = "" + diff; } }
private void button3_Click(object sender, EventArgs e) { con_db del_chart = new con_db(); del_chart.OpenConnection(); string sql = "DELETE FROM charts WHERE chart_number='" + listCharts.SelectedItem.ToString() + "'"; MessageBox.Show("Are you sure you want to delete the chart"); }
private void button2_Click(object sender, EventArgs e) { con_db newconection = new con_db(); if (newconection.OpenConnection() == true) { MessageBox.Show("Connection Successfull"); } else { MessageBox.Show("Connection Unsuccessfull"); } }
private void Getforchatrt(string sql) // Queries for a specific chart to display in chart area { con_db getcharts = new con_db(); getcharts.OpenConnection(); MySqlDataReader readcharts = getcharts.Readinfo(sql); chart1.Series["Series1"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; while (readcharts.Read()) { //MessageBox.Show("Got point " + readcharts["X(actualcoord)"].ToString()+", "+ readcharts["Y(actualcoord)"].ToString()); //for testing MessageBox.Show("" + readcharts["st_code"] + ", " + readcharts["st_name"]); chart1.Series["Series1"].Points.AddXY(readcharts["X(actualcoord)"].ToString(), readcharts["Y(actualcoord)"].ToString()); } getcharts.CloseConnection(); }
private bool validate_dates(int[] indexarray) { try { con_db getlargestindex = new con_db(); string newsql = "SELECT date_off FROM charts WHERE chart_index ='" + indexarray[0] + "'"; getlargestindex.OpenConnection(); MySqlDataReader newreadindex = getlargestindex.Readinfo(newsql); newreadindex.Read(); if (!newreadindex.HasRows) { return(true); } string off = "" + newreadindex["date_off"]; DateTime doff = Convert.ToDateTime(off).Date; var don = dateTimePicker1.Value; if (don.Subtract(doff).TotalDays >= 1) { if (DialogResult.Yes == MessageBox.Show("River data for the past " + don.Subtract(doff).TotalDays + " days is will not be captured. Do you want to continue? ", "Loose data", MessageBoxButtons.YesNo)) { return(true); } else { return(false); } } else { //MessageBox.Show("dates good"); return(true); } } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } }
private void textBox1_TextChanged(object sender, EventArgs e) { string sql = "SELECT * FROM gnrlusers WHERE usrname='" + textBox1.Text + "' "; // MessageBox .Show(""+ sql ); //testing sql con_db populateforsearch = new con_db(); populateforsearch.OpenConnection(); MySqlDataReader read = populateforsearch.Readinfo(sql); while (read.Read()) { ListViewItem row = new ListViewItem(); row.SubItems.Add("" + read["usrname"]); row.SubItems.Add("" + read["usrpswrd"]); row.SubItems.Add("" + read["dob"]); row.SubItems.Add("" + read["gender"]); row.SubItems.Add("" + read["email"]); row.SubItems.Add("" + read["phone"]); row.SubItems.Add("G/User"); listView1.Items.Add(row); } //populateforsearch.CloseConnection(); read.Close(); /* con_db populateforsearch2 = new con_db();*/ string sql2 = "SELECT * FROM admns WHERE usrname='" + textBox1.Text + "' "; MySqlDataReader read2 = populateforsearch.Readinfo(sql2); //populateforsearch.OpenConnection(); while (read2.Read()) { ListViewItem row = new ListViewItem(); row.SubItems.Add("" + read2["usrname"]); row.SubItems.Add("" + read2["usrpswrd"]); row.SubItems.Add("" + read2["dob"]); row.SubItems.Add("" + read2["gender"]); row.SubItems.Add("" + read2["email"]); row.SubItems.Add("" + read2["phone"]); row.SubItems.Add("Admin"); listView1.Items.Add(row); } //populateforsearch2.CloseConnection(); }
private void textBox1_TextChanged(object sender, EventArgs e) { string sql = "SELECT * FROM stations WHERE st_code='" + textBox1.Text + "' "; // MessageBox .Show(""+ sql ); //testing sql con_db populateforsearch = new con_db(); populateforsearch.OpenConnection(); MySqlDataReader read = populateforsearch.Readinfo(sql); while (read.Read()) { ListViewItem row = new ListViewItem(); row.SubItems.Add("" + read["st_name"]); row.SubItems.Add("" + read["st_code"]); listView1.Items.Add(row); } //populateforsearch.CloseConnection(); read.Close(); }
private void login_Load(object sender, EventArgs e) { textBox1.Focus(); con_db atload = new con_db(); if (atload.OpenConnection()) { label3.ForeColor = Color.Blue; string codetail = atload.Getserverdetail(); label3.Text = "Connected to server at " + codetail; atload.CloseConnection(); } else { label3.ForeColor = Color.Red; label3.Text = "Connection to server Failed"; } }
private void getmyprofile() { string sql = "SELECT * FROM gnrlusers WHERE usrname='" + globals.usernamme + "' "; // MessageBox .Show(""+ sql ); //testing sql con_db populateprof = new con_db(); populateprof.OpenConnection(); MySqlDataReader read = populateprof.Readinfo(sql); while (read.Read()) { label1.Text = "" + read["usrname"].ToString(); label6.Text = "" + read["phone"].ToString(); label3.Text = "" + read["dob"].ToString(); label4.Text = "" + read["gender"].ToString(); label5.Text = "" + read["email"].ToString(); } populateprof.CloseConnection(); }
private void Populate() { try { string sql = "SELECT * FROM " + globals.tablescope + " WHERE usrname='" + globals.targetuser + "' "; // MessageBox .Show(""+ sql ); //testing sql con_db populateforedit = new con_db(); populateforedit.OpenConnection(); MySqlDataReader read = populateforedit.Readinfo(sql); while (read.Read()) { textusrername.Text = read["usrname"].ToString(); textpassword.Text = read["usrpswrd"].ToString(); textverify.Text = read["usrpswrd"].ToString(); textphone.Text = read["phone"].ToString(); //dateTimedob.Text = read["dob"].ToString(); combogender.Text = read["gender"].ToString(); textemail.Text = read["email"].ToString(); if (globals.tablescope == "admns") { textacceslevel.Text = "Administrator"; } else if (globals.tablescope == "gnrlusers") { textacceslevel.Text = "General User"; } globals.rowid = int.Parse(read["usrID"].ToString()); } populateforedit.CloseConnection(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void Getallstations() { try { string sql = "SELECT * FROM stations"; con_db getstations = new con_db(); getstations.OpenConnection(); MySqlDataReader read = getstations.Readinfo(sql); while (read.Read()) { ListViewItem row = new ListViewItem(); row.SubItems.Add("" + read["st_name"]); row.SubItems.Add("" + read["st_code"]); listView1.Items.Add(row); } getstations.CloseConnection(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button4_Click(object sender, EventArgs e) { button2.Visible = false; try { ListViewItem record = listView1.SelectedItems[0]; string sql = "SELECT * FROM stations WHERE st_code =" + record.SubItems[2].Text; con_db getstations = new con_db(); getstations.OpenConnection(); MySqlDataReader read = getstations.Readinfo(sql); while (read.Read()) { textBox2.Text = read["st_name"].ToString(); textBox3.Text = read["st_code"].ToString(); } button5.Visible = true; getstations.CloseConnection(); } catch (Exception) { MessageBox.Show("Please make a selecton first"); } }