Esempio n. 1
0
    protected void ButtonAdd_Click(object sender, EventArgs e)
    {
        string tenantId = DropDownListTenant.SelectedValue;
        //string name = DropDownListTenant.SelectedItem.Text;
        int sqft = 0;
        Int32.TryParse(TextBoxSqFt.Text, out sqft);
        int outsidesqft;
        Int32.TryParse(TextBoxSqFtOutside.Text, out outsidesqft);
        string unitNumber = TextBoxUnitNumber.Text;
        bool hasOutside = RadioButtonListHasOutside.SelectedItem.Text == "Yes";
        QuickPM.PropertyUnit unit = new QuickPM.PropertyUnit(unitNumber, property.Id, TextBoxNotes.Text.Trim());
        unit.HasOutside = hasOutside;
        unit.AreaSize = TextBoxAreaSize.Text.Trim();
        unit.AreaSizeOutside = TextBoxOutsideAreaSize.Text.Trim();
        unit.SqFt = sqft;
        unit.SqFtOutside = outsidesqft;

        unit.PropertyId = property.Id;
        unit.Save();
        if (tenantId != "")
        {
            QuickPM.Tenant tenant = new QuickPM.Tenant(tenantId);
            tenant.AddUnit(unit.Id, DateTime.Today, DateTime.MaxValue);
            tenant.Save();
        }
        GetUnits();
    }
Esempio n. 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request["Id"] == null)
     {
         return;
     }
     unit = new QuickPM.PropertyUnit(long.Parse(Request["Id"]));
     if (!IsPostBack)
     {
         ListItem it = new ListItem("None", "");
         it.Selected = "" == unit.GetCurrentTenantId();
         DropDownListTenant.Items.Add(it);
         QuickPM.Property property = new QuickPM.Property(unit.PropertyId);
         foreach (string tenantId in property.GetTenantIds())
         {
             QuickPM.Tenant tenant = new QuickPM.Tenant(tenantId);
             ListItem item = new ListItem(tenant.GetShortName(), tenant.TenantId);
             item.Selected = tenantId == unit.GetCurrentTenantId();
             DropDownListTenant.Items.Add(item);
         }
         TextBoxAreaSize.Text = unit.AreaSize;
         TextBoxNotes.Text = unit.Notes;
         TextBoxOutsideAreaSize.Text = unit.AreaSizeOutside;
         TextBoxSqFt.Text = unit.SqFt.ToString();
         TextBoxSqFtOutside.Text = unit.SqFtOutside.ToString();
         TextBoxUnitNumber.Text = unit.UnitNumber;
         RadioButtonListHasOutside.Items[0].Selected = unit.HasOutside;
         RadioButtonListHasOutside.Items[1].Selected = !unit.HasOutside;
     }
 }
Esempio n. 3
0
 protected void ButtonAddNewUnit_Click(object obj, EventArgs e)
 {
     string unitNumber = TextBoxUnitNumber.Text.Trim();
     int sqFt = 0;
     if (int.TryParse(TextBoxUnitSqFt.Text, out sqFt))
     {
         QuickPM.PropertyUnit unit = new QuickPM.PropertyUnit(unitNumber, GetTenant().GetPropertyId(), "");
         unit.SqFt = sqFt;
         unit.Save();
         PopulateDropDown();
         message = "<font color=\"red\">Unit#/Suite#" + unit.UnitNumber + " Added</font>";
     } else {
         message = "<font color=\"red\">Please enter a number for the sq.ft.</font>";
     }
 }
Esempio n. 4
0
    protected void ButtonSave_Click(object sender, EventArgs e)
    {
        string tenantId = DropDownListTenant.SelectedValue;
        int sqft = 0;
        Int32.TryParse(TextBoxSqFt.Text, out sqft);
        int outsidesqft;
        Int32.TryParse(TextBoxSqFtOutside.Text, out outsidesqft);
        string unitNumber = TextBoxUnitNumber.Text;
        bool hasOutside = RadioButtonListHasOutside.SelectedItem.Text == "Yes";
        unit.HasOutside = hasOutside;
        unit.AreaSize = TextBoxAreaSize.Text.Trim();
        unit.AreaSizeOutside = TextBoxOutsideAreaSize.Text.Trim();
        unit.SqFt = sqft;
        unit.SqFtOutside = outsidesqft;
        unit.UnitNumber = unitNumber;
        unit.Notes = TextBoxNotes.Text.Trim();

        if (tenantId != "")
        {
            QuickPM.Tenant tenant = new QuickPM.Tenant(tenantId);
            tenant.SetCurrentUnitId(unit.Id);
            tenant.Save();
        }
        else
        {
            string id = unit.GetCurrentTenantId();
            if (id != "")
            {
                QuickPM.Tenant t = new QuickPM.Tenant(id);
                QuickPM.PropertyUnit pUnit = new QuickPM.PropertyUnit("", unit.PropertyId, "");
                pUnit.Save();
                t.SetCurrentUnitId(pUnit.Id);
                t.Save();
            }
        }
        unit.Save();
        Response.Redirect("Units.aspx?PropertyId=" + unit.PropertyId);
    }
Esempio n. 5
0
 protected void DeleteUnit(string unitId)
 {
     QuickPM.PropertyUnit unit = new QuickPM.PropertyUnit(long.Parse(unitId));
     unit.Delete();
     Response.Redirect("Units.aspx?PropertyId=" + property.Id);
 }
 protected void ExpenseSelectionChanged(string arg)
 {
     string[] vals = arg.Split(new char[] { ';' });
     QuickPM.PropertyUnit unit = new QuickPM.PropertyUnit(long.Parse(vals[0]));
     int value = int.Parse(vals[1]);
     int chartOfAccount = int.Parse(vals[2]);
     QuickPM.TenantReconciliation recon = QuickPM.TenantReconciliation.GetRecon(unit, eb);
     recon.ExpenseParticipation[chartOfAccount] = value;
     recon.Save();
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        QuickPMWebsite.DatabaseSettings.UpdateDatabaseConnectionString(HttpContext.Current.Profile, Request);
        if (Request["ebid"] != null)
        {
            eb = new QuickPM.ExpenseList(new Guid(Request["ebid"]));
        }
        else
        {
            return;
        }
        property = new QuickPM.Property(eb.PropertyId);
        units = QuickPM.PropertyUnit.FindUnits(eb.PropertyId);
        List<string> tenantIds = property.GetTenantIds();
        units = QuickPM.PropertyUnit.FindUnits(property.Id);
        foreach (string tenantId in tenantIds)
        {
            QuickPM.Tenant tenant = new QuickPM.Tenant(tenantId);
            bool needToAdd = true;
            foreach (QuickPM.PropertyUnit unit in units)
            {
                if (unit.GetCurrentTenantId() == tenant.TenantId)
                {
                    needToAdd = false;
                    break;
                }
            }
            if (needToAdd)
            {
                QuickPM.PropertyUnit unit = new QuickPM.PropertyUnit("", tenant.Property, "");
                unit.Save();
                //tenant.Prop
                //tenant.PropertyUnitId = unit.Id;
                tenant.Save();
                units.Add(unit);
            }
        }

        if (Request.Form["__EVENTTARGET"] == "ExpenseSelectionChanged")
        {
            ExpenseSelectionChanged(Request.Form["__EVENTARGUMENT"]);
        }
    }
    protected decimal GetTenantsShare(string tenantId, int chartOfAccount)
    {
        List<QuickPM.TenantReconciliation> tenantRecons = QuickPM.TenantReconciliation.Find<QuickPM.TenantReconciliation>("ExpenseBudgetId", eb.Id);
        int totalParcipSqFt = 0;
        bool tenantPays = false;
        foreach (QuickPM.TenantReconciliation recon in tenantRecons)
        {
            if (!recon.ExpenseParticipation.ContainsKey(chartOfAccount) || recon.ExpenseParticipation[chartOfAccount] == QuickPM.TenantReconciliation.DoesntParticipate)
            {
                continue;
            }
            if (recon.ExpenseParticipation[chartOfAccount] == QuickPM.TenantReconciliation.LandlordPays || recon.ExpenseParticipation[chartOfAccount] == QuickPM.TenantReconciliation.TenantPays)
            {
                totalParcipSqFt += recon.GetPropertyUnit().SqFt;
            }
            if (recon.TenantId == tenantId)
            {
                if (recon.ExpenseParticipation[chartOfAccount] == QuickPM.TenantReconciliation.TenantPays)
                {
                    tenantPays = true;
                }
            }

        }
        if (!tenantPays)
        {
            return 0m;
        }
        QuickPM.PropertyUnit tenantUnit = new QuickPM.PropertyUnit(new QuickPM.Tenant(tenantId).GetPropertyId());
        return tenantUnit.SqFt / totalParcipSqFt * eb.GetCOATotal(chartOfAccount);
    }
Esempio n. 9
0
        protected string GenerateHtml()
        {
            DateTime date = DateTime.Today;
            int year = DateTime.Today.Year;
            int month = DateTime.Today.Month;
            if (Int32.TryParse(DropDownListYear.SelectedValue, out year) && Int32.TryParse(DropDownListMonth.SelectedValue, out month))
            {
                date = new DateTime(year, month, 1);
            }else
            {
                year = DateTime.Today.Year;
                month = DateTime.Today.Month;
            }
            int propertyId;
            if (!Int32.TryParse(Request["PropertyId"], out propertyId) && !Int32.TryParse(DropDownListProperty.SelectedValue, out propertyId))
            {
                return null;
            }
            QuickPM.Property property = new QuickPM.Property(propertyId);
            string html = "";
            html += "<h2>Rent Roll for " + date.ToShortDateString() + "</h2>";
            tableId = Guid.NewGuid();
            html += "<fieldset>";
            html += "<legend>Rent Roll</legend>";
            html += "<table border=\"0px\" cellspacing=\"0px\" cellpadding=\"10px\" id=" + tableId + ">\n";
            List<string> rentTypes = new List<string>();
            List<decimal> rentTotals = new List<decimal>();
            decimal completeTotal = 0m;
            DateTime t1 = DateTime.Now;
            List<string> tenantIds = new List<string>(QuickPM.Database.GetPropertyTenantIds(property.Id, new QuickPM.Period(date.Year, date.Month)));
            TimeSpan l1 = DateTime.Now - t1;
            time1= l1.TotalSeconds.ToString();

            DateTime t2 = DateTime.Now;
            foreach (string tenantId in tenantIds)
            {
                foreach (string rentType in property.RentTypes)
                {
               		if (rentTypes.Contains(rentType))
                   		continue;
                    QuickPM.Bill bill = QuickPM.Bill.GetBill(tenantId, property.RentTypes.IndexOf(rentType), year, month);
               		if (bill.Amount == 0m)
                   		continue;
               		rentTypes.Add(rentType);
               		rentTotals.Add(0m);
                }
            }
            time2 = (DateTime.Now - t2).TotalSeconds.ToString();

            bool even = true;
            string color = even ? "#fff" : "#ddd";
            html += "<tr style=\"background-color:" + color + "\">";
            even = !even;
            Del head = str => "<th>" + str + "</th>";
            html += head("Tenant Number");
            html += head("Name");
            html += head("Phone");
            html += head("Unit #");
            html += head("Unit Size");

            html += head("Next Rent Adjustment");
            foreach (string rentType in rentTypes)
            {
                html += head(rentType);
            }
            html += head("Total Rent");
            html += "</tr>";
            int unitSquareFeetTotal = 0;
            string vacantId = QuickPM.Util.FormatTenantId(property.Id.ToString() + "-0");
            string propertyPart = vacantId.Split(new char[] { '-' })[0];
            string tenantPart = vacantId.Split(new char[] { '-' })[1];
            tenantPart = tenantPart.Replace("0", "*");
            DateTime t3 = DateTime.Now;
            List<QuickPM.PropertyUnit> units = QuickPM.PropertyUnit.FindUnits(property.Id);
            DateTime date1 = new DateTime(year, month, 1);
            DateTime date2 = new DateTime(year, month, DateTime.DaysInMonth(year, month));
            Dictionary<long, string> tIds = QuickPM.PropertyUnit.GetTenantIds(property.Id, date1, date2);
            time3 = (DateTime.Now - t3).TotalSeconds.ToString();

            QuickPMWebsite.RentRollCSV.MergeUnits(units, tIds);
            List<QuickPM.PropertyUnit> mergedUnits = units;
            Dictionary<long, List<long>> associatedUnits = QuickPMWebsite.RentRollCSV.GetAssociatedUnits(mergedUnits, tIds);
            DateTime t4 = DateTime.Now;
            foreach (QuickPM.PropertyUnit unit in mergedUnits)
            {

                color = even ? "#fff" : "#ddd";
                if (tIds[unit.Id] == "")
                {

                    html += "<tr style=\"background-color:" + color + "\">";

                    html += "<td>" + propertyPart + "-" + tenantPart + "</td>";//tenantid
                    string name = "Vacant";
                    if (unit.Notes.Trim() != "")
                    {
                        name = unit.Notes.Trim();
                    }
                    html += "<td>" + name + "</td>";//name
                    html += "<td></td>";//phone
                    html += "<td>" + unit.UnitNumber + "</td>";
                    html += "<td>" + unit.SqFt.ToString("n0") + "</td>";
                    html += "<td>None</td>";//next rent adjustment date.
                    for (int i = 0; i < rentTypes.Count; i++)
                    {
                        html += "<td>" + (0m).ToString("c") + "</td>";
                    }
                    html += "<td>" + (0m).ToString("c") + "</td>";//total rent
                    html += "</tr>";
                    unitSquareFeetTotal += unit.SqFt;
                }
                else
                {
                    QuickPM.Tenant prof = new QuickPM.Tenant(tIds[unit.Id]);

                    string profileIdLink = "<a href = \"" + ResolveUrl("~/Tenants/TenantPage/" + prof.Id) + "\">" + prof.TenantId + "</a>";
                    string name = prof.Name;
                    string phone = prof.Phone;

            string unitNumber = unit.UnitNumber;
            int sqFt = unit.SqFt;

            foreach(long id in associatedUnits[unit.Id])
            {
                QuickPM.PropertyUnit u = new QuickPM.PropertyUnit(id);
                unitNumber += ", " + u.UnitNumber;
                sqFt += u.SqFt;
            }
                    string unitSquareFeet = sqFt.ToString("n0");
                    unitSquareFeetTotal += sqFt;

                    string nextAdjustment = "None.";
                    DateTime? nextBillingChange = prof.GetNextBillingChange(date);
                    if (nextBillingChange.HasValue)
                        nextAdjustment = nextBillingChange.Value.ToShortDateString();
                    List<string> rents = new List<string>();
                    decimal total = 0m;
                    for (int i = 0; i < rentTypes.Count; i++)
                    {
                       	string rentType = rentTypes[i];
                       	QuickPM.Bill bill = QuickPM.Bill.GetBill(prof.TenantId, prof.RentTypes.IndexOf(rentType), year, month);
                       	rents.Add(bill.Amount.ToString("c"));
                       	rentTotals[i] += bill.Amount;
                       	total += bill.Amount;
                    }

                    List<string> columns = new List<string>();
                    columns.Add(profileIdLink);
                    columns.Add(name);
                    columns.Add(phone);
                    columns.Add(unitNumber);
                    columns.Add(unitSquareFeet);

                    columns.Add(nextAdjustment);
                    foreach (string rent in rents)
                    {
                        columns.Add(rent);
                    }
                    columns.Add(total.ToString("c"));
                    completeTotal += total;
                    html += "<tr style=\"background-color:" + color + "\">";

                    foreach (string column in columns)
                    {
                        html += "<td>" + column + "</td>";
                    }
                    html += "</tr>";
                }
                even = !even;
            }

            time4 = (DateTime.Now - t4).TotalSeconds.ToString();

            color = even ? "#fff" : "#ddd";
            html += "<tr style=\"background-color:" + color + "\">";
            even = !even;
            html += "<td><b>Totals</b></td>";
            html += "<td></td><td></td><td></td>";
            html += "<td>" + unitSquareFeetTotal.ToString("n0") + "</td>";
            html += "<td></td>";
            for (int i = 0; i < rentTypes.Count; i++)
            {
                html += "<td>" + rentTotals[i].ToString("c") + "</td>";
            }
            html += "<td>" + completeTotal.ToString("c") + "</td>";
            html += "</tr>";
            html += "</table>";
            html += "</fieldset>";
            return html;
        }