示例#1
0
        private void SaveSettings(MyClubs mk)
        {
            string vrednost = JsonConvert.SerializeObject(mk);

            Properties.Settings.Default.MyClubs = vrednost;
            Properties.Settings.Default.Save(); // Saves settings in application configuration file
            Properties.Settings.Default.Reload();
        }
示例#2
0
        private void btn_Add_Click(object sender, EventArgs e)
        {
            string   url = ApiEndPoint + "club/" + tb_ClubName.Text;
            ClubInfo klub;

            try
            {
                klub = API.GetData.getApiData <ClubInfo>(url);

                if (klub == null || klub.Id == null)
                {
                    throw new NotImplementedException();
                }
            }
            catch
            {
                MessageBox.Show("Provjerite naziv kluba, došlo je do greške.");

                return;
            }


            MyClubs a = getMyClubs();

            if (a.Clubs == null)
            {
                List <ClubInfo> t = new List <ClubInfo>();
                t.Add(klub);
                a.Clubs = t;
            }
            else
            {
                var urlClubExists = a.Clubs.Any(x => x.Id == klub.Id);

                if (urlClubExists)
                {
                    MessageBox.Show("Već ste dodali taj klub!");
                    return;
                }
                else
                {
                    a.Clubs.Add(klub);
                }
            }

            SaveSettings(a);

            ShowSettingsInGrid();

            tb_ClubName.Text = "";
        }
示例#3
0
        private void ShowSettingsInGrid()
        {
            try
            {
                MyClubs mk          = getMyClubs();
                var     bindingList = new BindingList <ClubInfo>(mk.Clubs);
                var     source      = new BindingSource(bindingList, null);
                dgv_Clubs.DataSource = source;
                dgv_Clubs.Refresh();

                for (int i = 0; i < dgv_Clubs.ColumnCount; i++)
                {
                    dgv_Clubs.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                }

                ShowClubInfo();
            }
            catch
            {
                MessageBox.Show("Nije nađen ni jedan klub!");
            }
        }
示例#4
0
        private void btn_DeleteMyClub_Click(object sender, EventArgs e)
        {
            //Properties.Settings.Default.Reset();
            if (MessageBox.Show("Da li ste sigurni u ovo?", "Brisanje kluba", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (dgv_Clubs.SelectedCells.Count > 0)
                {
                    int             selectedrowindex = dgv_Clubs.SelectedCells[0].RowIndex;
                    DataGridViewRow selectedRow      = dgv_Clubs.Rows[selectedrowindex];
                    Uri             clubId;

                    Uri.TryCreate(selectedRow.Cells[0].Value.ToString(), UriKind.Absolute, out clubId);

                    MyClubs mk = getMyClubs();
                    mk.Clubs.RemoveAll(x => x.Id == clubId);

                    Properties.Settings.Default.Reset();

                    SaveSettings(mk);

                    ShowSettingsInGrid();
                }
            }
        }