Exemple #1
0
    protected void LinqDataSource1_Inserted(object sender, LinqDataSourceStatusEventArgs e)
    {
        PersonInfo p = e.Result as PersonInfo;

        if (p.SpouseID != null && p.SpouseID != 0)
        {
            try
            {
                //Updating SpouseID after submit
                using (MyFamilyDatabaseDataContext db = new MyFamilyDatabaseDataContext())
                {
                    PersonInfo spouse = db.PersonInfos.Where(sp => sp.PersonID == p.SpouseID).FirstOrDefault();
                    spouse.SpouseID = p.PersonID;
                    db.SubmitChanges();
                }
            }
            catch (Exception)
            {
                //Eat any exception
            }
        }

        ExtMethods.SendAddEmail(p);
        Response.Redirect("./PersonInfo.aspx?PersonID=" + p.PersonID);
    }
 protected void Button1_Click(object sender, EventArgs e)
 {
     PopulatePersonInfo();
     if (_PersonInfo != null)
     {
         _db.PersonInfos.DeleteOnSubmit(_PersonInfo);
         try
         {
             _db.SubmitChanges();
             Response.Write("Deleted PersonInfo");
         }
         catch (Exception ex)
         {
             Response.Write(ex.Message);
         }
     }
     else
     {
         Response.Write("_PersonInfo is null");
     }
 }
Exemple #3
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(txtOccupation.Text))
        {
            Response.Write("Occupation can't be empty");
            return;
        }

        try
        {
            using (MyFamilyDatabaseDataContext db = new MyFamilyDatabaseDataContext())
            {
                Occupation occupation = new Occupation();
                occupation.OccupationDesc = txtOccupation.Text;
                db.Occupations.InsertOnSubmit(occupation);
                db.SubmitChanges();
                Response.Write("New occupation inserted");
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }