Exemple #1
0
        protected void SaveButtonHandler(object sender, EventArgs e)
        {
            string strFirstName;
            string strLastName;
            string strNickName;
            string strDenNumber;
            string strMom;
            string strDad;
            string strEmail;
            string strHome;
            string strMobile;

            try
            {
                if ((txtFirstName.Text == null) || (txtFirstName.Text.ToString().Trim() == "")) {
                    ShowError("First Name");
                    return;
                }else{
                    strFirstName = txtFirstName.Text.Trim ();
                }
                if ((txtLastName.Text == null) || (txtLastName.Text.ToString().Trim() == "")) {
                    ShowError("Last Name");
                    return;
                }else{
                    strLastName = txtLastName.Text.Trim();
                }
                if ((txtNickName.Text == null) || (txtNickName.Text.ToString().Trim() == "")) {
                    strNickName = "";
                }else{
                    strNickName = txtNickName.Text.ToString().Trim();
                }
                if ((txtDen.Text == null) || (txtDen.Text.ToString().Trim() == "")) {
                    ShowError("Den");
                    return;
                }else{
                    switch (txtDen.Text)
                    {
                    case "Tiger":
                        strDenNumber = "0";
                        break;
                    case "Wolf":
                        strDenNumber = "1";
                        break;
                    case "Bear":
                        strDenNumber = "2";
                        break;
                    case "Weblo":
                        strDenNumber = "3";
                        break;
                    default:
                        strDenNumber = "";
                        break;
                    }
                }
                if ((txtMomName.Text == null) || (txtMomName.Text.ToString().Trim() == "")) {
                    strMom = "";
                }else{
                    strMom = txtMomName.Text.ToString().Trim();
                }
                if ((txtDadName.Text == null) || (txtDadName.Text.ToString().Trim() == "")) {
                    strDad = "";
                }else{
                    strDad = txtDadName.Text.ToString().Trim();
                }
                if ((txtEmail.Text == null) || (txtEmail.Text.ToString().Trim() == "")) {
                    strEmail = "";
                }else{
                    strEmail = txtEmail.Text.ToString().Trim();
                }
                if ((txtHomePhone.Text == null) || (txtHomePhone.Text.ToString().Trim() == "")) {
                    strHome = "";
                }else{
                    strHome = txtHomePhone.Text.ToString().Trim();
                }
                if ((txtMobilePhone.Text == null) || (txtMobilePhone.Text.ToString().Trim() == "")) {
                    strMobile = "";
                }else{
                    strMobile = txtMobilePhone.Text.ToString().Trim();
                }

                folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
                //conn = new SQLiteAsyncConnection (System.IO.Path.Combine (folder, "CubScouts.db"));
                conn2 = new SQLiteConnection(System.IO.Path.Combine (folder, "CubScouts.db"));
                CubScout newScout = new CubScout {
                    FirstName = strFirstName,
                    LastName = strLastName,
                    Nickname = strNickName,
                    ScoutType = strDenNumber,
                    MomsName = strMom,
                    DadsName = strDad,
                    EmailAddress = strEmail,
                    HomePhone = strHome,
                    CellPhone = strMobile
                };
            //				conn.InsertAsync (newScout).ContinueWith (t => {
            //					Console.WriteLine ("New scout ID: {0}", newScout.Id);
            //				});
                if (ScoutAction != "EditScout")
                {
                    conn2.Insert (newScout);
                    Console.WriteLine ("New scout ID: {0}", newScout.Id);
                }
                else
                {
                    newScout.Id = Convert.ToInt32(ScoutID);
                    conn2.Update(newScout);
                    Console.WriteLine ("Updated scout ID: {0}", newScout.Id);
                }
                this.NavigationController.PopViewControllerAnimated(true);
            }
            catch (Exception ex)
            {
                using (UIAlertView myAlert = new UIAlertView())
                {
                    myAlert.Message = ex.Message;
                    myAlert.Title = "Error";
                    myAlert.AddButton("OK");
                    myAlert.Show();
                }
            }
            finally
            {
            }
        }
Exemple #2
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear (animated);
            try
            {
                this.NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem(UIImage.FromBundle("icons/399-list1"), UIBarButtonItemStyle.Plain, FlyoutNavigationHandler), true);

                folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
                conn = new SQLiteAsyncConnection (System.IO.Path.Combine (folder, "CubScouts.db"));
                if (!myDB.TableExists("CubScout")) {
                    conn.CreateTableAsync<CubScout>().ContinueWith (t => {
                        Console.WriteLine ("Table created!");
                    });
                }

                //Setup Map Types Radio Group
                RadioGroup myScoutTypes = new RadioGroup("scoutTypes",0);
                RadioElement rTiger = new RadioElement("Tiger","scoutTypes");
                RadioElement rWolf = new RadioElement("Wolf","scoutTypes");
                RadioElement rBear = new RadioElement("Bear","scoutTypes");
                RadioElement rWeblo = new RadioElement("Weblo","scoutTypes");

                Section myScoutTypesSection = new Section();
                myScoutTypesSection.Add(rTiger);
                myScoutTypesSection.Add(rWolf);
                myScoutTypesSection.Add(rBear);
                myScoutTypesSection.Add(rWeblo);

                secCurrentScouts = new Section ("Pack 957 Tigers");
                //MultilineElement scoutElement;

                //Call the reload method to re-populate the list.
                ReloadCubScouts(secCurrentScouts);

                EntryElement fn;
                EntryElement ln;
                EntryElement nn;
                RootElement st;
                Root = new RootElement ("Tigers") {
                    new Section ("Add") {
                        new RootElement ("Add Scout") {
                            new Section ("Your info") {
                                (fn = new EntryElement("First Name","First Name","")),
                                (ln = new EntryElement("Last Name","Last Name","")),
                                (nn = new EntryElement("Nickname","Nickname","")),
                                (st = new RootElement("Scout Types", myScoutTypes) {
                                    myScoutTypesSection
                                }),
                                new StringElement("Save",delegate {
                                    CubScout newScout = new CubScout {FirstName = fn.Value.Trim(), LastName = ln.Value.Trim(), Nickname = nn.Value.Trim (), ScoutType = st.RadioSelected.ToString()};
                                    conn.InsertAsync (newScout).ContinueWith (t => {
                                        Console.WriteLine ("New scout ID: {0}", newScout.Id);
                                    });
                                    fn.Value = "";
                                    ln.Value = "";
                                    nn.Value = "";
                                    st.RadioSelected = 0;
                                    this.NavigationController.PopViewControllerAnimated(true);
                                }),
                            },
                        }
                    },
                    secCurrentScouts,
                };
            }
            catch (Exception ex)
            {
                using (UIAlertView myAlert = new UIAlertView())
                {
                    myAlert.Message = ex.Message;
                    myAlert.Title = "Error!";
                    myAlert.AddButton("OK");
                    myAlert.Show();
                }
            }
            finally
            {

            }
        }
Exemple #3
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear (animated);
            folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
            conn = new SQLiteAsyncConnection (System.IO.Path.Combine (folder, "CubScouts.db"));

            //Setup Map Types Radio Group
            RadioGroup myScoutTypes = new RadioGroup("scoutTypes",0);
            RadioElement rTiger = new RadioElement("Tiger","scoutTypes");
            RadioElement rWolf = new RadioElement("Wolf","scoutTypes");
            RadioElement rBear = new RadioElement("Bear","scoutTypes");
            RadioElement rWeblo = new RadioElement("Weblo","scoutTypes");

            Section myScoutTypesSection = new Section();
            myScoutTypesSection.Add(rTiger);
            myScoutTypesSection.Add(rWolf);
            myScoutTypesSection.Add(rBear);
            myScoutTypesSection.Add(rWeblo);

            EntryElement fn;
            EntryElement ln;
            EntryElement nn;
            RootElement st;
            EntryElement mn;
            EntryElement dn;
            EntryElement ea;
            EntryElement hp;
            EntryElement cp;
            Root = new RootElement ("Add Scout") {
                new Section ("Scout Info") {
                    (fn = new EntryElement("First Name","First Name","")),
                    (ln = new EntryElement("Last Name","Last Name","")),
                    (nn = new EntryElement("Nickname","Nickname","")),
                    (st = new RootElement("Den", myScoutTypes) {
                        myScoutTypesSection
                    }),
                    (mn = new EntryElement("Mom's Name","Mom's Name", "")),
                    (dn = new EntryElement("Dad's Name","Dad's Name", "")),
                    (ea = new EntryElement("Email Address","Email Address", "")),
                    (hp = new EntryElement("Home Phone", "(999) 999-9999", "")),
                    (cp = new EntryElement("Mobile Phone", "(999) 999-9999", "")),
                    new StringElement("Save",delegate {
                        CubScout newScout = new CubScout {FirstName = fn.Value.Trim(), LastName = ln.Value.Trim(),
                            Nickname = nn.Value.Trim (), ScoutType = st.RadioSelected.ToString(),
                            MomsName = mn.Value.Trim(), DadsName = dn.Value.Trim(), EmailAddress = ea.Value.Trim(),
                            HomePhone = hp.Value.Trim(), CellPhone = cp.Value.Trim()};
                        conn.InsertAsync (newScout).ContinueWith (t => {
                            Console.WriteLine ("New scout ID: {0}", newScout.Id);
                        });
                        fn.Value = "";
                        ln.Value = "";
                        nn.Value = "";
                        st.RadioSelected = 0;
                        mn.Value = "";
                        dn.Value = "";
                        ea.Value = "";
                        hp.Value = "";
                        cp.Value = "";
                        this.NavigationController.PopViewControllerAnimated(true);
                    }),
                },
            };
        }
Exemple #4
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear (animated);

            try
            {
                this.NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem(UIImage.FromBundle("icons/399-list1"), UIBarButtonItemStyle.Plain, FlyoutNavigationHandler), true);

                folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
                conn = new SQLiteAsyncConnection (System.IO.Path.Combine (folder, "CubScouts.db"));
                if (!myDB.TableExists("CubScout")) {
                    conn.CreateTableAsync<CubScout>().ContinueWith (t => {
                        Console.WriteLine ("Table created!");
                    });
                }

                //Setup Map Types Radio Group
                RadioGroup myScoutTypes = new RadioGroup("scoutTypes",3);
                RadioElement rTiger = new RadioElement("Tiger","scoutTypes");
                RadioElement rWolf = new RadioElement("Wolf","scoutTypes");
                RadioElement rBear = new RadioElement("Bear","scoutTypes");
                RadioElement rWeblo = new RadioElement("Weblo","scoutTypes");

                Section myScoutTypesSection = new Section();
                myScoutTypesSection.Add(rTiger);
                myScoutTypesSection.Add(rWolf);
                myScoutTypesSection.Add(rBear);
                myScoutTypesSection.Add(rWeblo);

                secCurrentScouts = new Section ("Pack 957 Weblos");
                //MultilineElement scoutElement;

                //Call the reload method to re-populate the list.
                ReloadCubScouts(secCurrentScouts);

                //Setup text colors, etc.
            //				var headerAdd = new UILabel(new RectangleF(0,0,this.View.Bounds.Width-25,48)){
            //					Font = UIFont.BoldSystemFontOfSize (22),
            //					TextColor = UIColor.White,
            //					BackgroundColor = UIColor.Clear,
            //					Text = "Add"
            //				};

                EntryElement fn;
                EntryElement ln;
                EntryElement nn;
                RootElement st;
                EntryElement mn;
                EntryElement dn;
                EntryElement ea;
                EntryElement hp;
                EntryElement cp;
                Root = new RootElement ("Weblos") {
                    new Section ("Add") {
                        new RootElement ("Add Scout") {
                            new Section ("Your info") {
                                (fn = new EntryElement("First Name","First Name","")),
                                (ln = new EntryElement("Last Name","Last Name","")),
                                (nn = new EntryElement("Nickname","Nickname","")),
                                (st = new RootElement("Den", myScoutTypes) {
                                    myScoutTypesSection
                                }),
                                (mn = new EntryElement("Mom's Name","Mom's Name", "")),
                                (dn = new EntryElement("Dad's Name","Dad's Name", "")),
                                (ea = new EntryElement("Email Address","Email Address", "")),
                                (hp = new EntryElement("Home Phone", "(999) 999-9999", "")),
                                (cp = new EntryElement("Mobile Phone", "(999) 999-9999", "")),
                                new StringElement("Save",delegate {
                                    CubScout newScout = new CubScout {FirstName = fn.Value.Trim(), LastName = ln.Value.Trim(),
                                        Nickname = nn.Value.Trim (), ScoutType = st.RadioSelected.ToString(),
                                        MomsName = mn.Value.Trim(), DadsName = dn.Value.Trim(), EmailAddress = ea.Value.Trim(),
                                        HomePhone = hp.Value.Trim(), CellPhone = cp.Value.Trim()};
                                    conn.InsertAsync (newScout).ContinueWith (t => {
                                        Console.WriteLine ("New scout ID: {0}", newScout.Id);
                                    });
                                    fn.Value = "";
                                    ln.Value = "";
                                    nn.Value = "";
                                    st.RadioSelected = 3;
                                    mn.Value = "";
                                    dn.Value = "";
                                    ea.Value = "";
                                    hp.Value = "";
                                    cp.Value = "";
                                    this.NavigationController.PopViewControllerAnimated(true);
                                }),
                            },
                        }
                    },
                    secCurrentScouts,
                };
            }
            catch (Exception ex)
            {
                using (UIAlertView myAlert = new UIAlertView())
                {
                    myAlert.Message = ex.Message;
                    myAlert.Title = "Error!";
                    myAlert.AddButton("OK");
                    myAlert.Show();
                }
            }
            finally
            {

            }
        }
Exemple #5
0
		public override void CommitEditingStyle (UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
		{
			folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
			conn2 = new SQLiteConnection(System.IO.Path.Combine (folder, "CubScouts.db"),false);
			switch (editingStyle)
			{
			case UITableViewCellEditingStyle.Delete:
				CubScout deleteScout = new CubScout {
					Id = Convert.ToInt32(_tableItems[indexPath.Section].IDs[indexPath.Row].ToString())
				};
				conn2.Delete(deleteScout);
				DeleteItemReload(this, new EventArgs());	
				break;
			case UITableViewCellEditingStyle.Insert:
				break;
			case UITableViewCellEditingStyle.None:
				break;
			}
		}