コード例 #1
0
ファイル: Units.aspx.cs プロジェクト: Devang83/csc131
    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();
    }
コード例 #2
0
ファイル: TestUtil.cs プロジェクト: Devang83/csc131
 public static void CreateTenant(string tenantId)
 {
     QuickPM.Tenant t = new QuickPM.Tenant(tenantId);
     t.CreatedDate = DateTime.MinValue;
     t.Name = "Tenant #1";
     t.Save();
 }
コード例 #3
0
ファイル: BillingRecordTests.cs プロジェクト: Devang83/csc131
        public void CreateBillingRecord()
        {
            QuickPM.BillingRecord b1 = new QuickPM.BillingRecord();
            b1.StartDate = new DateTime(2008, 1, 1);
            b1.EndDate = new DateTime(2008, 2, 1);
            b1.RentTypeIndex = 0;
            b1.Amount = 100m;
            b1.TenantId = tenantId;
            b1.Save();

            b1 = QuickPM.BillingRecord.CreateBillingRecord(b1.Id);
            Assert.AreEqual(b1.StartDate, new DateTime(2008, 1, 1));
            Assert.AreEqual(b1.Amount, 100m);
            Assert.AreEqual(b1.RentTypeIndex, 0);
            Assert.AreEqual(b1.TenantId, tenantId);

            b1.StartDate = DateTime.MinValue;
            QuickPM.Tenant tenant = new QuickPM.Tenant(tenantId);
            tenant.CreatedDate = DateTime.Today;
            tenant.Save();
            bool exceptionThrown = false;
            try
            {
                b1.Save();
            }
            catch (Exception e)
            {
                if (e.Message.Contains("billing record start before the tenant was created"))
                {
                    exceptionThrown = true;
                }
                else
                {
                    throw e;
                }
            }
            if (!exceptionThrown)
            {
                throw new Exception("Should have had exception when saving billing record.");
            }
        }
コード例 #4
0
ファイル: EditUnit.aspx.cs プロジェクト: Devang83/csc131
    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);
    }
コード例 #5
0
ファイル: PropertyTests.cs プロジェクト: Devang83/csc131
        public void GetTenantIds()
        {
            QuickPM.Property p = new QuickPM.Property(propertyNumber);
            QuickPM.Tenant tenant = new QuickPM.Tenant(QuickPM.Util.FormatTenantId(propertyNumber.ToString() + "-01"));
            tenant.Save();

            Assert.AreEqual(1, p.GetTenantIds().Count);
            Assert.AreEqual(1, p.GetTenantIds(true).Count);
            Assert.AreEqual(tenant.Id, p.GetTenantIds()[0]);
            Assert.AreEqual(tenant.Id, p.GetTenantIds(true)[0]);

            tenant.EndDate = new DateTime(DateTime.Today.Year - 1, 1, 1);
            tenant.CreatedDate = tenant.EndDate;
            tenant.Save();
            Assert.AreEqual(0, p.GetTenantIds().Count);
            Assert.AreEqual(1, p.GetTenantIds(true).Count);
        }
コード例 #6
0
ファイル: PropertyTests.cs プロジェクト: Devang83/csc131
        public void FindDelinquentTenants()
        {
            string rent1 = "Rent";
            QuickPM.Property p = new QuickPM.Property(propertyNumber);
            p.AddRentType(rent1);
            p.Save();
            QuickPM.Tenant tenant = new QuickPM.Tenant(QuickPM.Util.FormatTenantId(propertyNumber.ToString() + "-01"));
            tenant.CreatedDate = DateTime.MinValue;
            tenant.Save();
            Dictionary<string, decimal> rents = new Dictionary<string,decimal>();
            rents.Add(rent1, 100);
            QuickPM.Util.AddBillingAndARRecords(tenant.Id, 1, 1, new DateTime(DateTime.Today.Year - 1, DateTime.Today.Month, 1), new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1), rents);
            p.FindDelinquentTenants((float)1.0);
            return;
            /*Assert.AreEqual(1, p.FindDelinquentTenants((float)1.0).Count);
            Assert.AreEqual(1, p.FindDelinquentTenants((int)60).Count);
            Assert.AreEqual(0, p.FindDelinquentTenants((float)10000).Count);
            QuickPM.Check check = new QuickPM.Check();
            check.TenantId = tenant.Id;
            check.ARRecordDate = new DateTime(DateTime.Today.Year - 1, 1, 1);
            check.CheckDate = DateTime.Today;
            check.Number = "1";
            check.ReceivedDate = DateTime.Today;
            check.Amount = 100;
            check.AutoApply(new QuickPM.Period(check.ARRecordDate.Year, check.ARRecordDate.Month));
            check.Save();

            Assert.AreEqual(0, p.FindDelinquentTenants((int)600).Count);*/
        }
コード例 #7
0
    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"]);
        }
    }