コード例 #1
0
        private string loginLocal()
        {
            cKoneksi koneksi = new cKoneksi();
            string   role    = string.Empty;

            var           con = new SQLiteConnection(koneksi.LokasiSqlite());
            cQuery        qr  = new cQuery();
            SQLiteCommand cmd = new SQLiteCommand(qr.qSelectUserLoginSqlite(), con);

            cmd.Parameters.AddWithValue("@username", this.textBox_username.Text);
            cmd.Parameters.AddWithValue("@password", this.textBox_pass.Text);

            try
            {
                con.Open();
                SQLiteDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    if (dr.HasRows == true)
                    {
                        role = dr.GetString(1);
                        cVarGlobal.isAplication = dr.GetString(2);//set hak akses aplikasi
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                role = string.Empty;
            }
            finally
            {
                con.Close();
                con.Dispose();
            }
            return(role);
        }