Exemplo n.º 1
0
        private void btLG_Click(object sender, EventArgs e)
        {
            string strKoneksi = "Data Source=localhost;Initial Catalog=akreditasi;User "
                                + "ID=sa;Password=ayi240799";
            SqlConnection koneksi = new SqlConnection();

            koneksi.ConnectionString = strKoneksi;
            koneksi.Open();

            SqlDataAdapter sda = new SqlDataAdapter("select count(*) from user_data where userid = '" + boxID.Text + "' and password ='******'", koneksi);
            DataTable      dt  = new DataTable();

            sda.Fill(dt);
            if (dt.Rows[0][0].ToString() == "1")
            {
                this.Hide();
                nama = boxID.Text;
                userDassboard dsb = new userDassboard();
                dsb.Show();
            }
            else
            {
                MessageBox.Show("Please enter corect username and password", "alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private void btSG_Click(object sender, EventArgs e)
        {
            if (boxPass.Text == boxCnfirm.Text)
            {
                string str        = "";
                string strKoneksi = "Data Source=localhost;Initial Catalog=akreditasi;User "
                                    + "ID=sa;Password=ayi240799";
                SqlConnection koneksi = new SqlConnection();
                koneksi.ConnectionString = strKoneksi;
                koneksi.Open();

                string user = boxID.Text.ToString().Trim();
                string pass = boxPass.Text.ToString().Trim();

                str = "insert into user_data values (@User, @Pass)";
                SqlCommand cmd = new SqlCommand(str, koneksi);
                cmd.CommandType = CommandType.Text;

                cmd.Parameters.Add(new SqlParameter("User", user));
                cmd.Parameters.Add(new SqlParameter("Pass", pass));
                cmd.ExecuteNonQuery();

                btSG.Enabled = true;

                userDassboard dsb = new userDassboard();
                dsb.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Please enter corect password", "alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }