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);
                }
            }
        }
        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);
        }
Пример #3
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();
         }
     }
 }
        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));
                }
            }
        }