Exemplo n.º 1
0
        public int AddMultiple(List <oGlAccount> objs)
        {
            ChartOfAccounts coa = null;

            try
            {
                SboComObject.StartTransaction();

                int retcode = 0;

                foreach (oGlAccount obj in objs)
                {
                    coa = (ChartOfAccounts)SboComObject.GetBusinessObject(BoObjectTypes.oChartOfAccounts);

                    coa.Code       = obj.AccntCode;
                    coa.Name       = obj.AccntName;
                    coa.BPLID      = obj.BPLId;
                    coa.FormatCode = obj.FormatCode;

                    retcode = coa.Add();

                    if (retcode > 0)
                    {
                        break;
                    }
                }

                if (retcode > 0)
                {
                    int    errCode    = 0;
                    string errMessage = "";
                    SboComObject.GetLastError(out errCode, out errMessage);
                    GlobalInstance.Instance.SBOErrorCode    = errCode;
                    GlobalInstance.Instance.SBOErrorMessage = errMessage;

                    SboComObject.EndTransaction(BoWfTransOpt.wf_RollBack);
                }
                else
                {
                    SboComObject.EndTransaction(BoWfTransOpt.wf_Commit);
                }


                return(retcode);
            }
            catch
            {
                throw new Exception(GlobalInstance.Instance.SBOErrorMessage);
            }
            finally
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(coa);
            }
        }