private void button1_Click(object sender, EventArgs e)
        {
            try
               {

            string MyConnection = "datasource=localhost;port=3306;username=root;password=root";

            string Query = "insert into database.users(Username, Password, Name, Email) values('" + this.textBox2.Text + "','" + this.textBox3.Text + "', '" + this.textBox1.Text + "','" + this.textBox4.Text + "')";

            MySqlConnection MyConn = new MySqlConnection(MyConnection);

            MySqlCommand MyCommand = new MySqlCommand(Query, MyConn);
            MySqlDataReader MyReader;
            MyConn.Open();
            MyReader = MyCommand.ExecuteReader();
              MessageBox.Show("Registered successfully");
            this.Hide();
            MyReader.Close();
            MySqlDataReader MyReader2;

            string query2 = "Select * from database.users where Username='******'and Password='******';";
            MySqlCommand MyCommand2 = new MySqlCommand(query2, MyConn);
                   MyReader2 = MyCommand2.ExecuteReader();
                   int count = 0;
            while (MyReader2.Read())
            {
                count = count + 1;
            }
                if (count==1)
                {

                    MainForm m=new MainForm(MyReader2.GetString("Name"));
                    m.Show();

                }

            }
            catch (Exception ex)
            {
            MessageBox.Show(ex.Message);
              }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string MyConnection = "datasource=localhost;port=3306;username=root;password=root";
            MySqlConnection conn = new MySqlConnection(MyConnection);
            MySqlDataAdapter da = new MySqlDataAdapter("Select * from database.users where Username='******'and Password='******'", conn);
            DataTable dt = new System.Data.DataTable();
            da.Fill(dt);
            if (dt.Rows.Count == 1)
            {
                this.Hide();
                MainForm m = new MainForm(dt.Rows[0][0].ToString());
                m.Show();
                ((Form)m).Controls["label5"].Text = dt.Rows[0][0].ToString();
            }
            else
            {
                MessageBox.Show("Check Username/password and Please Try again");
                textBox2.Clear();
                textBox1.Clear();

            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (Contact_ID == 0)
                {

                    string MyConnection = "datasource=localhost;port=3306;username=root;password=root";

                    string Query = "insert into `database`.`contact_info` (`FirstName`, `LastName`, `Address1`, `Address2`, `City`, `State`, `Zip`, `PhoneNumber`) values('" + this.textBox1.Text + "','" + this.textBox2.Text + "', '" + this.textBox3.Text + "','" + this.textBox4.Text + "','" + this.textBox5.Text + "', '" + this.comboBox1.Text + "','" + this.textBox6.Text + "','" + this.textBox7.Text + "');SELECT LAST_INSERT_ID();";

                    MySqlConnection MyConn = new MySqlConnection(MyConnection);

                    MySqlCommand MyCommand = new MySqlCommand(Query, MyConn);
                    MySqlDataReader MyReader;
                    MyConn.Open();
                    MyReader = MyCommand.ExecuteReader();
                    string ContactID = string.Empty;
                    while (MyReader.Read())
                    {
                        ContactID = MyReader[0].ToString();
                    }
                    MyReader.Close();
                    if (comboBox2.SelectedItem.ToString() == "Provider")
                    {
                        string Query1 = "insert into `database`.`provider_info`(`contact_ID`,`NPI_Number`, `DEA_Number`) values('" + ContactID + "','" + this.textBox8.Text + "','" + this.textBox9.Text + "');";
                        MySqlCommand MyCommand1 = new MySqlCommand(Query1, MyConn);
                        MySqlDataReader MyReader1;
                        if (MyConn != null && MyConn.State == ConnectionState.Closed)
                        {
                            MyConn.Open();
                        }
                        MyReader1 = MyCommand1.ExecuteReader();
                        MyReader1.Close();
                    }
                    else if (comboBox2.SelectedItem.ToString() == "Staff")
                    {
                        string Query2 = "insert into `database`.`staff_info`(`contact_ID`,`Employee_ID`) values('" + ContactID + "','" + this.textBox8.Text + "');";
                        MySqlCommand MyCommand2 = new MySqlCommand(Query2, MyConn);
                        MySqlDataReader MyReader2;
                        if (MyConn != null && MyConn.State == ConnectionState.Closed)
                        {
                            MyConn.Open();
                        }
                        MyReader2 = MyCommand2.ExecuteReader();
                        MyReader2.Close();
                    }
                    MessageBox.Show("Saved successfully");
                    this.Hide();

                }
                else
                {
                    string MyConnection = "datasource=localhost;port=3306;username=root;password=root";

                    string Query = "Update `database`.`contact_info` SET `FirstName`='" + textBox1.Text + "', `LastName`='" + textBox2.Text + "', `Address1`= '" + textBox3.Text + "', `Address2` = '" + textBox4.Text + "', `City`='" + textBox5.Text + "', `State`='" + this.comboBox1.Text + "', `Zip`= '" + textBox6.Text + "', `PhoneNumber`=" + textBox7.Text + " where `Contact_ID`=" + Contact_ID + "";

                    MySqlConnection MyConn = new MySqlConnection(MyConnection);

                    MySqlCommand MyCommand = new MySqlCommand(Query, MyConn);
                    MySqlDataReader MyReader;
                    MyConn.Open();
                    MyReader = MyCommand.ExecuteReader();
                    MyReader.Close();
                    if (comboBox2.SelectedItem.ToString() == "Provider")
                    {
                        string Query1 = "Update `database`.`provider_info` SET `contact_ID`=" + Contact_ID + ",`NPI_Number`='" + this.textBox8.Text + "' , `DEA_Number`='" + this.textBox9.Text + "' where contact_ID=" + Contact_ID + " ;";
                        MySqlCommand MyCommand1 = new MySqlCommand(Query1, MyConn);
                        MySqlDataReader MyReader1;
                        if (MyConn != null && MyConn.State == ConnectionState.Closed)
                        {
                            MyConn.Open();
                        }
                        MyReader1 = MyCommand1.ExecuteReader();
                        MyReader1.Close();
                    }
                    else if (comboBox2.SelectedItem.ToString() == "Staff")
                    {
                        string Query2 = "Update `database`.`staff_info`SET `contact_ID`=" + Contact_ID + ",`Employee_ID`='" + this.textBox8.Text + "' where contact_ID=" + Contact_ID + ";";
                        MySqlCommand MyCommand2 = new MySqlCommand(Query2, MyConn);
                        MySqlDataReader MyReader2;
                        if (MyConn != null && MyConn.State == ConnectionState.Closed)
                        {
                            MyConn.Open();
                        }
                        MyReader2 = MyCommand2.ExecuteReader();
                        MyReader2.Close();
                    }
                    MessageBox.Show("Saved successfully");
                    this.Hide();
                }
                MainForm main = new MainForm("");
                main.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }