/// <summary>
        /// reads the column values from a datareader and populates the object properties
        /// </summary>
        /// <param name="reader"></param>
        public override void Load(MySqlDataReader reader)
        {
            this.Code               = Preparer.SafeString(reader["ap_code"]);
            this.Description        = Preparer.SafeString(reader["ap_description"]);
            this.SendNotification   = Preparer.SafeBool(reader["ap_send_notification"]);
            this.ChangeStatusTo     = Preparer.SafeString(reader["ap_change_status_to"]);
            this.PermissionRequired = Preparer.SafeInt(reader["ap_permission_required"]);

            // Get all associated roles for this attachment purpose
            AttachmentRole          ardao  = new AttachmentRole(this.phreezer);
            AttachmentRolesCriteria arcrit = new AttachmentRolesCriteria();

            arcrit.AttachmentPurposeCode = reader["ap_code"].ToString();
            AttachmentRoles aroles = ardao.GetAttachmentRoles(arcrit);

            IEnumerator   i  = aroles.GetEnumerator();
            StringBuilder sb = new StringBuilder();

            // put roles into a comma-delimited list
            while (i.MoveNext())
            {
                AttachmentRole r = (AttachmentRole)i.Current;
                sb.Append(r.RoleDescription + ", ");
            }

            // trim off comma at the end
            if (sb.Length > 2)
            {
                sb.Length = sb.Length - 2;
            }

            this.Roles = Preparer.SafeString(sb.ToString());

            this.OnLoad(reader);
        }
Пример #2
0
        /* ~~~ CONSTRAINTS ~~~ */


        /* ~~~ SETS ~~~ */

        /// <summary>
        /// Returns a collection of AttachmentRole objects
        /// </summary>
        /// <param name="criteria"></param>
        /// <returns>Accounts</returns>
        public AttachmentRoles GetAttachmentRoles(AttachmentRolesCriteria criteria)
        {
            Phreezer        p = new Phreezer(System.Configuration.ConfigurationManager.ConnectionStrings["DBConn"].ConnectionString);
            AttachmentRoles attachmentRoles = new AttachmentRoles(p);

            attachmentRoles.Query(criteria);
            p.Close();
            return(attachmentRoles);
        }
    /// <summary>
    /// Persist to DB
    /// </summary>
    protected void UpdateAttachmentPurpose()
    {
        string code = txtCode.Text;

        this.attachmentPurpose.Code               = code;
        this.attachmentPurpose.Description        = txtDescription.Text;
        this.attachmentPurpose.ChangeStatusTo     = txtChangeStatusTo.Text;
        this.attachmentPurpose.PermissionRequired = int.Parse(txtPermissionRequired.Text);
        this.attachmentPurpose.SendNotification   = cbSendNotification.Checked;

        // Insert/Delete Attachment/Roles
        IEnumerator i = RolesCheckboxes.Items.GetEnumerator();

        Affinity.AttachmentRole ardao = new Affinity.AttachmentRole(this.phreezer);
        ardao.AttachmentPurposeCode = code;
        Affinity.AttachmentRolesCriteria arcrit = new Affinity.AttachmentRolesCriteria();
        arcrit.AttachmentPurposeCode = code;

        // loop through the checkboxes and insert or delete as needed
        while (i.MoveNext())
        {
            ListItem li = (ListItem)i.Current;
            arcrit.RoleCode = li.Value;
            Affinity.AttachmentRoles aroles = ardao.GetAttachmentRoles(arcrit);
            ardao.RoleCode = li.Value;

            //Delete item if there was one there before but is no longer selected
            if (aroles.Count > 0 && !li.Selected)
            {
                ardao.Delete();
            }
            // insert item if there wasn't there before but is now selected
            else if (li.Selected && aroles.Count == 0)
            {
                ardao.Insert(false);
            }
        }

        if (this.isUpdate)
        {
            this.attachmentPurpose.Update();
        }
        else
        {
            this.attachmentPurpose.Insert(false);
        }

        this.Redirect("AdminAttachmentPurposes.aspx?feedback=Attachment+Type+Updated");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        this.RequirePermission(Affinity.RolePermission.AdminSystem);
        this.RequirePermission(Affinity.RolePermission.AffinityManager);
        this.RequirePermission(Affinity.RolePermission.AffinityStaff);
        this.Master.SetLayout("AttachmentPurpose Details", MasterPage.LayoutStyle.ContentOnly);

        this.btnDelete.Attributes.Add("onclick", "return confirm('Delete this record?')");

        if (!Page.IsPostBack)
        {
            // populate the form
            string code = this.attachmentPurpose.Code.ToString();
            txtCode.Text               = code;
            lblCode.Text               = code;
            txtDescription.Text        = this.attachmentPurpose.Description.ToString();
            txtChangeStatusTo.Text     = this.attachmentPurpose.ChangeStatusTo.ToString();
            txtPermissionRequired.Text = this.attachmentPurpose.PermissionRequired.ToString();
            cbSendNotification.Checked = this.attachmentPurpose.SendNotification;

            if (this.isUpdate)
            {
                lblCode.Visible = true;
            }
            else
            {
                txtCode.Visible = true;
            }

            // Display checkbox roles
            Affinity.Roles        roles = new Affinity.Roles(this.phreezer);
            Affinity.RoleCriteria rc    = new Affinity.RoleCriteria();

            // order by description
            rc.AppendToOrderBy("Description");
            roles.Query(rc);

            // display checkboxes in columns of 3
            RolesCheckboxes.RepeatColumns = 3;
            RolesCheckboxes.Width         = 700;

            Affinity.AttachmentRole          ardao  = new Affinity.AttachmentRole(this.phreezer);
            Affinity.AttachmentRolesCriteria arcrit = new Affinity.AttachmentRolesCriteria();
            IEnumerator i = roles.GetEnumerator();

            // loop through all the roles and add checkboxes for each one
            while (i.MoveNext())
            {
                ListItem      li = new ListItem();
                Affinity.Role r  = (Affinity.Role)i.Current;
                li.Text  = r.Description;
                li.Value = r.Code;

                // verify if this checkbox should be checked
                arcrit.AttachmentPurposeCode = code;
                arcrit.RoleCode = r.Code;
                Affinity.AttachmentRoles aroles = ardao.GetAttachmentRoles(arcrit);
                li.Selected = (aroles.Count > 0);

                // Add checkbox to RolesCheckboxes div
                RolesCheckboxes.Items.Add(li);
            }
        }
    }
Пример #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.RequirePermission(Affinity.RolePermission.SubmitOrders);
        this.Master.SetLayout("Order Details", MasterPage.LayoutStyle.ContentOnly);

        string id = NoNull.GetString(Request["id"]);

        // this is used to track if a property changes was submitted
        int changeId = 0;

        Affinity.Order order = new Affinity.Order(this.phreezer);
        order.Load(id);

        // make sure this user has permission to make updates to this order
        if (!order.CanRead(this.GetAccount()))
        {
            this.Crash(300, "Permission denied.");
        }

        //order.CustomerStatusCode
        //order.InternalStatusCode

        lblWorkingId.Text = order.WorkingId;

        txtCustomerId.Text = order.CustomerId;

        txtClientName.Text       = order.ClientName;
        txtPIN.Text              = order.Pin;
        txtAdditionalPins.Text   = order.AdditionalPins;
        txtPropertyAddress.Text  = order.PropertyAddress;
        txtPropertyAddress2.Text = order.PropertyAddress2;
        txtPropertyCity.Text     = order.PropertyCity;
        txtPropertyState.Text    = order.PropertyState;
        txtPropertyZip.Text      = order.PropertyZip;
        txtCustomerId.Text       = order.CustomerId;
        txtPropertyCounty.Text   = order.PropertyCounty;
        txtClosingDate.Text      = order.ClosingDate.ToShortDateString();

        // show any attachments that go with this order
        Affinity.Attachments        atts = new Affinity.Attachments(this.phreezer);
        Affinity.AttachmentCriteria attc = new Affinity.AttachmentCriteria();
        attc.OrderId = order.Id;
        atts.Query(attc);

        // see if the user has access to the attachment
        Affinity.AttachmentRole          ardao  = new Affinity.AttachmentRole(this.phreezer);
        Affinity.AttachmentRolesCriteria arcrit = new Affinity.AttachmentRolesCriteria();
        arcrit.RoleCode = this.GetAccount().RoleCode;

        foreach (Affinity.Attachment att in atts)
        {
            arcrit.AttachmentPurposeCode = att.AttachmentPurpose.Code;
            Affinity.AttachmentRoles aroles = ardao.GetAttachmentRoles(arcrit);

            // if the user has permission to view this attachment
            if (aroles.Count > 0 || this.GetAccount().Id == order.OriginatorId)
            {
                pnlAttachments.Controls.Add(new LiteralControl("<div><a class=\"attachment\" href=\"MyAttachment.aspx?id=" + att.Id + "\">" + att.Name + "</a> (" + att.Created.ToString("M/dd/yyyy hh:mm tt") + ")</div>"));
            }
        }

        // show the entire order history
        Affinity.RequestCriteria rc = new Affinity.RequestCriteria();
        rc.AppendToOrderBy("Created", true);
        rGrid.DataSource = order.GetOrderRequests(rc);
        rGrid.DataBind();

        // show the available actions that can be done with this order
        Affinity.RequestTypes rts = order.GetAvailableRequestTypes();
        pnlActions.Controls.Add(new LiteralControl("<div class=\"actions\">"));
        foreach (Affinity.RequestType rt in rts)
        {
            pnlActions.Controls.Add(new LiteralControl("<div><a class=\"add\" href=\"MyRequestSubmit.aspx?id=" + order.Id + "&code=" + rt.Code + "\">Add a " + rt.Description + " to this Order</a></div>"));
        }
        pnlActions.Controls.Add(new LiteralControl("<div><a class=\"add\" href=\"documents.aspx?id=" + order.Id + "\">Closing Document Manager – Forms</a></div>"));
        pnlActions.Controls.Add(new LiteralControl("</div>"));

        // show the details for the active requests
        Affinity.Requests rs = order.GetCurrentRequests();

        foreach (Affinity.Request r in rs)
        {
            // we don't want to show changes to the property information
            if (r.RequestType.Code != Affinity.RequestType.DefaultChangeCode)
            {
                XmlForm xf = new XmlForm(this.GetAccount());

                //Hashtable labels = xf.GetLabelHashtable(r.RequestType.Definition);
                Hashtable responses = XmlForm.GetResponseHashtable(r.Xml);

                pnlRequests.Controls.Add(new LiteralControl("<div class=\"groupheader\">" + r.RequestType.Description
                                                            + " [<a href=\"MyRequestSubmit.aspx?change=" + r.Id + "&id=" + order.Id + "&code=" + r.RequestType.Code + "\">Edit</a>]"
                                                            + "</div>"));
                pnlRequests.Controls.Add(new LiteralControl("<fieldset class=\"history\">"));

                // add the basic info
                pnlRequests.Controls.Add(NewLine("Request Status", r.RequestStatus.Description));
                pnlRequests.Controls.Add(NewLine("Notes", r.Note));
                pnlRequests.Controls.Add(NewLine("Submitted", r.Created.ToString("MM/dd/yyyy hh:mm tt")));

                ArrayList keys = new ArrayList(responses.Keys);
                keys.Sort();

                foreach (string key in keys)
                {
                    // we check for fields ending with "_validator" due to a bug with order prior to 03/13/07
                    // if (responses[key].ToString().Equals("") == false)
                    if (responses[key].ToString().Equals("") == false && key.EndsWith("_validator") == false)
                    {
                        //pnlRequests.Controls.Add(new LiteralControl("<div>" + labels[key].ToString() + ": " + responses[key].ToString() + "</div>"));
                        pnlRequests.Controls.Add(NewLine(key, responses[key]));
                    }
                }

                pnlRequests.Controls.Add(new LiteralControl("</fieldset>"));
            }
            else
            {
                changeId = r.Id;
            }
        }

        lnkChange.NavigateUrl = "MyRequestSubmit.aspx?id=" + order.Id + "&change=" + changeId + "&code=" + Affinity.RequestType.DefaultChangeCode;
    }