private void BindData()
        {
            Affiliate affiliate = AffiliateManager.GetAffiliateByID(this.AffiliateID);

            if (affiliate != null)
            {
                this.lblAffiliateID.Text    = affiliate.AffiliateID.ToString();
                this.txtFirstName.Text      = affiliate.FirstName;
                this.txtLastName.Text       = affiliate.LastName;
                this.txtMiddleName.Text     = affiliate.MiddleName;
                this.txtPhoneNumber.Text    = affiliate.PhoneNumber;
                this.txtEmail.Text          = affiliate.Email;
                this.txtFaxNumber.Text      = affiliate.FaxNumber;
                this.txtCompany.Text        = affiliate.Company;
                this.txtAddress1.Text       = affiliate.Address1;
                this.txtAddress2.Text       = affiliate.Address2;
                this.txtCity.Text           = affiliate.City;
                this.txtStateProvince.Text  = affiliate.StateProvince;
                this.txtZipPostalCode.Text  = affiliate.ZipPostalCode;
                this.pnlAffiliateID.Visible = true;
                CommonHelper.SelectListItem(this.ddlCountry, affiliate.CountryID);
                this.cbActive.Checked = affiliate.Active;
            }
            else
            {
                this.pnlAffiliateID.Visible = false;
            }
        }
Exemple #2
0
        private void BindData()
        {
            Affiliate affiliate = AffiliateManager.GetAffiliateByID(this.AffiliateID);

            if (affiliate != null)
            {
                gvAffiliateOrders.DataSource = OrderManager.GetOrdersByAffiliateID(this.AffiliateID);
                gvAffiliateOrders.DataBind();
            }
            else
            {
                Response.Redirect("Affiliates.aspx");
            }
        }
        public Affiliate SaveInfo()
        {
            Affiliate affiliate = AffiliateManager.GetAffiliateByID(this.AffiliateID);

            if (affiliate != null)
            {
                affiliate = AffiliateManager.UpdateAffiliate(affiliate.AffiliateID, txtFirstName.Text, txtLastName.Text, txtMiddleName.Text,
                                                             txtPhoneNumber.Text, txtEmail.Text, txtFaxNumber.Text, txtCompany.Text,
                                                             txtAddress1.Text, txtAddress2.Text, txtCity.Text, txtStateProvince.Text, txtZipPostalCode.Text,
                                                             int.Parse(this.ddlCountry.SelectedItem.Value), affiliate.Deleted, cbActive.Checked);
            }
            else
            {
                affiliate = AffiliateManager.InsertAffiliate(txtFirstName.Text, txtLastName.Text, txtMiddleName.Text,
                                                             txtPhoneNumber.Text, txtEmail.Text, txtFaxNumber.Text, txtCompany.Text,
                                                             txtAddress1.Text, txtAddress2.Text, txtCity.Text, txtStateProvince.Text, txtZipPostalCode.Text,
                                                             int.Parse(this.ddlCountry.SelectedItem.Value), false, cbActive.Checked);
            }

            return(affiliate);
        }
        protected void CheckAffiliate()
        {
            Affiliate affiliate = AffiliateManager.GetAffiliateByID(CommonHelper.QueryStringInt("AffiliateID"));

            if (affiliate != null && affiliate.Active)
            {
                if (NopContext.Current.User == null)
                {
                    HttpCookie affiliateCookie = HttpContext.Current.Request.Cookies.Get("NopCommerce.AffiliateID");
                    if (affiliateCookie == null)
                    {
                        affiliateCookie = new HttpCookie("NopCommerce.AffiliateID");
                    }

                    affiliateCookie.Value   = affiliate.AffiliateID.ToString();
                    affiliateCookie.Expires = DateTime.Now.AddDays(10.0);
                    HttpContext.Current.Response.Cookies.Set(affiliateCookie);
                }
                else if (NopContext.Current.User.AffiliateID != affiliate.AffiliateID)
                {
                    NopContext.Current.User = CustomerManager.SetAffiliate(NopContext.Current.User.CustomerID, affiliate.AffiliateID);
                }
            }
        }