Exemplo n.º 1
0
        public bool insertClient(String fname, String lname, String phoneno1, String email, String dob, string sex, String address)
        {
            MySqlCommand command     = new MySqlCommand();
            String       insertQuery = "INSERT INTO `manageclients`(`fnames`, `lnames`, `phonenos`, `emails`, `dobs`, `sexs`, `addresses`) VALUES (@fns,@lns,@phns, @emls, @dos,@sxs, @adds)";

            command.CommandText = insertQuery;
            command.Connection  = conn.GetConnection();

            //@fns,@lns,@phns, @emls, @dos,@sxs, @adds
            command.Parameters.Add("@fns", MySqlDbType.VarChar).Value  = fname;
            command.Parameters.Add("@lns", MySqlDbType.VarChar).Value  = lname;
            command.Parameters.Add("@phns", MySqlDbType.VarChar).Value = phoneno1;
            command.Parameters.Add("@emls", MySqlDbType.VarChar).Value = email;
            command.Parameters.Add("@dos", MySqlDbType.VarChar).Value  = dob;
            command.Parameters.Add("@sxs", MySqlDbType.VarChar).Value  = sex;
            command.Parameters.Add("@adds", MySqlDbType.VarChar).Value = address;

            conn.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                conn.closeConnection();
                return(true);
            }

            else
            {
                conn.closeConnection();
                return(false);
            }
        }
Exemplo n.º 2
0
        private void Login_Click(object sender, EventArgs e)
        {
            SQLConnect       conn    = new SQLConnect();
            DataTable        table   = new DataTable();
            MySqlDataAdapter adapter = new MySqlDataAdapter();
            MySqlCommand     command = new MySqlCommand();
            String           query   = " SELECT * FROM `appusers` WHERE `username`= @admin AND `password`= @12345;";

            command.CommandText = query;
            command.Connection  = conn.GetConnection();

            command.Parameters.Add("@admin", MySqlDbType.VarChar).Value = username.Text;
            command.Parameters.Add("@12345", MySqlDbType.VarChar).Value = Password.Text;



            adapter.SelectCommand = command;
            adapter.Fill(table);

            if (table.Rows.Count > 0)

            {
                this.Hide();
                Main mform = new Main();
                mform.Show();
            }

            else
            {
                if (username.Text.Trim().Equals("") && Password.Text.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Username and Password to Login", "Empty Username and Password fields", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                else if (username.Text.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Username to Login", "Empty Username field", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                else if (Password.Text.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Password to Login", "Empty Password field", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }



                else
                {
                    MessageBox.Show("Username or Password is not correct. Please try again", "Incorrect username or password", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        public void FillCombo()
        {
            SQLConnect       conn    = new SQLConnect();
            DataTable        dt      = new DataTable();
            MySqlDataAdapter adapter = new MySqlDataAdapter();
            MySqlCommand     command = new MySqlCommand();
            String           query   = " SELECT gender from sex";

            command.CommandText = query;
            command.Connection  = conn.GetConnection();

            adapter.SelectCommand = command;
            adapter.Fill(dt);
            foreach (DataRow dr in dt.Rows)

            {
                sexcombobox.Items.Add(dr["gender"].ToString());
            }
        }