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");
            }
        }
예제 #2
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();
            }
        }
        /* 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);
            }
        }