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;
            }
        }
Exemple #3
0
        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 void button3_Click(object sender, EventArgs e)
        {
            var chartno      = int.Parse(textBox1.Text);
            var station      = textBox2.Text;
            var datedigitzed = dateTimePicker1.Value.ToString("yyyy/MM/dd");
            int season       = int.Parse(textBox4.Text);
            var dateon       = dateTimePicker2.Value.ToString("yyyy/MM/dd");
            var dateoff      = dateTimePicker3.Value.ToString("yyyy/MM/dd");

            con_db save_chart = new con_db();
            string sql        = "UPDATE  `charts` SET  `st_code` =  '" + station + "',`date_digitized` =  '" + datedigitzed + "',`season` =  '" + season + "',`date_on` =  '" + dateon + "',`date_off` =  '" + dateoff + "' WHERE  `chart_number` =  '" + chartno + "' LIMIT 1";

            if (save_chart.Update(sql))
            {
                MessageBox.Show("Data Updated Successfully");

                Dispose();
                chartmngmnt newform = new chartmngmnt();
                newform.ShowDialog();
            }
            else
            {
                MessageBox.Show("Failed to Update data");
            }
        }
Exemple #5
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                con_db       deleteone = new con_db();
                string       sql       = "";
                ListViewItem record    = listView1.SelectedItems[0];
                sql = "DELETE FROM stations WHERE st_code='" + record.SubItems[2].Text + "'";
                if (DialogResult.Yes == MessageBox.Show("Are you sure you want to delete this station?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    if (deleteone.Delete(sql))
                    {
                        MessageBox.Show("user deleted success!!");
                    }
                }

                else
                {
                    MessageBox.Show("User not found");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Cant perform operation. Make sure you have selected a specific user!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                string station_name = textBox2.Text;
                string station_code = textBox3.Text;
                string thequery     = "INSERT INTO stations (st_name, st_code) VALUES ('" + station_name + "','" + station_code + "')";
                con_db adduser      = new con_db();

                if (adduser.Insert(thequery))
                {
                    MessageBox.Show("Station added successfully");
                    globals.Clearallboxes(this);
                    listView1.Items.Clear();
                    Getallstations();
                }
                else
                {
                    MessageBox.Show("Station add failed!!");
                }
            }
            catch
            {
                MessageBox.Show("An Error occured please contact the system administrator");
            }
        }
        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();
        }
Exemple #8
0
        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 button1_Click(object sender, EventArgs e)
        {
            try
            {
                con_db sttncheck = new con_db();
                int    stcode    = int.Parse(textStationCode.Text);
                string sql       = "SELECT * FROM stations WHERE st_code=" + stcode;
                if (sttncheck.SelectVerifyStation(sql))
                {
                    //MessageBox.Show("The station exists in the database"+stcode);
                    globals.stationcode = stcode;
                    Hide();

                    StationParameters newform = new StationParameters();
                    newform.ShowDialog();
                    Show();
                    textStationCode.Clear();
                    textStationCode.Focus();
                }
                else
                {
                    labelnotexist.Text    = "Station does not exist !!!";
                    labelnotexist.Visible = true;
                    textStationCode.Focus();
                    textStationCode.SelectAll();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Enter Code in the correct format");
            }
        }
        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");
        }
Exemple #11
0
        private void button5_Click(object sender, EventArgs e)
        {
            con_db updatestation = new con_db();
            string thequery      = "UPDATE  `stations` SET  `st_name` =  '" + textBox2.Text + "',`st_code` =  '" + textBox3.Text + "'";

            if (updatestation.Update(thequery))
            {
                MessageBox.Show("Station Update Successfull");
            }
        }
        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");
            }
        }
Exemple #13
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                string username = textusrername.Text;
                string password = textpassword.Text;
                string phone    = textphone.Text;
                string dob      = dateTimedob.Text;
                string gender   = combogender.Text;
                string email    = textemail.Text;
                string thequery = ""; //= "INSERT INTO admns (admName, admPass,phone,dob,gender,email) VALUES ('"+username+"','"+password +"','"+phone+"','"+dob+"','"+gender+"','"+email+"')";
                if ((textpassword.Text == textverify.Text) && (textpassword.Text != ""))
                {
                    if (comboaccess.Text == "Administrator")
                    {
                        thequery = "INSERT INTO admns (usrname, usrpswrd,phone,dob,gender,email) VALUES ('" + username + "','" + password + "','" + phone + "','" + dob + "','" + gender + "','" + email + "')";
                    }
                    else if (comboaccess.Text == "General User")
                    {
                        thequery = "INSERT INTO gnrlusers (usrname, usrpswrd,email,phone,gender,dob) VALUES ('" + username + "','" + password + "','" + email + "','" + phone + "','" + gender + "','" + dob + "')";
                    }
                    else
                    {
                        labelcantuser.Visible = true;
                    }
                    con_db adduser = new con_db();

                    if (adduser.Insert(thequery))
                    {
                        MessageBox.Show("User added successfully");
                        globals.Clearallboxes(this);
                    }
                    else
                    {
                        MessageBox.Show("User add failed!!");
                    }
                }
                else
                {
                    labelcantuser.Text    = "Passwords Do Not Match Please Verify Your Password";
                    labelcantuser.Visible = true;
                }
            }
            catch
            {
                MessageBox.Show("An Error occured please contact the system administrator");
            }
        }
Exemple #14
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                con_db       deleteone = new con_db();
                string       sql       = "";
                ListViewItem record    = listView1.SelectedItems[0];

                if (record.SubItems[7].Text == "Root user")
                {
                    MessageBox.Show("You cannot remove this user from the system");
                }
                else if (record.SubItems[7].Text == "Admin")
                {
                    if (DialogResult.Yes == MessageBox.Show("Are you sure u want to delete this user?", "Confirm deletion", MessageBoxButtons.YesNo))
                    {
                        sql = "DELETE FROM admns WHERE usrname='" + record.SubItems[1].Text + "'";
                        if (deleteone.Delete(sql))
                        {
                            MessageBox.Show("user deleted success!!");
                            Refreshall();
                        }
                    }
                }
                else if (record.SubItems[7].Text == "G/User")
                {
                    if (DialogResult.Yes == MessageBox.Show("Are you sure u want to delete this user?", "Confirm deletion", MessageBoxButtons.YesNo))
                    {
                        sql = "DELETE FROM gnrlusers WHERE usrname='" + record.SubItems[1].Text + "'";
                        if (deleteone.Delete(sql))
                        {
                            MessageBox.Show("user deleted success!!");
                            Refreshall();
                        }
                    }
                }


                else
                {
                    MessageBox.Show("User not found");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Cant perform operation. Make sure you have selected a specific user!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        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 queryforupdate()
        {
            try
            {
                string username = textusrername.Text;

                string thequery = ""; //= "INSERT INTO admns (admName, admPass,phone,dob,gender,email) VALUES ('"+username+"','"+password +"','"+phone+"','"+dob+"','"+gender+"','"+email+"')";
                if ((textpassword.Text == textverify.Text) && (textpassword.Text != ""))
                {
                    if (textacceslevel.Text == "Administrator")
                    {
                        thequery = "UPDATE  `admns` SET  `usrname` =  '" + textusrername.Text + "',`usrpswrd` =  '" + textpassword.Text + "',`phone` =  '" + textphone.Text + "',`dob` =  '" + dateTimedob.Text + "',`gender` =  '" + combogender.Text + "' WHERE  `admns`.`usrID` =  '" + globals.rowid + "' LIMIT 1";
                        // thequery = "UPDATE admns SET usrname= '" + textusrername.Text + "', usrpswrd= '" + textpassword.Text + "',phone= '" + textphone.Text + "',dob= '" + dateTimedob.Text + "', gender= '" + combogender.Text + "', email= '" + textemail.Text + "' ";
                    }
                    else if (textacceslevel.Text == "General User")
                    {
                        thequery = "UPDATE  `gnrlusers` SET  `usrname` =  '" + textusrername.Text + "',`usrpswrd` =  '" + textpassword.Text + "',`phone` =  '" + textphone.Text + "',`dob` =  '" + dateTimedob.Text + "',`gender` =  '" + combogender.Text + "' WHERE  `gnrlusers`.`usrID` =  '" + globals.rowid + "' LIMIT 1";
                    }
                    else
                    {
                        labelcantuser.Visible = true;
                    }
                    con_db updateuser = new con_db();

                    if (updateuser.Update(thequery))
                    {
                        MessageBox.Show("User Updated successfully");
                        Populate();
                    }
                    else
                    {
                        MessageBox.Show("User Update failed!!");
                    }
                }
                else
                {
                    labelcantuser.Text    = "Passwords Do Not Match Please Verify Your Password";
                    labelcantuser.Visible = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #18
0
        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();
        }
Exemple #19
0
        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();
        }
Exemple #20
0
        private void button1_Click(object sender, EventArgs e)
        {
            string username = textBox1.Text;
            string password = textBox2.Text;

            string sqlgnrluser = "******" + username + "' AND usrpswrd='" + password + "'";
            string sqladmin    = "SELECT * FROM admns WHERE usrname='" + username + "'AND usrpswrd='" + password + "'";

            con_db loginuora = new con_db();

            if (loginuora.SelectVerifyStation(sqlgnrluser))
            {
                // MessageBox.Show("user success"); //testing access
                globals.usernamme = username;
                Hide();

                userwelcome newform = new userwelcome();
                newform.ShowDialog();
                Show();
                textBox1.Clear();
                textBox2.Clear();
            }
            else if (loginuora.SelectVerifyStation(sqladmin))
            {
                // MessageBox.Show("admin access"); //testing access
                globals.usernamme = username;
                Hide();

                administrator newform = new administrator();
                newform.ShowDialog();
                Show();
                textBox1.Clear();
                textBox2.Clear();
            }
            else
            {
                labelerror.Text    = "Invalid login parameters!!!";
                labelerror.Visible = true;
                textBox1.Focus();
                textBox1.SelectAll();
                textBox2.Clear();
            }
        }
Exemple #21
0
        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 button2_Click(object sender, EventArgs e)
 {
     try
     {
         con_db qrychart = new con_db();
         int    size     = upload.mystackx.Count;
         MessageBox.Show("size is " + size); //testing
         for (int i = 0; i < size; i++)
         {
             string sql = "INSERT INTO coordinates (chart_number, actualcoord) VALUES ('" + globals.chartnumber + "',GeomFromText('POINT(" + upload.mystackx.Pop() + " " + upload.mystacky.Pop() + ")'))";
             qrychart.Insert(sql);
             MessageBox.Show("Popped point " + upload.mystackx.Pop() + "," + upload.mystacky.Pop()); //Testing point entry
         }
         MessageBox.Show("Success!!!");
         Dispose();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        private void changepwd()
        {
            if ((textBox1.Text == textBox2.Text) && (textBox1.Text != ""))
            {
                string sql = "UPDATE gnrlusers SET usrpswrd='" + textBox1.Text + " ' WHERE usrname='" + globals.usernamme + "'";

                con_db changepwd = new con_db();
                if (changepwd.Update(sql))
                {
                    MessageBox.Show("Password Change Successfull");
                    Dispose();
                }
            }

            else
            {
                label3.Visible = true;
                textBox2.Clear();
                textBox1.Focus();
                textBox1.SelectAll();
            }
        }
        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);
            }
        }
Exemple #26
0
 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");
     }
 }
Exemple #27
0
        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);
            }
        }
        /* public  void Control_KeyUp(object sender, KeyEventArgs e)
         * {
         *   if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
         *   {
         *       this.SelectNextControl((Control)sender, true, true, true, true);
         *   }
         *
         * }*/
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (get_indices())
                {
                    if (radioApendNo.Checked == true)
                    {
                        string season  = comboBox1.SelectedText.ToString();
                        int    chartno = int.Parse(textBox1.Text);
                        // int chartduration = int.Parse(textBox4.Text);
                        var dateon       = dateTimePicker1.Value.ToString("yyyy/MM/dd");
                        var dateoff      = dateTimePicker2.Value.ToString("yyyy/MM/dd");
                        var datedigitzed = System.DateTime.Now;
                        // var range = comboBox2.SelectedText;

                        con_db newentry = new con_db();
                        string sql      = "INSERT INTO charts (chart_number,date_digitized,date_on,date_off,season,st_code) VALUES ('" + chartno + "','" + datedigitzed + "','" + dateon + "','" + dateoff + "','" + season + "','" + globals.stationcode + "')";
                        if (newentry.Insert(sql))
                        {
                            globals.chartnumber = chartno;
                            globals.x_date      = dateon;
                            Hide();

                            upload newform = new upload();
                            newform.ShowDialog();
                            Show();
                            globals.Clearallboxes(this);
                        }
                        else
                        {
                            MessageBox.Show("data not updated");
                        }
                    }

                    else if (radioApendYes.Checked == true)
                    {
                        int    chartno  = int.Parse(textBox3.Text);
                        string sql      = "SELECT * FROM charts WHERE chart_number ='" + chartno + "'AND st_code ='" + globals.stationcode + "'";
                        con_db newentry = new con_db();
                        if (newentry.SelectVerifyStation(sql))
                        {
                            globals.chartnumber = chartno;
                            Hide();
                            upload newform = new upload();
                            newform.ShowDialog();
                            Show();
                        }
                        else
                        {
                            labelcantappend.Text    = "Can not find chart to append";
                            labelcantappend.Visible = true;
                            textBox3.Focus();
                            textBox3.SelectAll();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.Message);
            }
        }