Пример #1
0
        private void CreateXml()
        {
            DocumentCached doc = new DocumentCached();

            doc.CustomerCode = "ABCDW";
            doc.DocDate      = DateTime.Now;
            doc.Comment      = "testing comment";
            doc.VLCompany    = "VLB";

            DocumentLineCached line = new DocumentLineCached();

            line.Currency      = "EUR";
            line.ItemCode      = "A100";
            line.LineNum       = 2;
            line.Price         = 23;
            line.Quantity      = 200;
            line.ShortText     = "Testline";
            line.UnitOfMeasure = "EU";

            doc.Lines.Add(line);

            DocumentLineCached line2 = new DocumentLineCached();

            line2.Currency      = "EUR";
            line2.ItemCode      = "B12300";
            line2.LineNum       = 3;
            line2.Price         = 57;
            line2.Quantity      = 450;
            line2.ShortText     = "Testline2";
            line2.UnitOfMeasure = "EU";

            doc.Lines.Add(line2);

            VanLeeuwen.Framework.Xml.XmlToObject.ObjectToXml(doc, @"D:\Test\DataProcessor_Outbox\SBO_SAPECC6_PROD\testxml_" + DateTime.Now.ToShortDateString() + ".xml");
        }
Пример #2
0
        protected void RadSaveButton_Click(object sender, EventArgs e)
        {
            DALPortalDataContext dc        = new DALPortalDataContext();
            certificateBundle    bundleOld = dc.certificateBundles.Where(c => c.businessPartnerId.Equals(bpId) && c.isActive.Equals(true)).SingleOrDefault();

            if (bundleOld != null)
            {
                bundleOld.isActive = false;
            }
            certificateBundle bundelNew = new certificateBundle();

            if (bundleOld != null)
            {
                bundelNew.previousCertQty  = bundleOld.actualCertQty;
                bundelNew.actualCertQty    = (Int32)creditsOrderTxtBox.Value + bundleOld.actualCertQty;
                bundelNew.orderedCertQty   = bundleOld.orderedCertQty + (Int32)creditsOrderTxtBox.Value;
                bundelNew.certificatePrice = bundleOld.certificatePrice;
            }
            else
            {
                bundelNew.previousCertQty  = 0;
                bundelNew.actualCertQty    = (Int32)creditsOrderTxtBox.Value;
                bundelNew.orderedCertQty   = (Int32)creditsOrderTxtBox.Value;
                bundelNew.certificatePrice = (decimal)7.50;
            }

            bundelNew.startDate  = DateTime.Now;
            bundelNew.expireDate = DateTime.Now.AddYears(1);

            bundelNew.isActive          = true;
            bundelNew.modelId           = 2;
            bundelNew.companyCode       = "ZW";
            bundelNew.businessPartnerId = bpId;

            businessPartner bpProps = dc.businessPartners.Where(c => c.businessPartnerId.Equals(bpId)).Select(c => c).SingleOrDefault();


            DocumentCached cashed = new DocumentCached();

            cashed.CustomerCode = bpProps.bpCode;
            cashed.VLCompany    = "ZW01";
            cashed.DocDate      = DateTime.Now;
            cashed.Comment      = "Certificate portal invoice";

            DocumentLineCached cashedLine = new DocumentLineCached();

            cashedLine.Currency      = "EUR";
            cashedLine.LineNum       = 1;
            cashedLine.ItemCode      = "C";
            cashedLine.Quantity      = (Int32)creditsOrderTxtBox.Value;
            cashedLine.UnitOfMeasure = "ST";
            cashedLine.Price         = (decimal)bundelNew.certificatePrice;
            cashedLine.ShortText     = creditsOrderTxtBox.Value + " ordered on " + DateTime.Now + ".";
            cashed.Lines.Add(cashedLine);
            dc.certificateBundles.InsertOnSubmit(bundelNew);

            dc.SubmitChanges();

            XmlToObject.ObjectToXml(cashed, HttpContext.Current.Server.MapPath(Path.Combine(@"~\Files\Outbox", "invoice " + DateTime.Now.Ticks.ToString() + ".xml")));


            MembershipUser membershipUser = Membership.GetUser();

            if (membershipUser != null)
            {
                String emailTemplate = HttpContext.Current.Server.MapPath(Path.Combine(@"~\Files\EmailTemplates", "OrderConfirmation.html"));

                StreamReader streamReader    = new StreamReader(emailTemplate);
                String       mailMessageBody = streamReader.ReadToEnd();

                String fromEmailAddress;
                String subject;
                String toEmailAddress;

                mailMessageBody = EmailClass.GetMailParams(mailMessageBody, out fromEmailAddress, out toEmailAddress, out subject);
                mailMessageBody = mailMessageBody.Replace("{Credits}", membershipUser.UserName);
                try
                {
                    MailMessage mailMessage = new MailMessage();
                    mailMessage.IsBodyHtml = true;
                    mailMessage.From       = new MailAddress(fromEmailAddress);
                    mailMessage.To.Add(membershipUser.UserName);
                    mailMessage.Subject = subject;
                    mailMessage.Body    = mailMessageBody;
                    SmtpClient smtpClient = new SmtpClient();
                    smtpClient.Send(mailMessage);
                }
                catch (Exception ex)
                {
                    // TODO: Create errorpage for user
                    Response.Redirect("~/Pages/OrderSuccess.aspx");
                }
            }



            Session["businessPartnerId"] = bpId;
            Response.Redirect("~/Pages/OrderSuccess.aspx");
        }