Ejemplo n.º 1
0
        private async void TapGestureRecognizer_Tapped(object sender, EventArgs e)
        {
            Pothi pothi = (e as TappedEventArgs).Parameter as Pothi;
            await Navigation.PushAsync(new PothiShabadList(pothi));

            lstPothi.SelectedItem = null;
        }
Ejemplo n.º 2
0
        private async void DeletePothi_Clicked(object sender, EventArgs e)
        {
            Pothi pothi  = (sender as MenuItem).CommandParameter as Pothi;
            bool  answer = await DisplayAlert("Delete", $"Are you sure you want to delete {pothi.Name} ?", "Yes", "No");

            if (answer)
            {
                try
                {
                    int deletePothiShabads = await _con.ExecuteAsync(Queries.DeletePothiShabad(pothi.PothiId.Value));

                    int deleted = await _con.DeleteAsync <Pothi>(pothi.PothiId);

                    if (deleted > 0 || pothi.PothiId == null)
                    {
                        PothiObs.Remove(pothi);
                        Util.ShowRoast("Pothi deleted successfully", true);
                        await Queries.ExportPothis(PothiObs.ToList(), true);
                    }
                }
                catch (Exception ex)
                {
                    Util.ShowRoast("Failed to Delete pothi");
                }
            }
        }
Ejemplo n.º 3
0
        private async void NewPothi_Clicked(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(entPothiName.Text))
            {
                Pothi pothi = new Pothi();
                pothi.Name      = entPothiName.Text;
                pothi.CreatedOn = DateTime.Now;
                var cnt = await _con.InsertAsync(pothi);

                if (cnt > 0)
                {
                    int lastId = await Queries.GetLastId();

                    if (lastId > 0)
                    {
                        pothi.PothiId = lastId;
                        PothiOrb.Add(pothi);
                        ddlPothi.SelectedItem = pothi;
                        if (ddlPothi.Items.Count > 0)
                        {
                            Save_Clicked(null, null);
                        }
                    }
                }

                await Navigation.PopPopupAsync();
            }
        }
Ejemplo n.º 4
0
        private async void lstPothi_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            if (e.SelectedItem == null)
            {
                return;
            }
            Pothi pothi = e.SelectedItem as Pothi;
            await Navigation.PushAsync(new PothiShabadList(pothi));

            lstPothi.SelectedItem = null;
        }
Ejemplo n.º 5
0
 public PothiShabadList(Pothi pothi)
 {
     BindingContext = new Theme();
     InitializeComponent();
     Title  = pothi.Name;
     _con   = DependencyService.Get <ISqliteDb>().GetSQLiteConnection();
     _pothi = pothi;
     EditToolbar.TranslateTo(0, 50, 10, Easing.SinOut);
     EditToolbar.IsVisible = false;
     LoadPothiShabads();
 }
Ejemplo n.º 6
0
        private async void RenamePothi(Pothi pothi)
        {
            string newPothiName = await DisplayPromptAsync("Rename Pothi", "Enter new pothi name", "Save", "Cancel", initialValue : pothi.Name);

            if (!string.IsNullOrWhiteSpace(newPothiName) && newPothiName != pothi.Name)
            {
                pothi.Name = newPothiName;
                int updated = await _con.UpdateAsync(pothi);

                if (updated > 0)
                {
                    PothiObs[PothiObs.IndexOf(pothi)].Name = newPothiName;
                }
                await Queries.ExportPothis(PothiObs.ToList(), true);
            }
        }
Ejemplo n.º 7
0
        public async static Task <string> GetPothiJson(Pothi pothi)
        {
            if (pothi == null || pothi.PothiId == null || pothi.PothiId < 1)
            {
                return(string.Empty);
            }
            else
            {
                SQLiteAsyncConnection _con = DependencyService.Get <ISqliteDb>().GetSQLiteConnection();
                List <PothiShabad>    ps   = await _con.QueryAsync <PothiShabad>($"Select * from PothiShabad where PothiId = {pothi.PothiId}");

                PothiShabadExt ext = new PothiShabadExt()
                {
                    pothi = pothi, shabadList = ps
                };
                string json = JsonConvert.SerializeObject(ext);
                return(json);
            }
        }
Ejemplo n.º 8
0
        private async void AddPothi_Clicked(object sender, EventArgs e)
        {
            string pothiName = await DisplayPromptAsync(pothiText.NewPothiNameSubject, pothiText.NewPothiNameMsg);

            if (!string.IsNullOrWhiteSpace(pothiName))
            {
                Pothi pothi = new Pothi();
                pothi.Name      = pothiName;
                pothi.CreatedOn = DateTime.Now;
                var cnt = await _con.InsertAsync(pothi);

                if (cnt > 0)
                {
                    PothiObs.Add(pothi);
                }
                Util.ShowRoast("Pothi added successfully", true);
                await LoadPothis();

                await Queries.ExportPothis(PothiObs.ToList(), true);
            }
        }
Ejemplo n.º 9
0
        internal async static Task <bool> SavePothFromPothiShabadExt(PothiShabadExt cur)
        {
            _con = DependencyService.Get <ISqliteDb>().GetSQLiteConnection();
            Pothi pothi = new Pothi();

            pothi.Name      = cur.pothi.Name;
            pothi.CreatedOn = DateTime.Now;
            int cnt = await _con.InsertAsync(pothi);

            if (cnt > 0)
            {
                int pothiId = await Queries.GetLastId();

                foreach (PothiShabad shabad in cur.shabadList)
                {
                    PothiShabad pothiShabad = shabad;
                    pothiShabad.PothiId = pothiId;
                    await _con.InsertAsync(pothiShabad);
                }
            }
            return(true);
        }
Ejemplo n.º 10
0
        private async void Save_Clicked(object sender, EventArgs e)
        {
            Pothi pothi = ddlPothi.SelectedItem as Pothi;

            SortOrder = await Queries.GetMaxSortId(pothi.PothiId.Value) ?? 0;

            int?pothiId = pothi.PothiId;

            if (pothiId.HasValue)
            {
                if (RequestType == RequestSource.Single)
                {
                    Verse       verse       = pckLine.SelectedItem as Verse;
                    PothiShabad pothiShabad = new PothiShabad();
                    pothiShabad.PothiId   = pothiId.Value;
                    pothiShabad.ShabadId  = ShabadId;
                    pothiShabad.VerseId   = verse.ID;
                    pothiShabad.SortOrder = SortOrder + 1;
                    PothiShabad.Add(pothiShabad);
                }
                else
                {
                    PothiShabad.ToList().ForEach(a => a.PothiId = pothiId.Value);
                    int sortOrder = SortOrder.Value + 1;
                    foreach (PothiShabad pothiShabads in PothiShabad)
                    {
                        pothiShabads.PothiId   = pothiId.Value;
                        pothiShabads.SortOrder = sortOrder;
                        sortOrder += 1;
                    }
                }

                SavePothiShabad(PothiShabad);
                await Navigation.PopPopupAsync();
            }
        }
Ejemplo n.º 11
0
        private void Rename_Clicked(object sender, EventArgs e)
        {
            Pothi pothi = (sender as MenuItem).CommandParameter as Pothi;

            RenamePothi(pothi);
        }