Beispiel #1
0
        // POST api/values

        public RTNMANVAL Post([FromBody] PO_HEADER value)
        {
            RTNMANVAL returnVal = null;

            SAPbobsCOM.Company oCompany = null;
            string             newKey   = "";

            try
            {
                oCompany = Company.GetCompany(Properties.Settings.Default.StrDbServer, Properties.Settings.Default.StrDbUserName, Properties.Settings.Default.StrDbPassword,
                                              Properties.Settings.Default.StrDbName, Properties.Settings.Default.StrSapB1UserName, Properties.Settings.Default.StrSapB1Password,
                                              Properties.Settings.Default.StrSapB1LicenseServer);

                newKey = Logic.SAP.SAP_PO.AddData(oCompany, value);

                returnVal = new RTNMANVAL()
                {
                    errorCode = "0",
                    message   = "Data has beed added",
                    value     = newKey
                };
            }
            catch (Exception e)
            {
                returnVal = new RTNMANVAL()
                {
                    errorCode = "-1",
                    message   = e.Message.ToString()
                };
            }

            return(returnVal);
        }
Beispiel #2
0
        public static PO_HEADER GetData(SAPbobsCOM.Company oCompany, int id)
        {
            Utils            control    = new Utils();
            List <PO_DETAIL> details    = new List <PO_DETAIL>();
            XDocument        xDoc       = new XDocument();
            XDocument        xDocDetail = new XDocument();

            string    sql = "select U_PrimaryNumberingPOS, U_DocumentNumberingPOS, docentry, docnum, CardCode, CardName, DocDate, DocDueDate, TaxDate from opor where docentry = " + id;
            Recordset rs  = control._IDU_Recordset(oCompany, sql);

            xDoc = XDocument.Parse(rs.GetAsXML());

            sql = "select t1.LineNum, ItemCode, dscription, UomEntry, UomCode, Quantity, Price, t2.WhsCode, t2.WhsName from por1 t1 " +
                  "join owhs t2 on t1.WhsCode = t2.WhsCode where t1.docentry = " + id;
            rs         = control._IDU_Recordset(oCompany, sql);
            xDocDetail = XDocument.Parse(rs.GetAsXML());

            XElement xEle       = xDoc.Element("BOM").Element("BO").Element("opor").Element("row");
            XElement xEleDetail = xDocDetail.Element("BOM").Element("BO").Element("por1");

            foreach (var item in xEleDetail.Elements("row"))
            {
                PO_DETAIL model_detail = new PO_DETAIL()
                {
                    LineNum       = Convert.ToInt32(item.Element("LineNum").Value),
                    ItemCode      = item.Element("ItemCode").Value,
                    Description   = item.Element("dscription").Value,
                    UomEntry      = Convert.ToInt32(item.Element("UomEntry").Value),
                    UomCode       = item.Element("UomCode").Value,
                    Quantity      = Convert.ToDouble(item.Element("Quantity").Value),
                    Price         = Convert.ToDouble(item.Element("Price").Value),
                    WarehouseCode = item.Element("WhsCode").Value,
                    WarehouseName = item.Element("WhsName").Value
                };

                details.Add(model_detail);
            }

            PO_HEADER model = new PO_HEADER()
            {
                PrimaryNumberingPOS  = xEle.Element("U_PrimaryNumberingPOS").Value,
                DocumentNumberingPOS = xEle.Element("U_DocumentNumberingPOS").Value,
                DocEntry             = xEle.Element("docentry").Value,
                DocNum       = xEle.Element("docnum").Value,
                CardCode     = xEle.Element("CardCode").Value,
                CardName     = xEle.Element("CardName").Value,
                DocumentDate = DateTime.ParseExact(xEle.Element("DocDate").Value, "yyyyMMdd",
                                                   CultureInfo.InvariantCulture, DateTimeStyles.None),
                DocDueDate = DateTime.ParseExact(xEle.Element("DocDueDate").Value, "yyyyMMdd",
                                                 CultureInfo.InvariantCulture, DateTimeStyles.None),
                TaxDate = DateTime.ParseExact(xEle.Element("TaxDate").Value, "yyyyMMdd",
                                              CultureInfo.InvariantCulture, DateTimeStyles.None),
                lines = details
            };

            return(model);
        }
 private void MapToHeaderRow(POHeaderRow row, PO_HEADER entity)
 {
     row.PONum          = entity.PONum > 0 ? entity.PONum : row.PONum;
     row.Company        = !string.IsNullOrEmpty(entity.CompanyCode) ? entity.CompanyCode : row.Company;
     row.EntryPerson    = !string.IsNullOrEmpty(entity.EntryPerson) ? entity.EntryPerson : row.EntryPerson;
     row.POType         = !string.IsNullOrEmpty(entity.POType) ? entity.POType : row.POType;
     row.OrderDate      = entity.OrderDate != null ? entity.OrderDate : row.OrderDate;
     row.BuyerID        = !string.IsNullOrEmpty(entity.BuyerID) ? entity.BuyerID : row.BuyerID;
     row.TermsCode      = !string.IsNullOrEmpty(entity.PaymentTerm) ? entity.PaymentTerm : row.TermsCode;
     row.ShipViaCode    = !string.IsNullOrEmpty(entity.ShipViaCode) ? entity.ShipViaCode : row.ShipViaCode;
     row.CurrencyCode   = !string.IsNullOrEmpty(entity.Currency) ? entity.Currency : row.CurrencyCode;
     row.ExchangeRate   = entity.ExchangeRate.HasValue ? entity.ExchangeRate.Value : row.ExchangeRate;
     row.ShipState      = !string.IsNullOrEmpty(entity.ShipState) ? entity.ShipState : row.ShipState;
     row.ApprovalStatus = !string.IsNullOrEmpty(entity.ApprovalStatus) ? entity.ApprovalStatus : row.ApprovalStatus;
     row.VendorNum      = entity.VendorNumber;
     row.PostDate       = entity.PostingDate;
     row.PromiseDate    = entity.DeliveryDate;
 }
Beispiel #4
0
        // GET api/values/5
        public RTNVAL Get(int id)
        {
            RTNVAL returnVal = null;

            SAPbobsCOM.Company oCompany = null;

            try
            {
                oCompany = Company.GetCompany(Properties.Settings.Default.StrDbServer, Properties.Settings.Default.StrDbUserName, Properties.Settings.Default.StrDbPassword,
                                              Properties.Settings.Default.StrDbName, Properties.Settings.Default.StrSapB1UserName, Properties.Settings.Default.StrSapB1Password,
                                              Properties.Settings.Default.StrSapB1LicenseServer);

                PO_HEADER model   = Logic.SAP.SAP_PO.GetData(oCompany, id);
                int       count   = 0;
                string    message = "No Data Found";

                if (model.DocEntry != "")
                {
                    count = 1; message = "Get Data Successfull";
                }

                returnVal = new POSKALARVAL()
                {
                    errorCode   = "0",
                    message     = message,
                    values      = model,
                    recordCount = count
                };
            }
            catch (Exception e)
            {
                returnVal = new POSKALARVAL()
                {
                    errorCode = "-1",
                    message   = e.Message.ToString()
                };
            }

            return(returnVal);
        }
Beispiel #5
0
 // PUT api/values/5
 public string Put(int id, [FromBody] PO_HEADER value)
 {
     return("Function is not available");
 }
Beispiel #6
0
        public static string AddData(Company oCompany, PO_HEADER model)
        {
            Documents oObject = null;
            RTNMANVAL rtn = new RTNMANVAL();
            int       errCode; string errMessage, strResult = "";

            try
            {
                oCompany.StartTransaction();

                oObject = oCompany.GetBusinessObject(BoObjectTypes.oPurchaseOrders);

                oObject.CardCode   = model.CardCode;
                oObject.DocDate    = model.PostingDate;
                oObject.DocDueDate = model.DocDueDate;
                oObject.TaxDate    = model.TaxDate;
                oObject.DocType    = BoDocumentTypes.dDocument_Items;
                oObject.UserFields.Fields.Item("U_DocumentNumberingPOS").Value = model.DocumentNumberingPOS;
                oObject.UserFields.Fields.Item("U_PrimaryNumberingPOS").Value  = model.PrimaryNumberingPOS;

                for (int i = 0; i < model.lines.Count; i++)
                {
                    oObject.Lines.ItemCode      = model.lines[i].ItemCode;
                    oObject.Lines.WarehouseCode = model.lines[i].WarehouseCode;
                    oObject.Lines.UoMEntry      = model.lines[i].UomEntry;
                    oObject.Lines.UnitPrice     = model.lines[i].Price;
                    oObject.Lines.Quantity      = model.lines[i].Quantity;

                    oObject.Lines.Add();
                }

                int addStatus = oObject.Add();

                if (addStatus == 0)
                {
                    if (strResult == "")
                    {
                        strResult = oCompany.GetNewObjectKey();
                    }
                    else
                    {
                        strResult = strResult + " | " + oCompany.GetNewObjectKey();
                    }
                }
                else
                {
                    if (oCompany.InTransaction)
                    {
                        oCompany.EndTransaction(BoWfTransOpt.wf_RollBack);
                    }

                    oCompany.GetLastError(out errCode, out errMessage);
                    throw new Exception("Error Code : " + errCode + " | Error Message : " + errMessage);
                }
                oCompany.EndTransaction(BoWfTransOpt.wf_Commit);
            }
            catch (Exception)
            {
                if (oCompany.InTransaction)
                {
                    oCompany.EndTransaction(BoWfTransOpt.wf_RollBack);
                }
                ;
                throw;
            }

            return(strResult);
        }