Ejemplo n.º 1
0
    protected void btnSend_Click(object sender, EventArgs e)
    {
        bool boolIsValidPast = true;

        boolIsValidPast &= IsValidText(txtName.Text);
        boolIsValidPast &= IsValidText(txtEmail.Text);
        boolIsValidPast &= IsValidText(txtPhone.Text);

        int quantity = 0;

        if (!Int32.TryParse(txtAmount.Text, out quantity) || (quantity < 1))
        {
            boolIsValidPast = false;
        }

        if (!ValidationHelper.IsValidEmail(txtEmail.Text.Trim()))
        {
            boolIsValidPast = false;
        }

        if (!CaptchaControl1.IsValid())
        {
            CaptchaControl1.TryNew();
            boolIsValidPast = false;
        }

        if (boolIsValidPast == false)
        {
            ShowMessage(Notify.NotifyType.Error, Resource.Client_Feedback_WrongData);
            return;
        }

        try
        {
            var orderByRequest = new OrderByRequest
            {
                ProductId   = product.ID,
                ProductName = product.Name,
                ArtNo       = product.ArtNo,
                Quantity    = quantity,
                UserName    = txtName.Text,
                Email       = txtEmail.Text,
                Phone       = txtPhone.Text,
                Comment     = txtComment.Text,
                IsComplete  = false,
                RequestDate = DateTime.Now
            };

            OrderByRequestService.AddOrderByRequest(orderByRequest);

            var clsParam = new ClsMailParamOnOrderByRequest
            {
                OrderByRequestId = orderByRequest.OrderByRequestId.ToString(CultureInfo.InvariantCulture),
                ArtNo            = product.ArtNo,
                ProductName      = product.Name,
                Quantity         = quantity.ToString(CultureInfo.InvariantCulture),
                UserName         = txtName.Text,
                Email            = txtEmail.Text,
                Phone            = txtPhone.Text,
                Comment          = txtComment.Text
            };

            string message = SendMail.BuildMail(clsParam);

            SendMail.SendMailNow(txtEmail.Text, Resource.Client_OrderByRequest_PreOrder, message, true);
            SendMail.SendMailNow(SettingsMail.EmailForOrders, Resource.Client_OrderByRequest_PreOrder, message, true);

            lblMessage.Text = Resource.Client_Feedback_MessageSent;
            MultiView1.SetActiveView(ViewResult);
        }
        catch (Exception ex)
        {
            Debug.LogError(ex);
            ShowMessage(Notify.NotifyType.Error, Resource.Client_Feedback_MessageError);
            MultiView1.SetActiveView(ViewResult);
        }
    }
Ejemplo n.º 2
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            bool boolIsValidPast = true;

            boolIsValidPast &= IsValidText(txtName.Text);
            boolIsValidPast &= IsValidText(txtEmail.Text);
            boolIsValidPast &= IsValidText(txtPhone.Text);

            float quantity = 0;

            if (!float.TryParse(txtAmount.Text, out quantity) || (quantity < 0))
            {
                boolIsValidPast = false;
            }

            if (!ValidationHelper.IsValidEmail(txtEmail.Text.Trim()))
            {
                boolIsValidPast = false;
            }

            if (!CaptchaControl1.IsValid())
            {
                CaptchaControl1.TryNew();
                boolIsValidPast = false;
            }

            if (boolIsValidPast == false)
            {
                CaptchaControl1.TryNew();
                ShowMessage(Notify.NotifyType.Error, Resource.Client_Feedback_WrongData);
                return;
            }

            try
            {
                var orderByRequest = new OrderByRequest
                {
                    OfferId     = offer.OfferId,
                    ProductId   = offer.Product.ID,
                    ProductName = offer.Product.Name,
                    ArtNo       = offer.ArtNo,
                    Quantity    = quantity,
                    UserName    = txtName.Text,
                    Email       = txtEmail.Text,
                    Phone       = txtPhone.Text,
                    Comment     = txtComment.Text,
                    IsComplete  = false,
                    RequestDate = DateTime.Now,
                    Options     = Options
                };

                OrderByRequestService.AddOrderByRequest(orderByRequest);


                IList <EvaluatedCustomOptions> listOptions = null;
                if (Options.IsNotEmpty())
                {
                    try
                    {
                        listOptions = CustomOptionsService.DeserializeFromXml(Options);
                    }
                    catch (Exception)
                    {
                        listOptions = null;
                    }
                }

                var mailTemplate =
                    new OrderByRequestMailTemplate(
                        orderByRequest.OrderByRequestId.ToString(CultureInfo.InvariantCulture), offer.ArtNo,
                        offer.Product.Name + " " + OrderService.RenderSelectedOptions(listOptions),
                        quantity.ToString(CultureInfo.InvariantCulture), txtName.Text, txtEmail.Text, txtPhone.Text,
                        txtComment.Text, offer.Color != null ? offer.Color.ColorName : string.Empty,
                        offer.Size != null ? offer.Size.SizeName : string.Empty);

                mailTemplate.BuildMail();

                SendMail.SendMailNow(txtEmail.Text, mailTemplate.Subject, mailTemplate.Body, true);
                SendMail.SendMailNow(SettingsMail.EmailForOrders, mailTemplate.Subject, mailTemplate.Body, true);

                lblMessage.Text = Resource.Client_Feedback_MessageSent;
                MultiView1.SetActiveView(ViewResult);
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
                ShowMessage(Notify.NotifyType.Error, Resource.Client_Feedback_MessageError);
                MultiView1.SetActiveView(ViewResult);
            }
        }