Ejemplo n.º 1
0
        protected void wdgNotes_ItemCommand(object sender, Infragistics.Web.UI.GridControls.HandleCommandEventArgs e)
        {
            int policyNoteID = 0;
            PolicyNote note = null;

            if (e.CommandName == "DoEdit") {
                policyNoteID = Convert.ToInt32(e.CommandArgument);
                using (PolicyNoteManager repository = new PolicyNoteManager()) {
                    note = repository.Get(policyNoteID);

                    pnlPolicyNoteEdit.Visible = true;
                    pnlPolicyNotes.Visible = false;

                    txtPolicyNote.Text = note.Notes;
                }
                ViewState["policyNoteID"] = policyNoteID.ToString();
            }
            else if (e.CommandName == "DoRemove") {
                policyNoteID = Convert.ToInt32(e.CommandArgument);

                using (PolicyNoteManager repository = new PolicyNoteManager()) {
                    note = repository.Get(policyNoteID);
                    repository.Delete(note);

                    btnPolicyNoteCancel_Click(null, null);
                }
            }
        }
Ejemplo n.º 2
0
        protected void btnPolicyNoteSave_Click(object sender, EventArgs e)
        {
            PolicyNote policyNote = null;
            int policyID = 0;
            int policyNoteID = 0;

            Page.Validate("policyNote");
            if (!Page.IsValid)
                return;

            policyID = Convert.ToInt32(hf_policyID.Value);
            policyNoteID = Convert.ToInt32(ViewState["policyNoteID"]);

            using (PolicyNoteManager repository = new PolicyNoteManager()) {
                if (policyNoteID == 0) {
                    policyNote = new PolicyNote();
                    policyNote.PolicyID = policyID;
                    policyNote.NoteDate = DateTime.Now;
                    policyNote.UserID = SessionHelper.getUserId();
                }
                else {
                    policyNote = repository.Get(policyNoteID);
                }

                if (policyNote != null) {
                    policyNote.Notes = txtPolicyNote.Text.Trim();
                    repository.Save(policyNote);
                }
            }

            pnlPolicyNotes.Visible = true;
            pnlPolicyNoteEdit.Visible = false;

            wdgNotes.DataBind();
        }