示例#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
        private Boolean ImportInvoice(String databaseName, DocumentCached invoice, out String documentNumber, out String errorMessage)
        {
            errorMessage   = String.Empty;
            documentNumber = String.Empty;

            try
            {
                IRfcFunction fReadTable = repo.CreateFunction("ZZBAPI_DEBIT_MEMO_REQUEST");
                fReadTable.SetValue("CUSTOMER", ("0000000" + invoice.CustomerCode).Right(10));
                fReadTable.SetValue("SALES_ORG", invoice.VLCompany);
                fReadTable.SetValue("PURCH_DATE", invoice.DocDate);
                fReadTable.SetValue("PURCH_NO_C", invoice.Comment);

                foreach (DocumentLineCached line in invoice.Lines)
                {
                    RfcStructureMetadata metaData         = dest.Repository.GetStructureMetadata("ZORDERLINE");
                    IRfcStructure        structConditions = metaData.CreateStructure();

                    structConditions.SetValue("ITM_NUMBER", ("0000" + line.LineNum.ToString() + "0").Right(6));
                    structConditions.SetValue("MATERIAL", line.ItemCode);                     // C => Certificate
                    structConditions.SetValue("TARGET_QTY", line.Quantity);
                    structConditions.SetValue("SALES_UNIT", line.UnitOfMeasure);
                    structConditions.SetValue("COND_VALUE", line.Price);
                    structConditions.SetValue("CURRENCY", line.Currency);
                    structConditions.SetValue("SHORT_TEXT", line.ShortText);

                    IRfcTable tblItems = fReadTable.GetTable("ORDERLINE");
                    tblItems.Append(structConditions);
                    fReadTable.SetValue("ORDERLINE", tblItems);
                }


                fReadTable.Invoke(dest);
                String        result  = (String)fReadTable.GetValue("SALESDOCUMENT");
                IRfcStructure result2 = (IRfcStructure)fReadTable.GetValue("RETURN");

                documentNumber = result.ToString();
                errorMessage   = result2[3].ToString().Replace("FIELD MESSAGE=", "");


                if (String.IsNullOrEmpty(documentNumber) || !String.IsNullOrEmpty(errorMessage))
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }

            return(true);
        }
示例#3
0
        private Boolean GetInvoiceFromXML(String databaseName, String xmlContent, out DocumentCached invoice, out String errorMessage)
        {
            invoice      = new DocumentCached();
            errorMessage = String.Empty;
            try
            {
                invoice = (DocumentCached)XmlToObject.CreateObject(xmlContent, invoice);
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
                return(false);
            }

            return(true);
        }
示例#4
0
        private Boolean ImportInvoice2(String databaseName, DocumentCached invoice)
        {
            IRfcFunction fReadTable = repo.CreateFunction("ZZBAPI_DEBIT_MEMO_REQUEST");

            fReadTable.SetValue("CUSTOMER", "0000008289");
            fReadTable.SetValue("SALES_ORG", "ZW01");
            fReadTable.SetValue("PURCH_DATE", DateTime.Now);
            fReadTable.SetValue("PURCH_NO_C", "TEST ZZBAPI_DEBIT_MEMO_REQUEST");

            RfcStructureMetadata metaData         = dest.Repository.GetStructureMetadata("ZORDERLINE");
            IRfcStructure        structConditions = metaData.CreateStructure();

            structConditions.SetValue("ITM_NUMBER", "000010");
            structConditions.SetValue("MATERIAL", "C");             // C => Certificate
            structConditions.SetValue("TARGET_QTY", 10);
            structConditions.SetValue("SALES_UNIT", "ST");
            structConditions.SetValue("COND_VALUE", 16);
            structConditions.SetValue("CURRENCY", "EUR");
            structConditions.SetValue("SHORT_TEXT", "test");

            IRfcTable tblItems = fReadTable.GetTable("ORDERLINE");

            tblItems.Append(structConditions);
            fReadTable.SetValue("ORDERLINE", tblItems);



            fReadTable.Invoke(dest);
            var result  = fReadTable.GetValue("SALESDOCUMENT");
            var result2 = fReadTable.GetValue("RETURN");

            Console.WriteLine(result.ToString());
            Console.ReadLine();

            return(true);
        }
        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");
        }