private void BindData()
        {
            Discount discount = DiscountManager.GetDiscountByID(this.DiscountID);

            if (discount != null)
            {
                CommonHelper.SelectListItem(this.ddlDiscountType, discount.DiscountTypeID);
                CommonHelper.SelectListItem(this.ddlDiscountRequirement, discount.DiscountRequirementID);
                this.txtName.Text                          = discount.Name;
                this.cbUsePercentage.Checked               = discount.UsePercentage;
                this.txtDiscountPercentage.Value           = discount.DiscountPercentage;
                this.txtDiscountAmount.Value               = discount.DiscountAmount;
                this.cStartDateButtonExtender.SelectedDate = discount.StartDate;
                this.cEndDateButtonExtender.SelectedDate   = discount.EndDate;
                this.cbRequiresCouponCode.Checked          = discount.RequiresCouponCode;
                this.txtCouponCode.Text                    = discount.CouponCode;

                CustomerRoleCollection customerRoles    = discount.CustomerRoles;
                List <int>             _customerRoleIDs = new List <int>();
                foreach (CustomerRole customerRole in customerRoles)
                {
                    _customerRoleIDs.Add(customerRole.CustomerRoleID);
                }
                CustomerRoleMappingControl.SelectedCustomerRoleIDs = _customerRoleIDs;
                CustomerRoleMappingControl.BindData();
            }
            else
            {
                List <int> _customerRoleIDs = new List <int>();
                CustomerRoleMappingControl.SelectedCustomerRoleIDs = _customerRoleIDs;
                CustomerRoleMappingControl.BindData();
            }
        }
        public Discount SaveInfo()
        {
            DateTime discountStartDate = DateTime.MinValue;
            DateTime discountEndDate   = DateTime.MinValue;

            if (!DateTime.TryParse(txtStartDate.Text, out discountStartDate))
            {
                throw new NopException("Start date is not set");
            }
            if (!DateTime.TryParse(txtEndDate.Text, out discountEndDate))
            {
                throw new NopException("End date is not set");
            }
            discountStartDate = DateTime.SpecifyKind(discountStartDate, DateTimeKind.Utc);
            discountEndDate   = DateTime.SpecifyKind(discountEndDate, DateTimeKind.Utc);

            Discount discount = DiscountManager.GetDiscountByID(this.DiscountID);

            if (discount != null)
            {
                discount = DiscountManager.UpdateDiscount(discount.DiscountID,
                                                          (DiscountTypeEnum)int.Parse(this.ddlDiscountType.SelectedItem.Value),
                                                          (DiscountRequirementEnum)int.Parse(this.ddlDiscountRequirement.SelectedItem.Value),
                                                          txtName.Text,
                                                          cbUsePercentage.Checked,
                                                          txtDiscountPercentage.Value,
                                                          txtDiscountAmount.Value,
                                                          discountStartDate,
                                                          discountEndDate,
                                                          cbRequiresCouponCode.Checked,
                                                          txtCouponCode.Text.Trim(),
                                                          discount.Deleted);

                foreach (CustomerRole customerRole in discount.CustomerRoles)
                {
                    CustomerManager.RemoveDiscountFromCustomerRole(customerRole.CustomerRoleID, discount.DiscountID);
                }
                foreach (int customerRoleID in CustomerRoleMappingControl.SelectedCustomerRoleIDs)
                {
                    CustomerManager.AddDiscountToCustomerRole(customerRoleID, discount.DiscountID);
                }
            }
            else
            {
                discount = DiscountManager.InsertDiscount((DiscountTypeEnum)int.Parse(this.ddlDiscountType.SelectedItem.Value),
                                                          (DiscountRequirementEnum)int.Parse(this.ddlDiscountRequirement.SelectedItem.Value),
                                                          txtName.Text,
                                                          cbUsePercentage.Checked,
                                                          txtDiscountPercentage.Value,
                                                          txtDiscountAmount.Value,
                                                          discountStartDate,
                                                          discountEndDate,
                                                          cbRequiresCouponCode.Checked,
                                                          txtCouponCode.Text.Trim(),
                                                          false);

                foreach (int customerRoleID in CustomerRoleMappingControl.SelectedCustomerRoleIDs)
                {
                    CustomerManager.AddDiscountToCustomerRole(customerRoleID, discount.DiscountID);
                }
            }

            return(discount);
        }