Exemple #1
0
 protected string GetAccountDetailLink(Account a)
 {
     return "AccountDetails.aspx?id=" + a.accountID.ToString();
 }
Exemple #2
0
 protected string GetAccountPrimaryContactLink(Account a)
 {
     return string.Format("<a href='ContactDetails.aspx?id={0}'>{1} {2}</a>", a.Contact.contactID.ToString(), a.Contact.firstName, a.Contact.lastName);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                // add account setup
                LoadDropdowns();
                ButtonAccountAction.Text = "Add Account";
                ButtonAccountAction.Click += ButtonAccountActionAdd_Click;
                pnlAddresses.Visible = false;
                return;
            }

            int i = int.Parse(Request.QueryString["id"] != null ? Request.QueryString["id"] : "0");
            accountA = theGateContext.Accounts.FirstOrDefault(a => a.accountID == i);

            if (accountA == null)
            {
                ShowError("Account not found.");
                PanelAccountForm.Visible = false;
                return;
            }

            ButtonAccountAction.Text = "Update Account";
            ButtonAccountAction.Click += ButtonAccountActionUpdate_Click;

            if (Page.IsPostBack)
                return;

            LoadDropdowns();

            // account text fields
            txtAccountName.Text = accountA.accountName;
            txtAccountNumber.Text = accountA.accountNumber;
            txtWebsite.Text = accountA.website;
            txtGeneralEmail.Text = accountA.generalEmail;
            txtAccountPhone.Text = accountA.phone;
            txtAccountFax.Text = accountA.fax;
            ddlPrimaryContact.SelectedValue = accountA.primaryContact.ToString();

            if (accountA.address != null)
            {
                pnlShippingAddress.Visible = true;
                buttonAddShippingAddress.Visible = false;
                txtShippingAddress1.Text = accountA.AddressA.line1;
                txtShippingAddress2.Text = accountA.AddressA.line2;
                txtShippingCity.Text = accountA.AddressA.city;
                ddlShippingProvince.SelectedValue = accountA.AddressA.state;
                txtShippingPostalCode.Text = accountA.AddressA.zipcode;
                ckbSameAsShipping.Enabled = true;
            }

            if (accountA.billingAddress != null)
            {
                pnlBillingAddress.Visible = true;
                buttonAddBillingAddress.Visible = false;
                if (accountA.address == accountA.billingAddress)
                {
                    ckbSameAsShipping.Checked = true;
                    pnlBillingAddressDetails.Enabled = false;
                }
                else
                {
                    txtBillingAddress1.Text = accountA.BillingAddressA.line1;
                    txtBillingAddress2.Text = accountA.BillingAddressA.line2;
                    txtBillingCity.Text = accountA.BillingAddressA.city;
                    ddlBillingProvince.SelectedValue = accountA.BillingAddressA.state;
                    txtBillingPostalCode.Text = accountA.BillingAddressA.zipcode;
                }
            }

            if (accountA.address == accountA.billingAddress)
            {
                ckbSameAsShipping.Checked = true;
                pnlBillingAddressDetails.Enabled = false;
            }

            if (Page.IsPostBack)
                return;
        }