protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            this.SetContentView(IslamicHadithAND.Resource.Layout.Book);

            //ActionBar
            ActionBar.NavigationMode = ActionBarNavigationMode.Standard;

            progress = ProgressDialog.Show(this, "انتظر من فضلك", "يتم تحميل الأحاديث ...", true);

            new Thread(new ThreadStart(() =>
            {
                Thread.Sleep(1);
                this.RunOnUiThread(() =>
                {
                    try
                    {
                        string content;
                        using (StreamReader streamReader = new StreamReader(Assets.Open("hadeeth.sqlite")))
                        {
                            content = streamReader.ReadToEnd();
                        }
                        string dbName = "hadeeth.sqlite";
                        string dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), dbName);
                        if (!File.Exists(dbPath))
                        {
                            using (Stream source = new StreamReader(Assets.Open("hadeeth.sqlite")).BaseStream)
                            {
                                using (var destination = System.IO.File.Create(dbPath))
                                {
                                    source.CopyTo(destination);
                                }
                            }
                        }
                        DataTable dataTableBook = new DataTable();

                        var connectionString = string.Format("Data Source={0};Version=3;", dbPath);
                        using (var conn = new SqliteConnection((connectionString)))
                        {
                            using (var command = conn.CreateCommand())
                            {
                                conn.Open();
                                command.CommandText = @"SELECT hadeeth.*" +
                              "FROM Books INNER JOIN hadeeth ON Books.ID = hadeeth.BID" +
                              " where hadeeth.hadeeth like '%<%' and " +
                              "books.title like '%سنن الدارمي‏%'";

                                command.CommandType = CommandType.Text;
                                SqliteDataAdapter dataAdapter = new SqliteDataAdapter();
                                dataAdapter.SelectCommand = command;
                                dataAdapter.Fill(dataTableBook);
                            }
                        }

                        var data = new List<string>();
                        for (int i = 0; i < dataTableBook.Rows.Count; i++)
                        {
                            data.Add(unBold((dataTableBook.Rows[i]["hadeeth"].ToString())));
                            if (dataTableBook.Rows.Count == 0)
                            {
                                new AlertDialog.Builder(this)
                                  .SetTitle("خطأ")
                                  .SetMessage("لا يوجد نتائج")
                                  .SetPositiveButton("عودة", (senderaa, args) =>
                                  {
                                      // Back
                                  })
                                  .Show();
                            }
                        }

                        var listView = FindViewById<ListView>(IslamicHadithAND.Resource.Id.listBook);
                        listView.Adapter = new ArrayAdapter(this, Resource.Layout.ListViewContents, data);

                        listView.ItemClick += (sender, e) =>
                        {
                            var position = e.Position;
                            var HadithBrowser = new Intent(this, typeof(HadithBrowser));
                            HadithBrowser.PutExtra("Hadith", listView.GetItemAtPosition(position).ToString());
                            if (!listView.GetItemAtPosition(position + 1).Equals(null))
                            {
                                position++;
                                HadithBrowser.PutExtra("HadithNext1", listView.GetItemAtPosition(position).ToString());
                            }
                            if (!listView.GetItemAtPosition(position - 1).Equals(null))
                            {
                                position--;
                                HadithBrowser.PutExtra("HadithPrevious1", listView.GetItemAtPosition(position).ToString());
                            }
                            StartActivity(HadithBrowser);
                        };
                    }
                    catch (Exception ex)
                    {
                        new AlertDialog.Builder(this)
                                  .SetPositiveButton("عودة", (sendera, args) =>
                                  {
                                      // Back
                                  })
                                  .SetTitle("خطأ")
                                  .SetMessage("خطأ في قاعدة البيانات ( " + ex.ToString() + " )")
                                  .Show();
                    }

                    progress.Dismiss();
                });
            })).Start();
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.SearchByAuthor);

            //ActionBar
            ActionBar.NavigationMode = ActionBarNavigationMode.Standard;

            var btnSearchByAuthorData = FindViewById<Button>(Resource.Id.btnSearchByAuthorData);
            var txtKeywordAuthor = FindViewById<EditText>(Resource.Id.txtKeywordAuthor);
            var spinnerAuthorName = FindViewById<Spinner>(Resource.Id.txtAuthorNameData);

            spinnerAuthorName.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinnerAuthorName_ItemSelected);
            var adapter = ArrayAdapter.CreateFromResource(
                    this, Resource.Array.AuthorsNames, Android.Resource.Layout.SimpleSpinnerItem);

            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinnerAuthorName.Adapter = adapter;

            btnSearchByAuthorData.Click += delegate
            {
                progress = ProgressDialog.Show(this, "انتظر من فضلك", "يتم تحميل الأحاديث ...", true);

                new Thread(new ThreadStart(() =>
                {
                    Thread.Sleep(1);
                    this.RunOnUiThread(() =>
                    {
                        try
                        {
                            string content;
                            using (StreamReader streamReader = new StreamReader(Assets.Open("hadeeth.sqlite")))
                            {
                                content = streamReader.ReadToEnd();
                            }
                            string dbName = "hadeeth.sqlite";
                            string dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), dbName);
                            if (!File.Exists(dbPath))
                            {
                                using (Stream source = new StreamReader(Assets.Open("hadeeth.sqlite")).BaseStream)
                                {
                                    using (var destination = System.IO.File.Create(dbPath))
                                    {
                                        source.CopyTo(destination);
                                    }
                                }
                            }
                            DataTable dataTable = new DataTable();

                            var connectionString = string.Format("Data Source={0};Version=3;", dbPath);
                            using (var sqliteConnection = new SqliteConnection((connectionString)))
                            {
                                using (var command = sqliteConnection.CreateCommand())
                                {
                                    sqliteConnection.Open();
                                    command.CommandText = @"SELECT hadeeth.* " +
                                    "FROM (authors INNER JOIN books ON authors.ID = Books.Author) " +
                                    "INNER JOIN hadeeth ON Books.ID = hadeeth.BID " +
                                    "WHERE (((authors.name) Like '%" + txtAuthorNameData.ToString() + "%') " +
                                    "and ((hadeeth.hadeeth_norm) Like '%" + txtKeywordAuthor.Text + "%'))";

                                    command.CommandType = CommandType.Text;
                                    SqliteDataAdapter dataAdapter = new SqliteDataAdapter();
                                    dataAdapter.SelectCommand = command;
                                    dataAdapter.Fill(dataTable);
                                }
                            }

                            var data = new List<string>();
                            for (int i = 0; i < dataTable.Rows.Count; i++)
                            {
                                data.Add(unBold(dataTable.Rows[i]["hadeeth"].ToString()));
                            }

                            if (dataTable.Rows.Count == 0)
                            {
                                new AlertDialog.Builder(this)
                                .SetTitle("خطأ")
                                .SetMessage("لا يوجد نتائج")
                                .SetPositiveButton("عودة", (senderaa, args) =>
                                 {
                                     // Back
                                 })
                                .Show();
                            }

                            var listView = FindViewById<ListView>(Resource.Id.listHadithByAuthor);
                            listView.Adapter = new ArrayAdapter(this, Resource.Layout.ListViewContents, data);

                            listView.ItemClick += (sender, e) =>
                            {
                                var position = e.Position;
                                var HadithBrowser = new Intent(this, typeof(HadithBrowser));
                                HadithBrowser.PutExtra("Hadith", listView.GetItemAtPosition(position).ToString());
                                if (!listView.GetItemAtPosition(position + 1).Equals(null))
                                {
                                    position++;
                                    HadithBrowser.PutExtra("HadithNext1", listView.GetItemAtPosition(position).ToString());
                                }
                                if (!listView.GetItemAtPosition(position - 1).Equals(null))
                                {
                                    position--;
                                    HadithBrowser.PutExtra("HadithPrevious1", listView.GetItemAtPosition(position).ToString());
                                }
                                StartActivity(HadithBrowser);
                            };
                        }
                        catch (Exception ex)
                        {
                            new AlertDialog.Builder(this)
                                        .SetPositiveButton("عودة", (sendera, args) =>
                                        {
                                            // Back
                                        })
                                        .SetTitle("خطأ")
                                        .SetMessage("خطأ في قاعدة البيانات ( " + ex.ToString() + " )")
                                        .Show();
                        }
                        progress.Dismiss();
                    });
                })).Start();
            };
        }
Exemple #3
0
        private void tSBExportProfile_Click(object sender, EventArgs e)
        {
            if (lBProfiles.SelectedIndex < 0)
            {
                return;
            }

            using (Stream profile = new StreamReader(Global.appdatapath + "\\Profiles\\" + lBProfiles.SelectedItem + ".xml").BaseStream)
            {
                if (saveProfiles.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                using (Stream stream = saveProfiles.OpenFile())
                {
                    profile.CopyTo(stream);
                    profile.Close();
                }
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.HadithTitle);

            //ActionBar
            ActionBar.NavigationMode = ActionBarNavigationMode.Standard;

            progress = ProgressDialog.Show(this, "انتظر من فضلك", "يتم تحميل العناوين ...", true);

            new Thread(new ThreadStart(() =>
            {
                Thread.Sleep(1);
                this.RunOnUiThread(() =>
                {
                    try
                    {
                        string content;
                        using (StreamReader streamReader = new StreamReader(Assets.Open("hadeeth.sqlite")))
                        {
                            content = streamReader.ReadToEnd();
                        }
                        string dbName = "hadeeth.sqlite";
                        string dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), dbName);
                        if (!File.Exists(dbPath))
                        {
                            using (Stream source = new StreamReader(Assets.Open("hadeeth.sqlite")).BaseStream)
                            {
                                using (var destination = System.IO.File.Create(dbPath))
                                {
                                    source.CopyTo(destination);
                                }
                            }
                        }
                        DataTable dataTableSubject = new DataTable();
                        DataTable dataTableHadith = new DataTable();

                        var connectionString = string.Format("Data Source={0};Version=3;", dbPath);
                        using (var sqliteConnection = new SqliteConnection((connectionString)))
                        {
                            using (var command = sqliteConnection.CreateCommand())
                            {
                                sqliteConnection.Open();
                                command.CommandText = @"select distinct hadeeth.title from hadeeth";

                                command.CommandType = CommandType.Text;
                                SqliteDataAdapter da = new SqliteDataAdapter();
                                da.SelectCommand = command;
                                da.Fill(dataTableSubject);
                            }
                        }

                        var data = new List<string>();
                        for (int i = 0; i < dataTableSubject.Rows.Count; i++)
                        {
                            data.Add(unBold(dataTableSubject.Rows[i]["title"].ToString()));
                        }

                        if (dataTableSubject.Rows.Count == 0)
                        {
                            new AlertDialog.Builder(this)
                            .SetTitle("خطأ")
                            .SetMessage("لا يوجد نتائج")
                            .SetPositiveButton("عودة", (senderaa, args) =>
                            {
                                // Back
                            })
                            .Show();
                        }

                        var listView = FindViewById<ListView>(Resource.Id.listHadithTitle);
                        listView.Adapter = new ArrayAdapter(this, Resource.Layout.ListViewContents, data);

                        listView.ItemClick += (sender, e) =>
                        {
                            progress = ProgressDialog.Show(this, "انتظر من فضلك", "يتم تحميل الموضوعات ...", true);

                            new Thread(new ThreadStart(() =>
                            {
                                Thread.Sleep(1);
                                this.RunOnUiThread(() =>
                                {
                                    var connectionString2 = string.Format("Data Source={0};Version=3;", dbPath);
                                    using (var conn2 = new SqliteConnection((connectionString2)))
                                    {
                                        using (var command = conn2.CreateCommand())
                                        {
                                            conn2.Open();
                                            command.CommandText = @"SELECT hadeeth.* " +
                                            "FROM hadeeth WHERE " +
                                            "(((hadeeth.title) Like '%" + listView.GetItemAtPosition(e.Position).ToString() + "%'))";

                                            command.CommandType = CommandType.Text;
                                            SqliteDataAdapter da2 = new SqliteDataAdapter();
                                            da2.SelectCommand = command;
                                            da2.Fill(dataTableHadith);
                                        }
                                    }

                                    var data2 = new List<string>();
                                    for (int i = 0; i < dataTableHadith.Rows.Count; i++)
                                    {
                                        data2.Add(unBold(dataTableHadith.Rows[i]["hadeeth"].ToString()));
                                    }

                                    if (dataTableHadith.Rows.Count == 0)
                                    {
                                        new AlertDialog.Builder(this)
                                    .SetTitle("خطأ")
                                    .SetMessage("لا يوجد نتائج")
                                    .SetPositiveButton("عودة", (senderaa, args) =>
                                    {
                                        // Back
                                    })
                                    .Show();
                                    }

                                    var listView2 = FindViewById<ListView>(Resource.Id.listHadithTitle);
                                    listView2.Adapter = new ArrayAdapter(this, Resource.Layout.ListViewContents, data2);

                                    listView2.ItemClick += (senderaaa, ee) =>
                                    {
                                        var position = ee.Position;
                                        var HadithBrowser = new Intent(this, typeof(HadithBrowser));
                                        HadithBrowser.PutExtra("Hadith", listView2.GetItemAtPosition(position).ToString());
                                        if (!listView2.GetItemAtPosition(position + 1).Equals(null))
                                        {
                                            position++;
                                            HadithBrowser.PutExtra("HadithNext1", listView2.GetItemAtPosition(position).ToString());
                                        }
                                        if (!listView2.GetItemAtPosition(position - 1).Equals(null))
                                        {
                                            position--;
                                            HadithBrowser.PutExtra("HadithPrevious1", listView2.GetItemAtPosition(position).ToString());
                                        }
                                        StartActivity(HadithBrowser);
                                    };

                                    progress.Dismiss();
                                });
                            })).Start();
                        };
                    }
                    catch (Exception ex)
                    {
                        new AlertDialog.Builder(this)
                                        .SetPositiveButton("عودة", (sendera, args) =>
                                        {
                                            // Back
                                        })
                                        .SetTitle("خطأ")
                                        .SetMessage("خطأ في قاعدة البيانات ( " + ex.ToString() + " )")
                                        .Show();
                    }
                    progress.Dismiss();
                });
            })).Start();
        }