Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        QuickPMWebsite.DatabaseSettings.UpdateDatabaseConnectionString(HttpContext.Current.Profile, Request);
            DateTime date = DateTime.Today;
            int year = DateTime.Today.Year;
            int month = DateTime.Today.Month;

            if (Int32.TryParse(Request["Year"], out year) && Int32.TryParse(Request["Month"], out month))
            {
                date = new DateTime(year, month, 1);
            }
            int propertyId;
            if (!Int32.TryParse(Request["PropertyId"], out propertyId))
            {
                //return null;
            }
            QuickPM.Property property = new QuickPM.Property(propertyId);

            string fileName = Request.PhysicalApplicationPath + "/App_Data/Tmp/" + "RentRoll.pdf";
            //System.IO.FileStream file = new System.IO.FileStream(fileName, System.IO.FileMode.Create);

            QuickPMWebsite.RentRollCSV.GenerateRentRollPdf(property.Id, false, new QuickPM.Period(date.Year, date.Month), fileName);
            //doc.Data = new UTF8Encoding(true).GetBytes("test");
            //file.Write(doc.Data, 0, doc.Data.Length);
            //long fileLength = file.Length;
            //file.Close();
            Response.Clear();
            Response.AddHeader("Content-Disposition", "attachment; filename=" + "RentRoll.pdf");
            //Response.AddHeader("Content-Length", fileLength.ToString());
            Response.ContentType = "application/octet-stream";
            Response.WriteFile(fileName);
            Response.End();
    }
Пример #2
0
        public void CreateProperty()
        {
            string address = "add1";
            int rentindex1 = 0;
            string rent1 = "Min Rent";
            int rentindex2 = 1;
            string rent2 = "Addl Rent";
            string legalName = "Legal Name";
            string name = "Name";
            int chartOfAccount = 1001;
            bool active = false;
            //Create a new Property.
            QuickPM.Property p = new QuickPM.Property(2);
            p.Active = active;
            p.Address = address;
            p.ChartOfAccounts = new Dictionary<int, int>();
            p.ChartOfAccounts[rentindex1] = 1001;
            p.RentTypes.Add(rent1);
            p.LegalName = legalName;
            p.Name = name;
            p.AddRentType(rent2);

            p.Save();

            //Load the property from the database;
            p = new QuickPM.Property(2);
            Assert.AreEqual(address, p.Address);
            Assert.AreEqual(active, p.Active);
            Assert.AreEqual(p.ChartOfAccounts[rentindex1], chartOfAccount);
            Assert.AreEqual(p.RentTypes[0], rent1);
            Assert.AreEqual(legalName, p.LegalName);
            Assert.AreEqual(name, p.Name);
        }
Пример #3
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;
     }
 }
Пример #4
0
 protected void ButtonSubmit_Click(object sender, EventArgs e)
 {
     string rentTypeName = TextBoxName.Text.Trim();
     int rentTypeIndex = Int32.Parse(Request["RentNum"]);
     int chartOfAccount = 0;
     if (TextBoxChartOfAccount.Text.Trim() != "")
     {
         if (!Int32.TryParse(TextBoxChartOfAccount.Text, out chartOfAccount))
         {
             Session["Error"] = "<font color=\"red\"> Please enter a number for the chart of account</font>";
             return;
         }
     }
     QuickPM.Property property = new QuickPM.Property(Int32.Parse(Request["PropertyId"]));
     if (property.RentTypes.IndexOf(rentTypeName) != -1 && rentTypeName != property.RentTypes[rentTypeIndex])
     {
         Session["Error"] = "<font color=\"red\"> That name is already taken</font>";
         return;
     }
     if (!QuickPM.Property.ValidRentType(rentTypeName))
     {
         Session["Error"] = "<font color=\"red\">Please only use letters, numbers, and % for the name</font>";
         return;
     }
     property.RentTypes[rentTypeIndex] = rentTypeName;
     property.ChartOfAccounts[rentTypeIndex] = chartOfAccount;
     property.Save();
     Response.Redirect("PropertyPage.aspx?PropertyId=" + property.Id);
 }
Пример #5
0
 protected QuickPM.Property GetProperty()
 {
     if (property == null)
     {
         property = new QuickPM.Property(PropertyId);
     }
     return property;
 }
Пример #6
0
        public static void CreateProperty(int number)
        {
            QuickPM.Property p = new QuickPM.Property(number);
            p.Active = true;
            p.RentTypes.Add("Rent");

            p.ChartOfAccounts.Add(p.RentTypes.IndexOf("Rent"), 1);
            p.Name = "Property #1";
            p.Save();
        }
Пример #7
0
        public void AddRentType()
        {
            QuickPM.Property p = new QuickPM.Property(propertyNumber);
            Assert.AreEqual(false, p.AddRentType(null));
            Assert.AreEqual(false, p.AddRentType(""));
            p.AddRentType("r");
            Assert.AreEqual(true, p.AddRentType("r"));

            Assert.AreEqual(false, p.AddRentType("^"));//It's an error to use ^ in the rent type name.
        }
Пример #8
0
 protected void LoadProperty()
 {
     string sPropertyId = Request["PropertyId"];
     if (sPropertyId == null)
     {
         return;
     }
     long PropertyId = long.Parse(sPropertyId);
     property = new QuickPM.Property(PropertyId);
 }
Пример #9
0
        public void AddDocument()
        {
            QuickPM.Property p = new QuickPM.Property(propertyNumber);

            QuickPM.Document doc = new QuickPM.Document();
            doc.Save();
            p.AddDocumentId(doc.Id);
            p.Save();
            p = new QuickPM.Property(propertyNumber);
            Assert.AreEqual(p.DocumentIds[0], doc.Id);
        }
Пример #10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         QuickPM.Property property = new QuickPM.Property(Int32.Parse(Request["PropertyId"]));
         int rentTypeIndex = Int32.Parse(Request["RentNum"]);
         if (property.ChartOfAccounts.ContainsKey(rentTypeIndex))
         {
             TextBoxChartOfAccount.Text = property.ChartOfAccounts[rentTypeIndex].ToString();
         }
         TextBoxName.Text = property.RentTypes[rentTypeIndex];
     }
 }
Пример #11
0
 protected void DropDownListTenants_IndexChanged(object sender, EventArgs e)
 {
     string tenantId = DropDownListTenants.SelectedValue;
     DropDownListRentTypes.Items.Clear();
     QuickPM.Property property = new QuickPM.Property(QuickPM.Util.GetPropertyId(tenantId));
     for (int i = 0; i < property.RentTypes.Count; i++)
     {
         DropDownListRentTypes.Items.Add(new ListItem(property.RentTypes[i], i.ToString()));
     }
     if (DropDownListRentTypes.Items.Count > 0)
     {
         DropDownListRentTypes.Items[0].Selected = true;
     }
 }
Пример #12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     long id = 0;
     if (Request["PropertyId"] != null && long.TryParse(Request["PropertyId"], out id))
     {
         List<string> tenantIds = new QuickPM.Property(id).GetTenantIds();
         List<object> places = new List<object>();
         foreach (string tenantId in tenantIds)
         {
             places.Add(new QuickPM.Tenant(tenantId));
         }
         ((Maps_MapControl)Map).Places = places;
     }
 }
Пример #13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string sProp = Request["PropertyId"];
        if (sProp == null)
        {
            return;
        }
        int pNum;
        if (!Int32.TryParse(sProp, out pNum))
        {
            return;
        }
        property = new QuickPM.Property(pNum);
        GetUnits();

        if (Request.Form["__EVENTTARGET"] == "DeleteUnit")
        {
            DeleteUnit(Request.Form["__EVENTARGUMENT"]);
        }

        if (!IsPostBack)
        {
            DropDownListTenant.Items.Add(new ListItem("None", ""));
            foreach (string tenantId in property.GetTenantIds())
            {
                QuickPM.Tenant tenant = new QuickPM.Tenant(tenantId);
                string text = "" + tenant.TenantId + " " + tenant.Name;
                //text = tenant.Name;
                text = text.Length > 20 ? text.Substring(0, 20) : text;
                DropDownListTenant.Items.Add(new ListItem(text, tenant.TenantId));
            }
        }
        bool canWrite = property.ACL.CanWrite(QuickPM.Database.GetUserId());
        ButtonAdd.Visible = canWrite;
        ButtonAdd.Enabled = canWrite;

        DropDownListTenant.Visible = canWrite;
        TextBoxUnitNumber.Visible = canWrite;
        TextBoxSqFt.Visible = canWrite;
        TextBoxAreaSize.Visible = canWrite;
        RadioButtonListHasOutside.Visible = canWrite;
        TextBoxSqFtOutside.Visible = canWrite;
        TextBoxOutsideAreaSize.Visible = canWrite;
        TextBoxNotes.Visible = canWrite;

        if (!canWrite)
        {
            QuickPMWebsite.AppCode.DisableControls.DisableTextBoxControls(Page);
        }
    }
Пример #14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     all = CheckBoxInactive.Checked;
     long propertyId = 0;
     if (Request["PropertyId"] == null || !long.TryParse(Request["PropertyId"], out propertyId))
     {
         property = new QuickPM.Property();
     }
     else
     {
         property = new QuickPM.Property(propertyId);
     }
     bool canWrite = property.ACL.CanWrite(QuickPM.Database.GetUserId());
     LinkButtonAddTenant.Visible = canWrite;
     LinkButtonAddTenant.Enabled = canWrite;
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            QuickPMWebsite.DatabaseSettings.UpdateDatabaseConnectionString(HttpContext.Current.Profile, Request);
            long propertyId;
            if (!long.TryParse(Request["PropertyId"], out propertyId))
            {
                return;
            }
            QuickPM.Property property = new QuickPM.Property(propertyId);

            /*string fileName = Request.PhysicalApplicationPath + "/App_Data/Tmp/" + "RentRoll.pdf";*/
            //System.IO.FileStream file = new System.IO.FileStream(fileName, System.IO.FileMode.Create);

            string tenantContactInformation = QuickPMWebsite.ContactInformationCsv.GenerateContactInformationCsv(property.Id, false, new QuickPM.Period(DateTime.Today.Year, DateTime.Today.Month));

            Response.Clear();
            Response.AddHeader("Content-Disposition", "attachment; filename=" + "TenantContactInformation.csv");
            Response.ContentType = "application/octet-stream";
            Response.Write(tenantContactInformation);
            Response.End();
        }
Пример #16
0
 protected void Page_Load(object sender, EventArgs e)
 {
     QuickPMWebsite.DatabaseSettings.UpdateDatabaseConnectionString(HttpContext.Current.Profile, this.Request);
     if (Request["PropertyId"] != null)
     {
         int number;
         if (Int32.TryParse(Request["PropertyId"], out number))
         {
             property = new QuickPM.Property(number);
         }
     }
     if (!IsPostBack)
     {
         for (int year = DateTime.Today.Year - 5; year <= DateTime.Today.Year + 5; year++)
         {
             ListItem item = new ListItem(year.ToString());
             item.Selected = (year == DateTime.Today.Year + 1);
             DropDownListBeginYear.Items.Add(item);
             DropDownListEndYear.Items.Add(item);
         }
         DropDownListEndMonth.SelectedValue = "December";
     }
 }
    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"]);
        }
    }
Пример #18
0
 public void CompareProperties()
 {
     QuickPM.Property p = new QuickPM.Property(propertyNumber);
     QuickPM.Property p2 = new QuickPM.Property(propertyNumber + 1);
     Assert.AreEqual(-1, QuickPM.Property.Compare(p, p2));
 }
Пример #19
0
 protected void Page_Load(object sender, EventArgs e)
 {
     QuickPM.Property property = new QuickPM.Property(GetPropertyId());
     LinkButtonAddWorkOrder.Visible = property.ACL.CanWrite(QuickPM.Database.GetUserId());
 }
Пример #20
0
    private void LoadProperty()
    {
        if (PropertyList.SelectedValue == "")
        {
            return;
        }
        int PropertyId = Int32.Parse(PropertyList.SelectedValue);
        property = new QuickPM.Property(PropertyId);

        property = new QuickPM.Property(PropertyId);
    }
Пример #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (QuickPM.Util.GetPropertyIds().Length == 0)
            {
                return;
            }

            long iPropertyId = QuickPM.Util.GetPropertyIds()[0];

            if (Request["PropertyId"] != null)
            {
                Int64.TryParse(Request["PropertyId"], out iPropertyId);
            }

            if (!IsPostBack)
            {
                foreach (int PropertyId in QuickPM.Util.GetPropertyIds())
                {
                    QuickPM.Property p = new QuickPM.Property(PropertyId);
                    ListItem item = new ListItem(p.Name + " (#" + PropertyId + ")", p.Id.ToString());
                    item.Selected = p.Id == iPropertyId;
                    DropDownListProperty.Items.Add(item);
                }
                ListItem it = new ListItem("Other", "-1");
                it.Selected = iPropertyId == -1;
                DropDownListProperty.Items.Add(it);

            }
            string sPropertyId = DropDownListProperty.SelectedValue;
            if (sPropertyId == null)
            {
                return;
            }
            long pNumber;
            if (!long.TryParse(sPropertyId, out pNumber))
            {
                return;
            }
            this.PropertyId = pNumber;
        }
Пример #22
0
        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);
        }
Пример #23
0
 public void Setters()
 {
     QuickPM.Property p = new QuickPM.Property();
     p.Number = 1;
     p.DocumentIds = new List<long>();
     p.RemitInfoId = p.Number;
     List<string> rentTypes = new List<string>(new string[] { "Rent"});
     p.RentTypes = rentTypes;
     rentTypes.Add("^");
     try
     {
         p.RentTypes = rentTypes;
     }
     catch (Exception e)
     {
         if (e.Message != "Invalid rent type.")
         {
             throw e;
         }
     }
 }
Пример #24
0
        public void GetDocumentIds()
        {
            QuickPM.Property p = new QuickPM.Property(propertyNumber);
            Assert.AreEqual(0, p.DocumentIds.Count);

            QuickPM.Document doc = new QuickPM.Document();

            doc.Save();
            p.DocumentIds.Add(doc.Id);
            p.Save();
            p = new QuickPM.Property(p.Number);
            Assert.AreEqual(1, p.DocumentIds.Count);
            Assert.AreEqual(doc.Id, p.DocumentIds[0]);
            Assert.AreEqual(doc.Id, p.GetDocumentIds()[0]);

            p.RemoveDocumentId(doc.Id);
            p.Save();
            p = new QuickPM.Property(p.Number);
            Assert.AreEqual(0, p.DocumentIds.Count);
        }
Пример #25
0
        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);*/
        }
Пример #26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        QuickPMWebsite.DatabaseSettings.UpdateDatabaseConnectionString(HttpContext.Current.Profile, Request);
        if (IsPostBack)
        {
            return;
        }
        int year = DateTime.Now.Year;
        for (int y = year - 5; y <= year + 5; y++)
        {
            ListItem item = new ListItem(y.ToString());

            if ((y == DateTime.Now.Year && DateTime.Today.Month < 12) || (y == DateTime.Now.Year + 1 && DateTime.Today.Month == 12))
            {
                item.Selected = true;
            }
            DropDownListYear.Items.Add(item);
        }

        DropDownListMonth.SelectedIndex = DateTime.Today.Month < 12 ? DateTime.Today.Month : 0;

        long[] propertyIds = QuickPM.Util.GetPropertyIds();
        foreach (int propertyId in propertyIds)
        {
            QuickPM.Property property = new QuickPM.Property(propertyId);
            DropDownListPropertyId.Items.Add(new ListItem(property.Name + " (#" + propertyId + ")", propertyId.ToString()));
        }
        if (DropDownListPropertyId.Items.Count > 0)
        {
            DropDownListPropertyId.Items[0].Selected = true;
        }
    }
Пример #27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        QuickPMWebsite.DatabaseSettings.UpdateDatabaseConnectionString(HttpContext.Current.Profile, Request);

        if (QuickPM.Util.GetPropertyIds().Length == 0)
        {
            return;
        }

        long iPropertyId = QuickPM.Util.GetPropertyIds()[0];
        this.PropertyId = iPropertyId;

        if (Request["PropertyId"] != null)
        {
            if(long.TryParse(Request["PropertyId"], out iPropertyId)){
                this.PropertyId = iPropertyId;
            }

        }

        if (!IsPostBack)
        {
            foreach (int PropertyId in QuickPM.Util.GetPropertyIds())
            {
                QuickPM.Property p = new QuickPM.Property(PropertyId);
                ListItem item = new ListItem(p.Name + " (#" + PropertyId + ")", p.Id.ToString());
                if (p.Id == iPropertyId)
                {
                    item.Selected = true;
                }
                DropDownListProperty.Items.Add(item);
            }
        }
        period = null;
        period = GetCurrentPeriod();
            QuickPM.Property pp = new QuickPM.Property(this.PropertyId);
            if (DropDownListTenant.Items.Count == 0 || QuickPM.Util.GetPropertyId(DropDownListTenant.Items[0].Value) != pp.Id)
            {
                DropDownListTenant.Items.Clear();
                foreach (string tenantId in pp.GetTenantIds())
                {
                    QuickPM.Tenant t = new QuickPM.Tenant(tenantId);
                    string PropertyId = QuickPM.Util.GetPropertyId(t.TenantId).ToString();
                    PropertyId = PropertyId.Length < 2 ? "0" + PropertyId : PropertyId;
                    string tenantNumber = t.TenantId.Split(new char[] { '-' })[1];

                    DropDownListTenant.Items.Add(new ListItem(t.GetShortName() + " (#" + PropertyId + "-" + tenantNumber + ")", t.TenantId));
                }
                DropDownListTenant.Items.Add(new ListItem("(" + pp.Name + ")", pp.Id.ToString()));

            }

            if (Request.Form["__EVENTTARGET"] == "DepositDateChanged")
            {
                DepositDateChanged(Request.Form["__EVENTARGUMENT"]);
            }

            if (Request.Form["__EVENTTARGET"] == "AddDepositEntry")
            {
                AddDepositEntry(Request.Form["__EVENTARGUMENT"]);
            }

            if (Request.Form["__EVENTTARGET"] == "DeleteDeposit")
            {
                DeleteDeposit(Request.Form["__EVENTARGUMENT"]);
            }

            if (Request.Form["__EVENTTARGET"] == "DeleteDepositEntry")
            {
                DeleteDepositEntry(Request.Form["__EVENTARGUMENT"]);
            }

            if (Request.Form["__EVENTTARGET"] == "ChangeQuickBooksImported")
            {
                ChangeQuickBooksImported(Request.Form["__EVENTARGUMENT"]);
            }

            deposits = QuickPM.Deposit.GetDeposits(this.PropertyId, period.Year, period.Month);

            if (Request.Form["__EVENTTARGET"] == "FinishDeposit")
            {
                FinishDeposit(Request.Form["__EVENTARGUMENT"]);
            }

        //if(IsPostBack && period != null)
    }
Пример #28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        QuickPMWebsite.DatabaseSettings.UpdateDatabaseConnectionString(HttpContext.Current.Profile, this.Request);
        if (Request["PropertyId"] != null)
        {
            int number;
            if (Int32.TryParse(Request["PropertyId"], out number))
            {
                property = new QuickPM.Property(number);
            }
        }
        if (Request["EBId"] == null)
        {
            return;
        }
        eb = new QuickPM.ExpenseList(new Guid(Request["EBId"]));

        if (!IsPostBack)
        {
            Session["BudgetExpenses"] = GenerateBudgetExpenses();
            Session["BudgetIncome"] = GenerateBudget();
        }
    }
Пример #29
0
    protected void ButtonGenerateChart_Click(object sender, EventArgs e)
    {
        moneyReceived = new List<decimal>();
        tenantPaid = new Dictionary<string, decimal>();
        months = new List<long>();
        int beginYear = Convert.ToInt32(DropDownListBeginYear.SelectedValue);
        int beginMonth = QuickPM.Util.ConvertMonthToInt(DropDownListBeginMonth.SelectedValue);
        int endYear = Convert.ToInt32(DropDownListEndYear.SelectedValue);
        int endMonth = QuickPM.Util.ConvertMonthToInt(DropDownListEndMonth.SelectedValue);
        QuickPM.Period beginPeriod = new QuickPM.Period(beginYear, beginMonth);
        QuickPM.Period endPeriod = new QuickPM.Period(endYear, endMonth);
        if (endMonth == beginMonth && endYear == beginYear)
        {
            endPeriod = endPeriod.AddMonth();
        }
        int property;
        if (Request["PropertyId"] == null)
        {
            string selectedValue = this.PropertyList.SelectedValue;
            string[] tmp = selectedValue.Split(new char[] { ' ' });
            property = Convert.ToInt32(tmp[0]);
        }
        else
        {
            property = Convert.ToInt32(Request["PropertyId"]);
        }
        this.property = new QuickPM.Property(property);

        for (QuickPM.Period p = beginPeriod; p <= endPeriod; p = p.AddMonth())
        {
            months.Add((new DateTime(p.Year, p.Month, 1).Ticks) - (new DateTime(1970, 1, 1).Ticks));
            decimal received = 0;

            List<string> profileIds = new List<string>(QuickPM.Database.GetPropertyTenantIds(this.property.Id, p));
            foreach (string profileId in profileIds)
            {
                QuickPM.Tenant tenant = new QuickPM.Tenant(profileId);
                string shortName = tenant.GetShortName();
                List<QuickPM.Check> checks = QuickPM.Database.GetChecks(profileId, p);
                List<QuickPM.NSFCheck> nsfChecks = QuickPM.Database.GetNSFChecks(profileId, p);
                foreach (QuickPM.Check c in checks)
                {
                    received += c.Amount;
                    if (!tenantPaid.ContainsKey(shortName))
                    {
                        tenantPaid[shortName] = 0m;
                    }
                    tenantPaid[shortName] += c.Amount;
                }
                foreach (QuickPM.NSFCheck n in nsfChecks)
                {
                    received += n.Amount;
                    if (!tenantPaid.ContainsKey(shortName))
                    {
                        tenantPaid[shortName] = 0m;
                    }
                    tenantPaid[shortName] += n.Amount;
                }

            }
            moneyReceived.Add(received);
        }
        CreateTenantList();
    }
Пример #30
0
    protected void ButtonEmail_Click(object sender, EventArgs e)
    {
        QuickPM.Property property = new QuickPM.Property(GetPropertyId());
        List<string> tenantIds = property.GetTenantIds();
        string html = "<table id=\"email\" cellspacing=\"0px\" cellpadding=\"10px\">" + @"
            <tr>
                <th>Tenant Name/Id</th><th>Email</th><th>Status</th>
            </tr>
        ";
        int year = Int32.Parse(DropDownListYear.SelectedValue);
        int month = QuickPM.Util.ConvertMonthToInt(DropDownListMonth.SelectedValue);

        foreach (string tenantId in tenantIds)
        {
            QuickPM.Tenant tenant = new QuickPM.Tenant(tenantId);
            string email = tenant.BillingEmail;

            string status = "";

            if (email.Trim() != "")
            {
                PrintTenantBilling.url = "http://cmd.quickpm.net" + "/Public/Tenant.aspx";
                PDFjet.NET.PDF document = PrintBillings.GetPdf(tenantId, year, month);
                QuickPM.RemitInfo remitInfo = new QuickPM.RemitInfo(tenant.Property);
                string filePath = Request.PhysicalApplicationPath + "\\App_Data\\tmpbilling.pdf";
                document.Save(filePath);
                System.IO.Stream stream = new System.IO.FileStream(filePath, System.IO.FileMode.Open);
                status = "Sent";
                string questions = remitInfo.Email.Trim() != "" ? "\r\nIf you have a question about your billing statement please email " + remitInfo.Email : "";
                string message = "Please see the attached pdf for your billing statement.\r\nThis is an automated message, do not respond. " + questions;
                try
                {
                    SendEmail.Send(email, new QuickPM.Period(year, month).ToString() + " " + "Billing Statement", message,
                        Request.PhysicalApplicationPath, stream, "BillingStatement.pdf");
                }
                catch (Exception ex)
                {
                    if (ex is System.Net.Mail.SmtpFailedRecipientException)
                    {
                        status = "Failed to send email";
                    }
                    else if (ex is System.Net.Mail.SmtpFailedRecipientsException)
                    {
                        status = "Failed to send email";
                    }
                    else
                    {
                        status = "Unknown error";
                    }

                }finally
                {
                    stream.Close();
                    System.IO.File.Delete(filePath);
                }
            }

            html += "<tr>";
            string billingemail = tenant.BillingEmail.Trim() != "" ? tenant.BillingEmail.Trim() : "No Email";
            html += "<td>" + "<a href=" + QuickPMWebsite.AppCode.Link.LinkTo(tenant, this, HttpContext.Current.Profile.IsAnonymous) + ">" + tenant.Name + " (#" + tenantId + ")" + "</a>" + "</td>" +
                    "<td>" + billingemail + "</td>" +
                    "<td>" + status + "</td>";
            html += "</tr>";

        }
        html += "</table>";
        Session["email"] = html;
    }