Beispiel #1
0
        // POST api/values

        public RTNMANVAL Post([FromBody] GRPO_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_GRPO.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
        // 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);

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

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

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

            return(returnVal);
        }
Beispiel #3
0
 // PUT api/values/5
 public string Put(int id, [FromBody] GRPO_HEADER value)
 {
     return("Function is not available");
 }
Beispiel #4
0
        public static GRPO_HEADER GetData(SAPbobsCOM.Company oCompany, int id)
        {
            Utils control = new Utils();
            List <GRPO_DETAIL> details    = new List <GRPO_DETAIL>();
            XDocument          xDoc       = new XDocument();
            XDocument          xDocDetail = new XDocument();

            string sql = "select T0.DocEntry ,T0.DocNum as 'NumberForm',T0.DocDate as 'PostingDate',T0.DocDueDate as 'DueDate',T0.TaxDate as 'DocumentDate' " +
                         ",T0.CardCode as 'VendorCode',T0.CardName as 'VendorName',T0.DocStatus as 'Status',T0.Comments as 'Remarks'  FROM OPDN T0 where T0.DocEntry = " + id;
            Recordset rs = control._IDU_Recordset(oCompany, sql);

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

            sql = "Select T1.ItemCode as 'ItemNo',T1.Dscription as 'ItemDescription',T1.Quantity,T1.Price,T1.Currency,T1.LineTotal as 'Total',T1.WhsCode,T1.AcctCode as 'GLAccount',T1.OcrCode as 'CostCenter',T1.unitMsr as 'UOM'" +
                  ",T1.BaseEntry, T1.BaseLine " +
                  "FROM PDN1 T1 " +
                  "WHERE T1.docentry = " + id;
            rs         = control._IDU_Recordset(oCompany, sql);
            xDocDetail = XDocument.Parse(rs.GetAsXML());

            XElement xEle       = xDoc.Element("BOM").Element("BO").Element("OPDN").Element("row");
            XElement xEleDetail = xDocDetail.Element("BOM").Element("BO").Element("PDN1");

            foreach (var item in xEleDetail.Elements("row"))
            {
                GRPO_DETAIL model_detail = new GRPO_DETAIL()
                {
                    ItemCode        = item.Element("ItemNo").Value,
                    ItemDescription = item.Element("ItemDescription").Value,
                    UOM             = item.Element("UOM").Value,
                    Quantity        = Convert.ToDouble(item.Element("Quantity").Value),
                    Price           = Convert.ToDouble(item.Element("Price").Value),
                    WarehouseCode   = item.Element("WhsCode").Value,
                    GLAccount       = item.Element("GLAccount").Value,
                    CostCenter      = item.Element("CostCenter").Value,
                    Currency        = item.Element("Currency").Value,
                    Total           = Convert.ToDecimal(item.Element("Total").Value)
                };

                details.Add(model_detail);
            }

            GRPO_HEADER model = new GRPO_HEADER()
            {
                DocEntry    = xEle.Element("DocEntry").Value,
                NumberForm  = xEle.Element("NumberForm").Value,
                VendorCode  = xEle.Element("VendorCode").Value,
                VendorName  = xEle.Element("VendorName").Value,
                Status      = xEle.Element("Status").Value,
                Remarks     = xEle.Element("Remarks").Value,
                PostingDate = DateTime.ParseExact(xEle.Element("PostingDate").Value, "yyyyMMdd",
                                                  CultureInfo.InvariantCulture, DateTimeStyles.None),
                DueDate = DateTime.ParseExact(xEle.Element("DueDate").Value, "yyyyMMdd",
                                              CultureInfo.InvariantCulture, DateTimeStyles.None),
                DocumentDate = DateTime.ParseExact(xEle.Element("DocumentDate").Value, "yyyyMMdd",
                                                   CultureInfo.InvariantCulture, DateTimeStyles.None),

                lines = details
            };

            return(model);
        }
Beispiel #5
0
        public static string AddData(Company oCompany, GRPO_HEADER model)
        {
            Documents oObject = null;
            RTNMANVAL rtn = new RTNMANVAL();
            int       errCode; string errMessage, strResult = "";

            try
            {
                oCompany.StartTransaction();

                oObject = oCompany.GetBusinessObject(BoObjectTypes.oPurchaseDeliveryNotes);

                oObject.CardCode   = model.VendorCode;
                oObject.DocDate    = model.PostingDate;
                oObject.DocDueDate = model.DueDate;
                oObject.TaxDate    = model.DocumentDate;
                oObject.DocType    = BoDocumentTypes.dDocument_Items;


                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].UOM;
                    oObject.Lines.UnitPrice = model.lines[i].Price;
                    oObject.Lines.Quantity  = model.lines[i].Quantity;

                    if (model.lines[i].BaseEntry != 0)
                    {
                        oObject.Lines.BaseEntry = model.lines[i].BaseEntry;
                        oObject.Lines.BaseLine  = model.lines[i].BaseLine;
                        oObject.Lines.BaseType  = Convert.ToInt32(BoObjectTypes.oPurchaseOrders);
                    }

                    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);
        }