示例#1
0
        public RTGIPROD Post([FromBody] GRFROMPROD value)
        {
            RTGIPROD returnVal = new RTGIPROD();

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

                SAP_GRFROMPROD trans = new SAP_GRFROMPROD();

                returnVal = trans.AddData(oCompany, value);


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

            return(returnVal);
        }
示例#2
0
        public RTGIPROD AddData(Company oCompany, GRFROMPROD model)
        {
            Documents oObject = null;
            RTNMANVAL rtn     = new RTNMANVAL();
            RTGIPROD  rtn2    = new RTGIPROD();

            rtn2 = null;
            int errCode; string errMessage, strResult = "";

            try
            {
                oCompany.StartTransaction();

                oObject = oCompany.GetBusinessObject(BoObjectTypes.oInventoryGenEntry);

                oObject.DocDate = model.DocumentDate;
                //oObject.DocDueDate = model.DocumentDate;
                //oObject.TaxDate = model.DocumentDate;
                oObject.DocType    = BoDocumentTypes.dDocument_Items;
                oObject.Comments   = model.Remarks + " Create By WebService";
                oObject.Reference2 = model.Reference2;
                for (int i = 0; i < model.Detil.Count; i++)
                {
                    //oObject.Lines.ItemCode = model.Detil[i].ItemCode;
                    //oObject.Lines.WarehouseCode = model.Detil[i].WarehouseCode;
                    oObject.Lines.Quantity        = model.Detil[i].Quantity;
                    oObject.Lines.BaseEntry       = model.Detil[i].BaseEntry;
                    oObject.Lines.BaseType        = 202;
                    oObject.Lines.TransactionType = BoTransactionTypeEnum.botrntComplete;
                    //oObject.Lines.BaseLine = model.Detil[i].BaseLine;
                    oObject.Lines.Add();
                }

                int addStatus = oObject.Add();

                if (addStatus == 0)
                {
                    if (strResult == "")
                    {
                        strResult = oCompany.GetNewObjectKey();
                        rtn2      = GetInfo(oCompany, Convert.ToInt32(oCompany.GetNewObjectKey()), strResult);
                    }
                    else
                    {
                        strResult = strResult + " | " + oCompany.GetNewObjectKey();
                        rtn2      = GetInfo(oCompany, Convert.ToInt32(oCompany.GetNewObjectKey()), strResult);
                    }
                }
                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(rtn2);
        }