private void CreateChapterAddress(int chID) { int newChaKey = 0; ChapterAddressDataContext cadc = new ChapterAddressDataContext(); ChapterAddress ca = new ChapterAddress(); ca.ChapterId = chID; ca.Active = true; ca.StreetAddress1 = txtStreetAddr1.Text.ToString(); ca.City = txtCity.Text.ToString(); ca.StateId = Convert.ToInt32(cboState.SelectedValue); ca.Zip = txtZip.Text.ToString(); ca.DateCreated = System.DateTime.Now; ca.DateModified = System.DateTime.Now; try { cadc.ChapterAddresses.InsertOnSubmit(ca); cadc.SubmitChanges(); newChaKey = ca.ChapterAddressId; } catch (Exception exceptCha) { MessageBox.Show(exceptCha.ToString()); } //MessageBox.Show("New Chapter ID " + chID.ToString() +" New Chapter Address Key "+ newChaKey.ToString()); //If Successful Update the Google Link if (newChaKey > 0) { UpdateChapterGLink(chID, newChaKey); } }
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); }