示例#1
0
        public void submit_click(object sender, EventArgs e)
        {
            try {
                string radioButtons = "";


                con.Open();
                if (radioButton1.Checked)
                {
                    radioButtons = "INSERT INTO DataBaseName(plan)VALUES ('Basic')";
                }
                if (radioButton2.Checked)
                {
                    radioButtons = "INSERT INTO DataBaseName(plan)VALUES ('Standard')";
                }
                if (radioButton3.Checked)
                {
                    radioButtons = "INSERT INTO DataBaseName(plan)VALUES ('Premium')";
                }
                MySqlCommand cmd = new MySqlCommand(radioButtons, con);


                cmd.ExecuteNonQuery();
                con.Close();



                var answer = MessageBox.Show("Are you sure the filled in Information is Accurate and you have selected desired plan ?", "", MessageBoxButtons.YesNo);
                if (answer.ToString().ToLower().Equals("yes"))
                {
                    MessageBox.Show("Customer Added Successfully");
                    HomeForm homeForm = new HomeForm();
                    homeForm.Show();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Please reselect");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("error");
            }
        }
示例#2
0
        public void login(object sender, EventArgs e)
        {
            try {
                //checking if user info entered in password and username boxes matches an entry in the database
                string        conString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=\"F: \\UNIVERSITY\\SEMESTER 2\\.NET WITH C#\\PROJECT\\github connected\\TDMS\\Database1.mdf\";";
                string        sql       = "SELECT * FROM login where username= '******' and password= '******'";
                SqlConnection con       = new SqlConnection(conString);
                int           j         = 0;
                con.Open();
                SqlCommand cmd = new SqlCommand(sql, con);
                cmd.ExecuteNonQuery();

                DataTable      dt        = new DataTable();
                SqlDataAdapter dataAdapt = new SqlDataAdapter(cmd);
                dataAdapt.Fill(dt);
                j = dt.Rows.Count;
                //moves to the homepage if correct, prints error message if incorrect

                if (j == 0)
                {
                    invalidUserLabel.Text = "Invalid user or password";
                }
                else
                {
                    this.Hide();
                    HomeForm homeForm = new HomeForm();
                    homeForm.Show();
                }
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("error:" + ex.Message);
            }
            finally
            {
                this.Hide();
                HomeForm homeForm = new HomeForm();
                homeForm.Show();
            }
        }