public static bool InsertGoogleDoc(GoogleDoc newDoc)
 {
     GeoTradingCards.DAL.GoogleDocsPage newPage = new GoogleDocsPage();
     newPage.Season        = newDoc.Season;
     newPage.Set           = newDoc.Set;
     newPage.GoogleDocsUrl = newDoc.Url;
     try
     {
         Databases.GoogleDocs.GoogleDocsPages.InsertOnSubmit(newPage);
         Databases.GoogleDocs.SubmitChanges(System.Data.Linq.ConflictMode.FailOnFirstConflict);
         return(true);
     }
     catch (ChangeConflictException)
     {
         foreach (ObjectChangeConflict conflict in Databases.GoogleDocs.ChangeConflicts)
         {
             conflict.Resolve(RefreshMode.OverwriteCurrentValues);
         }
         return(true);
     }
     catch (System.Exception ex)
     {
         ExceptionManager.LogException(ex);
         return(false);
     }
 }
        protected void gvGoogleDocs_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            bool      updateRecord = true;
            GoogleDoc doc          = new GoogleDoc();

            if (e.NewValues.Contains("Set") && e.OldValues.Contains("Set"))
            {
                doc.Set = e.NewValues["Set"] != null ? e.NewValues["Set"].ToString() : string.Empty;
            }
            else
            {
                updateRecord = false;
                DAL.ExceptionManager.LogException(new Exception("Google Doc Update Failed"), "Could not find the SET column in the grid view control");
            }

            if (e.NewValues.Contains("Season") && e.OldValues.Contains("Season"))
            {
                doc.Season = e.NewValues["Season"] != null ? e.NewValues["Season"].ToString() : string.Empty;
            }
            else
            {
                updateRecord = false;
                DAL.ExceptionManager.LogException(new Exception("Google Doc Update Failed"), "Could not find the SEASON column in the grid view control");
            }

            if (e.NewValues.Contains("GoogleDocsUrl") && e.OldValues.Contains("GoogleDocsUrl"))
            {
                doc.Url = e.NewValues["GoogleDocsUrl"] != null ? e.NewValues["GoogleDocsUrl"].ToString() : string.Empty;
            }
            else
            {
                updateRecord = false;
                DAL.ExceptionManager.LogException(new Exception("Google Doc Update Failed"), "Could not find the \"GoogleDocsUrl\" column in the grid view control");
            }

            //if (!doc.isValidDbRow())
            //{
            //    updateRecord = false;
            //    // Display error message to user
            //}

            if (!updateRecord)
            {
                e.Cancel = true;
                gvGoogleDocs.EditIndex = -1;
                BindData();
            }
            else
            {
            }
        }
 protected void btnInsert_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         GoogleDoc newDoc = new GoogleDoc();
         newDoc.Season = ddlSeasons.SelectedItem.Value;
         newDoc.Set    = tbCardSet.Text;
         newDoc.Url    = tbGoogleDocUrl.Text;
         bool success = newDoc.InsertIntoDB();
         if (success)
         {
             BindData();
         }
         else
         {
             lbInsertError.Visible = true;
         }
     }
 }