protected void Page_Load(object sender, EventArgs e) { if (Session["personKey"] != null) { CommunityAssistEntities1 ae = new CommunityAssistEntities1(); int pk = (int)Session["personKey"]; var customer = from c in ae.People where c.PersonKey == pk select new { c.PersonLastName, c.PersonFirstName, c.PersonUsername }; foreach (var p in customer) { lblWelcome.Text = "Welcome! " + p.PersonFirstName + " " + p.PersonLastName + " to Community Assist."; } GridView1.DataSource = customer.ToList(); GridView1.DataBind(); } else { Response.Redirect("Default.aspx"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { try { CommunityAssistEntities1 cae = new CommunityAssistEntities1(); Donation d = new Donation(); int pk = (int)Session["personKey"]; d.DonationAmount = Decimal.Parse(txtDonation.Text); d.DonationDate = DateTime.Now; d.PersonKey = pk; cae.Donations.Add(d); cae.SaveChanges(); Response.Redirect("Confirmation.aspx"); } catch (Exception ex) { lblError.Text = ex.Message; } }
protected void btnSubmit_Click(object sender, EventArgs e) { try { CommunityAssistEntities1 cae = new CommunityAssistEntities1(); ServiceGrant sg = new ServiceGrant(); int pk = (int)Session["personKey"]; sg.ServiceKey = int.Parse(ddlGrantType.SelectedValue.ToString()); sg.GrantAmount = Decimal.Parse(txtGrantAmount.Text); sg.GrantDate = DateTime.Now; sg.GrantNeedExplanation = txtExplanation.Text; sg.PersonKey = pk; cae.ServiceGrants.Add(sg); cae.SaveChanges(); Response.Redirect("Confirmation.aspx"); } catch (Exception ex) { lblError.Text = ex.Message; } }