Beispiel #1
0
    protected void btnGuestbookSubmit_Click(object s, EventArgs e)
    {
        if (Page.IsValid)
        {
            NbpDataContext db = new NbpDataContext();
            guestbook g = new guestbook();

            g.guestbookId = Guid.NewGuid();
            g.guestbookEmail = txtEmail.Text.ToString();
            g.guestbookRelationship = txtRelationship.Text.ToString();
            g.guestbookSourceIp = Request.ServerVariables["REMOTE_ADDR"];
            g.guestbookText = txtText.Text.ToString();
            g.guestbookTimestamp = DateTime.Now;
            g.guestbookAuthor = txtAuthor.Text.ToString();

            db.guestbooks.InsertOnSubmit(g);
            db.SubmitChanges();

            Session["nbpEmail"] = txtEmail.Text.ToString();
            Session["nbpName"] = txtAuthor.Text.ToString();

            // audit stuff
            audit a = new audit();
            a.auditId = Guid.NewGuid();
            a.auditRemoteAddr = Request.ServerVariables["REMOTE_ADDR"].ToString();
            a.auditRequestedUrl = "Guestbook.aspx";
            a.auditSessionEmail = Session["nbpEmail"] != null ? Session["nbpEmail"].ToString() : "";
            a.auditSessionId = Session.SessionID.ToString();
            a.auditSessionName = Session["nbpName"] != null ? Session["nbpName"].ToString() : "";
            a.auditTimestamp = DateTime.Now;
            a.auditType = "Guestbook Signed";
            a.auditDescription = "E-Mail: " + txtEmail.Text.ToString() +
                " Relationship: " + txtRelationship.Text.ToString() +
                " Text: " + txtText.Text.ToString();
            a.auditReferrer = Request.UrlReferrer.AbsolutePath.ToString();
            a.auditLogonUser = Request.ServerVariables["LOGON_USER"];
            db.audits.InsertOnSubmit(a);
            db.SubmitChanges();

            MultiView1.ActiveViewIndex = 2;
            MultiView1.DataBind();
        }
        else
        {
            foreach (BaseValidator valControl in Page.Validators)
            {
                WebControl aControl = (WebControl)Page.FindControl(valControl.ControlToValidate);
                if (!valControl.IsValid)
                    aControl.BackColor = System.Drawing.Color.Yellow;
                else
                    aControl.BackColor = System.Drawing.Color.White;
            }

        }
    }
Beispiel #2
0
 partial void Updateguestbook(guestbook instance);
Beispiel #3
0
 partial void Deleteguestbook(guestbook instance);
Beispiel #4
0
 partial void Insertguestbook(guestbook instance);