コード例 #1
0
        public static string GetChGLink(int ChID)
        {
            ChapterClassDataContext cdc = new ChapterClassDataContext();
            string gLink = (from a in cdc.Chapters where a.ChapterId == ChID select a.GoogleLink).FirstOrDefault();;

            return(gLink);
        }
コード例 #2
0
        private void CreateChapter()
        {
            bool   validForm;
            string newGLink = string.Empty;
            int    newChKey = 0;

            RefreshErrorBlock();
            validForm = ValidateForm();

            if (validForm)
            {
                try
                {
                    ChapterClassDataContext cdc = new ChapterClassDataContext();
                    Chapter ch = new Chapter();
                    ch.ChapterName     = txtChapter.Text.ToString();
                    ch.ChapterNickName = txtChapterNN.Text.ToString();
                    ch.Active          = true;
                    cdc.Chapters.InsertOnSubmit(ch);
                    cdc.SubmitChanges();
                    newChKey = ch.ChapterId;
                }
                catch (Exception exceptCh)
                {
                    MessageBox.Show(exceptCh.ToString());
                }
                if (newChKey != 0)
                {
                    CreateChapterAddress(newChKey);
                    CreateChapterMiles(newChKey);
                }
            }
        }
コード例 #3
0
        private bool UpdateChapterInfo(bool updateSuccess)
        {
            bool validForm;
            //bool updateSuccess = true;
            string newGLink = string.Empty;
            int    chID     = Convert.ToInt32(cboChapter.SelectedValue);

            RefreshErrorBlock();
            validForm = ValidateForm();
            if (validForm)
            {
                newGLink = Helper.GoogleHelper.CreateChapterGLink(txtStreetAddr1.Text.ToString(), txtCity.Text.ToString(), Convert.ToInt32(cboState.SelectedValue), txtZip.Text.ToString());
                ChapterClassDataContext cdc = new ChapterClassDataContext();
                Chapter ch = new Chapter();
                ch = (from c in cdc.Chapters
                      where c.ChapterId == chID
                      select c).FirstOrDefault();

                ch.ChapterNickName = txtChapterNN.Text.ToString();
                ch.GoogleLink      = newGLink;
                ch.DateModified    = System.DateTime.Now;

                try
                {
                    cdc.SubmitChanges();
                }
                catch (Exception exceptCH)
                {
                    MessageBox.Show(exceptCH.Message.ToString());
                    updateSuccess = false;
                }
            }

            return(updateSuccess);
        }
コード例 #4
0
        public static Chapter GetChapter(int chID)
        {
            Chapter selChapter          = new Chapter();
            ChapterClassDataContext cdc = new ChapterClassDataContext();

            selChapter = (Chapter)cdc.Chapters.Where(a => a.ChapterId == chID).FirstOrDefault();
            return(selChapter);
        }
コード例 #5
0
        public static Dictionary <int, string> GetChapters()
        {
            Dictionary <int, string> ChapterDict = new Dictionary <int, string>();
            ChapterClassDataContext  cdc         = new ChapterClassDataContext();

            ChapterDict = cdc.Chapters.ToDictionary(x => x.ChapterId, x => x.ChapterName);

            return(ChapterDict);
        }
コード例 #6
0
        public static IEnumerable GetChapters()
        {
            ChapterClassDataContext cdc = new ChapterClassDataContext();

            chList = (from a in cdc.Chapters select a).ToList();
            //Putting Chapters into DataGrid to see the list
            //dgChapters.ItemsSource = chList;
            return(chList);
        }
コード例 #7
0
        private bool UpdateChapterAddressInfo(bool updateSuccess)
        {
            bool validForm;

            string chapterName = string.Empty;
            string newGLink    = string.Empty;

            RefreshErrorBlock();
            validForm = ValidateForm();
            if (validForm)
            {
                //Update the Chapter Address
                int chID = selChapt;
                ChapterAddressDataContext cadc = new ChapterAddressDataContext();
                ChapterAddress            chA  = new ChapterAddress();
                chA = (from chaA in cadc.ChapterAddresses
                       where chaA.ChapterId == chID
                       select chaA).FirstOrDefault();

                chA.StreetAddress1 = txtStreetAddr1.Text.ToString();
                chA.StateId        = Convert.ToInt32(cboState.SelectedValue);
                chA.City           = txtCity.Text.ToString();
                chA.Zip            = txtZip.Text;
                string streetAddress = (chA.StreetAddress2 == null) ? chA.StreetAddress1 : string.Concat(chA.StreetAddress1, " ", chA.StreetAddress2);
                try
                {
                    cadc.SubmitChanges();
                }
                catch (Exception exceptCA)
                {
                    MessageBox.Show(exceptCA.Message.ToString());
                    updateSuccess = false;
                }

                try
                {
                    //Update Chapter Google Link
                    ChapterClassDataContext cdc = new ChapterClassDataContext();
                    Chapter chU = new Chapter();
                    chU = (from ch in cdc.Chapters
                           where ch.ChapterId == chID
                           select ch).FirstOrDefault();
                    newGLink       = Helper.GoogleHelper.CreateChapterGLink(streetAddress, chA.City, Convert.ToInt32(cboState.SelectedValue), chA.Zip);
                    chU.GoogleLink = newGLink;
                    txtGlink.Text  = newGLink;
                    chapterName    = chU.ChapterName;
                }
                catch (Exception exceptCh)
                {
                    MessageBox.Show(exceptCh.Message.ToString());
                    updateSuccess = false;
                }
            }
            return(updateSuccess);
        }
コード例 #8
0
 private static void UpdateChapterGoogleLinkDB(Dictionary <int, string> chGoogleLink)
 {
     using (var chTableCon = new ChapterClassDataContext())
     {
         foreach (var ch in chTableCon.Chapters)
         {
             ch.GoogleLink = chGoogleLink[ch.ChapterId];
             chTableCon.SubmitChanges();
         }
     }
 }
コード例 #9
0
        private void UpdateChapterGLink(int chID, int chaID)
        {
            string newGLink      = string.Empty;
            bool   updateSuccess = true;
            string chapterName   = string.Empty;
            //Update Chapter Google Link
            ChapterClassDataContext cdc = new ChapterClassDataContext();
            Chapter chU = new Chapter();

            chU = (from ch in cdc.Chapters
                   where ch.ChapterId == chID
                   select ch).FirstOrDefault();
            newGLink               = Helper.GoogleHelper.CreateChapterGLink(txtStreetAddr1.Text.ToString(), txtCity.Text.ToString(), Convert.ToInt32(cboState.SelectedValue), txtZip.Text.ToString());
            chU.GoogleLink         = newGLink;
            chU.ClubHouseAddressID = chaID;
            chU.DateCreated        = System.DateTime.Now;
            chU.DateModified       = System.DateTime.Now;
            txtGlink.Text          = newGLink;
            chapterName            = chU.ChapterName;

            try
            {
                cdc.SubmitChanges();
            }
            catch (Exception exceptCh)
            {
                MessageBox.Show(exceptCh.Message.ToString());
                updateSuccess = false;
            }

            if (updateSuccess)
            {
                if (_mode == _modeCreate)
                {
                    MessageBox.Show(string.Concat(_successCreateMsg, chapterName));
                }
                else
                {
                    MessageBox.Show(string.Concat(_successMsg, chapterName));
                }
            }
        }