コード例 #1
0
        public static string AddData(SAPbobsCOM.Company oCompany, EXR model)
        {
            RTNMANVAL rtn = new RTNMANVAL();
            int       errCode; string errMessage, strResult = "";

            SAPbobsCOM.SBObob    oSBob = null;
            SAPbobsCOM.Recordset rs    = null;
            try
            {
                oCompany.StartTransaction();

                oSBob = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge);
                rs    = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                rs    = oSBob.GetLocalCurrency();
                rs    = oSBob.GetSystemCurrency();

                oSBob.SetCurrencyRate(model.Currency, model.DateRate, model.Rate, true);
                oCompany.EndTransaction(BoWfTransOpt.wf_Commit);

                strResult = "OK";
            }
            catch (Exception e)
            {
                if (oCompany.InTransaction)
                {
                    oCompany.EndTransaction(BoWfTransOpt.wf_RollBack);
                }
                ;
                throw;
            }
            return(strResult);
        }
コード例 #2
0
        // PUT api/exchangerate/5
        public void Put([FromBody] EXR 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_EXR.AddData(oCompany, value);

                returnVal = new RTNMANVAL()
                {
                    errorCode = "0",
                    message   = "Data has beed updated",
                    value     = newKey
                };
            }
            catch (Exception e)
            {
                returnVal = new RTNMANVAL()
                {
                    errorCode = "-1",
                    message   = e.Message.ToString()
                };
            }
        }
コード例 #3
0
        // POST api/values
        public RTNMANVAL Post([FromBody] REL value)
        {
            RTNMANVAL returnVal = null;
            string    newKey    = "";

            try
            {
                Logic.Connection.Connection.Release(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);

                returnVal = new RTNMANVAL()
                {
                    errorCode = "0",
                    message   = "Company connection released",
                    value     = newKey
                };
            }
            catch (Exception e)
            {
                returnVal = new RTNMANVAL()
                {
                    errorCode = "-1",
                    message   = e.Message.ToString()
                };
            }

            return(returnVal);
        }
コード例 #4
0
        // PUT api/ochatofaccount/5
        public static RTNMANVAL Put(string id, [FromBody] COA 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_COA.update(oCompany, value, id);

                returnVal = new RTNMANVAL()
                {
                    errorCode = "0",
                    message   = "Data has beed updated",
                    value     = id
                };
            }
            catch (Exception e)
            {
                returnVal = new RTNMANVAL()
                {
                    errorCode = "-1",
                    message   = e.Message.ToString()
                };
            }
            return(returnVal);
        }
コード例 #5
0
        public static string AddData(Company oCompany, ITEM model)
        {
            Items     oObject = null;
            RTNMANVAL rtn = new RTNMANVAL();
            int       errCode; string errMessage, strResult = "";

            try
            {
                oCompany.StartTransaction();
                oObject = oCompany.GetBusinessObject(BoObjectTypes.oItems);

                oObject.ItemCode = model.ItemCode;
                oObject.ItemName = model.ItemName;



                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);
        }
コード例 #6
0
        // POST api/values
        public RTNMANVAL Post([FromBody] IT_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_IT.AddData(oCompany, value);

                returnVal = new RTNMANVAL()
                {
                    errorCode     = "0",
                    message       = "Data has beed added",
                    value         = newKey,
                    DocEntry      = Convert.ToInt32(newKey),
                    Status        = "OPEN",
                    FromWarehouse = value.FromWarehouseCode,
                    ToWarehouse   = value.lines[0].ToWarehouseCode.ToString()
                };
            }
            catch (Exception e)
            {
                returnVal = new RTNMANVAL()
                {
                    errorCode = "-1",
                    message   = e.Message.ToString()
                };
            }

            return(returnVal);
        }
コード例 #7
0
        public static string update(Company oCompany, BP model, string BPCode)
        {
            SAPbobsCOM.BusinessPartners oObject;
            RTNMANVAL rtn = new RTNMANVAL();
            int       errCode; string errMessage, strResult = "";

            try
            {
                oCompany.StartTransaction();
                oObject = oCompany.GetBusinessObject(BoObjectTypes.oBusinessPartners);
                oObject.GetByKey(BPCode);
                oObject.CardName = model.CardName;
                if (model.BPType == "Vendor")
                {
                    oObject.CardType = BoCardTypes.cCustomer;
                }
                else if (model.BPType == "Lead")
                {
                    oObject.CardType = BoCardTypes.cLid;
                }
                else
                {
                    oObject.CardType = BoCardTypes.cSupplier;
                }
                oObject.Currency       = model.Currency;
                oObject.DebitorAccount = model.DebtPayAccount;
                oObject.Address        = model.Address;
                int statusBP = oObject.Update();
                if (statusBP == 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 e)
            {
                if (oCompany.InTransaction)
                {
                    oCompany.EndTransaction(BoWfTransOpt.wf_RollBack);
                }
                ;
                throw;
            }
            return(strResult);
        }
コード例 #8
0
ファイル: SAP_PR.cs プロジェクト: tuonny/RESTSAP
        public static string AddData(Company oCompany, PR_HEADER model)
        {
            Documents oObject = null;
            RTNMANVAL rtn = new RTNMANVAL();
            int       errCode; string errMessage, strResult = "";

            try
            {
                oCompany.StartTransaction();

                oObject              = oCompany.GetBusinessObject(BoObjectTypes.oPurchaseRequest);
                oObject.Series       = model.series;
                oObject.ReqType      = model.reqType;
                oObject.Requester    = model.requester;
                oObject.DocDate      = model.postingDate;
                oObject.DocDueDate   = model.docDueDate;
                oObject.TaxDate      = model.documentDate;
                oObject.RequriedDate = model.reqDate;

                for (int i = 0; i < model.lines.Count; i++)
                {
                    oObject.Lines.ItemCode    = model.lines[i].itemCode;
                    oObject.Lines.UnitPrice   = model.lines[i].infoPrice;
                    oObject.Lines.Quantity    = model.lines[i].requiredQuantity;
                    oObject.Lines.TaxCode     = model.lines[i].taxCode;
                    oObject.Lines.LineVendor  = model.lines[i].vendor;
                    oObject.Lines.ProjectCode = model.lines[i].siteID;

                    oObject.Lines.UserFields.Fields.Item("U_IDU_SiteName").Value = model.lines[i].siteName;
                    oObject.Lines.CostingCode = model.lines[i].costCenter;

                    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);
        }
コード例 #9
0
        public static string update(Company oCompany, COA model, string AcctCode)
        {
            SAPbobsCOM.ChartOfAccounts oObject;
            RTNMANVAL rtn = new RTNMANVAL();
            int       errCode; string errMessage, strResult = "";

            try
            {
                oCompany.StartTransaction();
                oObject = oCompany.GetBusinessObject(BoObjectTypes.oChartOfAccounts);
                oObject.GetByKey(AcctCode);
                oObject.Name         = model.AccountName;
                oObject.AcctCurrency = model.AccountCurrency;
                if (model.AccountType == "Revenues")
                {
                    oObject.AccountType = BoAccountTypes.at_Revenues;
                }
                else if (model.AccountType == "Expenses")
                {
                    oObject.AccountType = BoAccountTypes.at_Expenses;
                }
                else
                {
                    oObject.AccountType = BoAccountTypes.at_Other;
                }
                oObject.FatherAccountKey = model.FatherAccount;
                int statusCOA = oObject.Update();
                if (statusCOA == 0)
                {
                    oCompany.EndTransaction(BoWfTransOpt.wf_Commit);
                    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);
                }
            }
            catch (Exception e)
            {
                if (oCompany.InTransaction)
                {
                    oCompany.EndTransaction(BoWfTransOpt.wf_RollBack);
                }
                ;
                throw;
            }
            return(strResult);
        }
コード例 #10
0
ファイル: SAP_JE.cs プロジェクト: tuonny/RESTSAP
        public static string AddData(Company oCompany, JE model)
        {
            SAPbobsCOM.JournalEntries oObject;
            RTNMANVAL rtn = new RTNMANVAL();
            int       errCode; string errMessage, strResult = "";

            try
            {
                oCompany.StartTransaction();

                oObject = oCompany.GetBusinessObject(BoObjectTypes.oJournalEntries);
                oObject.ReferenceDate = model.Refdate;
                oObject.DueDate       = model.DueDate;
                oObject.TaxDate       = model.TaxDate;
                oObject.Reference     = model.Ref1;
                oObject.Reference2    = model.Ref2;
                oObject.Reference3    = model.Ref3;
                oObject.Memo          = model.Remarks;
                oObject.UserFields.Fields.Item("U_MaximoId").Value     = model.MaximoId;
                oObject.UserFields.Fields.Item("U_MaximoNumber").Value = model.MaximoNumber;

                if (model.ProjectId != "")
                {
                    oObject.ProjectCode = model.ProjectId;
                }

                for (int i = 0; i < model.Lines.Count; i++)
                {
                    oObject.Lines.AccountCode = model.Lines[i].AccountCode;
                    oObject.Lines.Debit       = Convert.ToDouble(model.Lines[i].DebitAmount);
                    oObject.Lines.Credit      = Convert.ToDouble(model.Lines[i].CreditAmount);
                    oObject.Lines.LineMemo    = model.Lines[i].LineMemo;


                    if (model.Lines[i].DebitAmountFC != 0 || model.Lines[i].CreditAmountFC != 0)
                    {
                        oObject.Lines.FCCurrency = model.Lines[i].FCCurrency;
                        oObject.Lines.FCDebit    = Convert.ToDouble(model.Lines[i].DebitAmountFC);
                        oObject.Lines.FCCredit   = Convert.ToDouble(model.Lines[i].CreditAmountFC);
                    }

                    if (model.Lines[i].CostCenter != null)
                    {
                        if (model.Lines[i].CostCenter != "")
                        {
                            oObject.Lines.CostingCode = model.Lines[i].CostCenter;
                        }
                    }
                    oObject.Lines.Add();
                }
                int statusJV = oObject.Add();

                if (statusJV == 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);
        }
コード例 #11
0
ファイル: SAP_ITR.cs プロジェクト: tuonny/RESTSAP
        public static string AddData(Company oCompany, ITR model)
        {
            StockTransfer oObject = null;
            RTNMANVAL     rtn = new RTNMANVAL();
            int           errCode; string errMessage, strResult = "";

            try
            {
                oCompany.StartTransaction();

                oObject = oCompany.GetBusinessObject(BoObjectTypes.oInventoryTransferRequest);

                oObject.DocDate       = model.PostingDate;
                oObject.DueDate       = model.DocumentDate;
                oObject.ToWarehouse   = model.ToWarehouseCode;
                oObject.FromWarehouse = model.FromWarehouseCode;
                oObject.Address       = model.ShipTo;
                oObject.UserFields.Fields.Item("U_MJTPO").Value        = model.NoSPK;
                oObject.UserFields.Fields.Item("U_MJTSPK").Value       = model.NoSPKDetil;
                oObject.UserFields.Fields.Item("U_MJT_NoSIP2").Value   = model.NoSIP2;
                oObject.UserFields.Fields.Item("U_MJT_TglSIP2").Value  = model.TglSIP2;
                oObject.UserFields.Fields.Item("U_MJTBASTB").Value     = model.NoBAP;
                oObject.UserFields.Fields.Item("U_MJTRCVD").Value      = model.TglBAP;
                oObject.UserFields.Fields.Item("U_mjt_opr").Value      = model.Operator;
                oObject.UserFields.Fields.Item("U_mjt_scr").Value      = model.Security;
                oObject.UserFields.Fields.Item("U_mjt_jam2").Value     = model.jam;
                oObject.UserFields.Fields.Item("U_mjt_qa").Value       = model.PetugasQA;
                oObject.UserFields.Fields.Item("U_MJTPO").Value        = model.NoSPK2;
                oObject.UserFields.Fields.Item("U_MJT_Uraian").Value   = model.UraianKerja;
                oObject.UserFields.Fields.Item("U_MJT_NomorINV").Value = model.NoInvoicePajak;
                oObject.UserFields.Fields.Item("U_MJT_DP").Value       = model.Downpayment;
                oObject.UserFields.Fields.Item("U_MJT_DP2").Value      = model.DownpaymentAmount;

                for (int i = 0; i < model.lines.Count; i++)
                {
                    oObject.Lines.ItemCode          = model.lines[i].ItemCode;
                    oObject.Lines.FromWarehouseCode = model.FromWarehouseCode;
                    oObject.Lines.WarehouseCode     = model.lines[i].ToWarehouseCode;
                    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);
        }
コード例 #12
0
ファイル: SAP_DO.cs プロジェクト: tuonny/RESTSAP
        public static string AddData(Company oCompany, DO_HEADER model)
        {
            Documents oObject = null;
            RTNMANVAL rtn = new RTNMANVAL();
            int       errCode; string errMessage, strResult = "";

            try
            {
                oCompany.StartTransaction();
                oObject = oCompany.GetBusinessObject(BoObjectTypes.oDeliveryNotes);

                oObject.CardCode   = model.CardCode;
                oObject.DocDate    = model.PostingDate;
                oObject.DocDueDate = model.DocDueDate;
                oObject.TaxDate    = model.DocDueDate;
                oObject.DocType    = BoDocumentTypes.dDocument_Items;
                //oObject.DocTotal = model.TotalTransaction;

                oObject.SalesPersonCode = Convert.ToInt32(model.SalesPersonCode);

                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.DiscountPercent = model.Lines[i].DiscountPercent;
                    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);
        }
コード例 #13
0
        public static string AddData(Company oCompany, APINV_HEADER model)
        {
            Documents oObject = null;
            RTNMANVAL rtn = new RTNMANVAL();
            int       errCode; string errMessage, strResult = "";

            try
            {
                oCompany.StartTransaction();

                oObject = oCompany.GetBusinessObject(BoObjectTypes.oPurchaseInvoices);

                oObject.Series     = model.series;
                oObject.CardCode   = model.cardCode;
                oObject.DocDate    = model.postingDate;
                oObject.DocDueDate = model.docDueDate;
                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].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);
        }
コード例 #14
0
ファイル: SAP_ARBA.cs プロジェクト: tuonny/RESTSAP
        public static string AddData(Company oCompany, ARBA model)
        {
            BlanketAgreement         oObject  = null;
            BlanketAgreementsService oService = null;

            RTNMANVAL rtn = new RTNMANVAL();
            int       errCode; string errMessage, strResult = "";

            try
            {
                oCompany.StartTransaction();

                oService = oCompany.GetCompanyService().GetBusinessService(ServiceTypes.BlanketAgreementsService);
                oObject  = oService.GetDataInterface(BlanketAgreementsServiceDataInterfaces.basBlanketAgreement);

                oObject.BPCode = model.bpCode;
                oObject.UserFields.Item("U_IDU_SiteID").Value   = model.siteID;
                oObject.UserFields.Item("U_IDU_SiteName").Value = model.siteName;
                oObject.UserFields.Item("U_IDU_SiteOp").Value   = model.siteOp;
                oObject.Remarks       = model.remarks;
                oObject.StartDate     = model.startDate;
                oObject.EndDate       = model.endDate;
                oObject.AgreementType = BlanketAgreementTypeEnum.atSpecific;

                BlanketAgreements_ItemsLine lines = oObject.BlanketAgreements_ItemsLines.Add();
                lines.ItemNo          = "L00001";
                lines.PlannedQuantity = model.plannedQuantity;
                lines.UnitPrice       = model.unitPrice;

                int addStatus = oService.AddBlanketAgreement(oObject).AgreementNo;

                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);
        }
コード例 #15
0
        public static string AddData(Company oCompany, GR_HEADER model)
        {
            Documents oObject = null;
            RTNMANVAL rtn = new RTNMANVAL();
            int       errCode; string errMessage, strResult = "";

            try
            {
                oCompany.StartTransaction();

                oObject = oCompany.GetBusinessObject(BoObjectTypes.oInventoryGenEntry);

                oObject.DocDate = model.PostingDate;
                oObject.TaxDate = model.DocumentDate;
                if (model.Reference2.Length > 11)
                {
                    oObject.Reference2 = model.Reference2.Substring(0, 11);
                }
                else
                {
                    oObject.Reference2 = model.Reference2;
                }
                oObject.Comments = model.Remarks;
                oObject.DocType  = BoDocumentTypes.dDocument_Items;


                for (int i = 0; i < model.lines.Count; i++)
                {
                    oObject.Lines.ItemCode      = model.lines[i].ItemCode;
                    oObject.Lines.Quantity      = model.lines[i].Quantity;
                    oObject.Lines.UnitPrice     = model.lines[i].Price;
                    oObject.Lines.WarehouseCode = model.lines[i].WarehouseCode;
                    oObject.Lines.ProjectCode   = model.lines[i].ProjectCode;
                    if (model.lines[i].ProjectCode != null)
                    {
                        oObject.Lines.CostingCode = model.lines[i].CostCenter;
                    }
                    if (model.lines[i].AccountCode != null)
                    {
                        oObject.Lines.AccountCode = model.lines[i].AccountCode;
                    }

                    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);
        }
コード例 #16
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);
        }