예제 #1
0
    protected void SaveTenant()
    {
        tenant.BillSame = RadioButtonBillingSame.Checked;
        tenant.BillName = TextBoxBillName.Text.Trim();
        tenant.BillAddress = TextBoxBillingAddress.Text.Trim();
        tenant.BillCity = TextBoxBillingCity.Text.Trim();
        tenant.BillState = TextBoxBillingState.Text.Trim();
        tenant.BillZip = TextBoxBillingZip.Text.Trim();
        tenant.Save();
        long currentUserId = QuickPM.Database.GetUserId();
        if (tenant.BillingKeyContactId == -1)
        {

            bContact = new QuickPM.Person();
            bContact.Save();
            tenant.BillingKeyContactId = bContact.Id;
            tenant.Save();
        }
        else
        {
            QuickPM.Database.SetUserId(QuickPM.AccessControlList.ROOT_USERID);

            bContact = new QuickPM.Person(tenant.BillingKeyContactId);
        }
        UpdateContact(bContact, (Tenant_PersonControl)BillingContact);
        QuickPM.Database.SetUserId(QuickPM.AccessControlList.ROOT_USERID);
        bContact.Save();
        QuickPM.Database.SetUserId(currentUserId);
    }
예제 #2
0
    public bool SaveTenant()
    {
        string tenantid = Request["TenantId"];
        if (addTenant)
        {
            tenantid = TextBoxTenantId.Text;
        }
        if (tenantid == null)
        {
            return false;
        }
        if (!QuickPM.Util.TryFormatTenantId(tenantid, out tenantid))
        {
            Session["Error"] = "<font color=\"red\">" + "Invalid tenant id" + "</font>";
            return false;
        }

        long property = QuickPM.Util.GetPropertyId(tenantid);
        long[] PropertyIds = QuickPM.Util.GetPropertyIds(true);
        bool hasProperty = false;
        foreach (int p in PropertyIds)
        {
            if (p == property)
            {
                hasProperty = true;
                break;
            }
        }
        if (!hasProperty)
        {
            Session["Error"] = "<font color=\"red\">" + "Property number " + property.ToString() + " does not exist" + "</font>";
            return false;
        }

        QuickPM.Tenant tmp = new QuickPM.Tenant(tenantid);
        if (!tmp.NewTenant && addTenant)
        {
            Session["Error"] = "<font color=\"red\">" + "Tenant already exists" + "</font>";
            return false;
        }

        if (!addTenant)
        {
            tenant = new QuickPM.Tenant(tenantid);
        }
        else
        {
            tenant = new QuickPM.Tenant();
            tenant.TenantId = tenantid;
            QuickPM.Person billingContact;
            billingContact = new QuickPM.Person();
            billingContact.Save();
            tenant.BillingKeyContactId = billingContact.Id;
        }

        //keyContact = contacts[0];
        if (RadioButtonActive.Checked)
        {
            tenant.EndDate = DateTime.MaxValue;
        }
        else
        {
            if (tenant.EndDate >= DateTime.Today)
            {
                tenant.EndDate = DateTime.Today;
            }
        }
        tenant.City = TextBoxCity.Text;
        //UpdateContact(keyContact, KeyContact1);
        tenant.Address = TextBoxLocation.Text;
        tenant.Name = TextBoxName.Text;
        tenant.Phone = TextBoxPhone.Text;
        tenant.State = TextBoxState.Text;
        tenant.Zip = TextBoxZip.Text;

        //keyContact.Save();
        tenant.BillingEmail = TextBoxBillingEmail.Text;
        tenant.Save();
        Session["Message"] = "Saved";
        LoadTenant();
        return true;
    }