Exemplo n.º 1
0
    protected void CreateCertificate()
    {
        if (!DataValidation())
        {
            return;
        }

        MsgErr(true);

        try
        {
            var curCurrency = CurrencyService.CurrentCurrency;
            Certificate = new GiftCertificate
            {
                CertificateCode    = lblCertificateCode.Text,
                FromName           = txtFromName.Text,
                ToName             = txtToName.Text,
                Paid               = chkPaid.Checked,
                Used               = chkUsed.Checked,
                Enable             = chkEnable.Checked,
                Type               = rbtnEmail.Checked ? CertificatePostType.Email : CertificatePostType.Mail,
                Sum                = Convert.ToDecimal(txtSum.Text),
                CertificateMessage = txtMessage.Text,
                CurrencyCode       = curCurrency.Symbol,
                CurrencyValue      = curCurrency.Value,
                FromEmail          = txtFromEmail.Text
            };
            if (rbtnEmail.Checked)
            {
                Certificate.Email = txtEmail.Text;
            }
            else
            {
                Certificate.Country = cboCountry.SelectedItem.Text;
                Certificate.Zone    = MultiViewRegion.ActiveViewIndex == 0 ? cboRegion.SelectedItem.Text : txtState.Text;
                Certificate.City    = txtCity.Text;
                Certificate.Zip     = txtZip.Text;
                Certificate.Address = txtAddress.Text;
            }
            if (Certificate.Paid && !CustomerSession.CurrentCustomer.IsVirtual)
            {
                GiftCertificateService.SendCertificateMails(Certificate);
            }

            GiftCertificateService.AddCertificate(Certificate);
        }
        catch (Exception ex)
        {
            MsgErr(ex.Message + " Create Certificate error");
            Debug.LogError(ex);
        }
    }
Exemplo n.º 2
0
    protected int CreateCertificate()
    {
        if (!DataValidation())
        {
            return(0);
        }

        var curCurrency = CurrencyService.CurrentCurrency;
        var certificate = new GiftCertificate
        {
            CertificateCode    = GiftCertificateService.GenerateCertificateCode(),
            ToName             = txtTo.Text,
            FromName           = txtFrom.Text,
            Sum                = Convert.ToDecimal(txtSum.Text),
            CertificateMessage = txtMessage.Text,
            Type               = rbtnEmail.Checked ? CertificatePostType.Email : CertificatePostType.Mail,
            Enable             = true,
            CurrencyCode       = curCurrency.Symbol,
            CurrencyValue      = curCurrency.Value,
            FromEmail          = CustomerSession.CurrentCustomer.RegistredUser ? CustomerSession.CurrentCustomer.EMail : string.Empty
        };

        if (rbtnEmail.Checked)
        {
            certificate.Email = txtEmail.Text;
        }
        else
        {
            certificate.Country = cboCountry.SelectedItem.Text;
            certificate.Zone    = txtState.Text;
            certificate.City    = txtCity.Text;
            certificate.Zip     = txtZip.Text;
            certificate.Address = txtAdress.Text;
        }
        var certificateId = GiftCertificateService.AddCertificate(certificate);

        return(certificateId);
    }