예제 #1
0
        public bool ColumnExists(string TableName, string FieldID)
        {
            bool oFlag = true;

            try
            {
                SAPbobsCOM.Recordset rsetField = (SAPbobsCOM.Recordset)oDiCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                string s = "Select 1 from [CUFD] Where TableID='" + TableName.Trim() + "' and AliasID='" + FieldID.Trim() + "'";
                rsetField.DoQuery("Select 1 from [CUFD] Where TableID='" + TableName.Trim() + "' and AliasID='" + FieldID.Trim() + "'");
                if (rsetField.EoF)
                {
                    oFlag = false;
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(rsetField);
                rsetField = null;
                GC.Collect();
                return(oFlag);
            }
            catch (Exception ex)
            {
                throw new Exception("hello");
                throw new Exception("Failed to Column Exists : " + ex.Message);
            }
            finally
            {
            }
            return(oFlag);
        }
예제 #2
0
        /// <summary>
        /// Validate customer code - nomor memo
        /// </summary>
        private void Validate_CashDisc_CustCode(string formUID, ref ItemEvent pVal, ref bool bubbleEvent)
        {
            if (bubbleEvent)
            {
                if (pVal.BeforeAction == false && pVal.ActionSuccess == true && pVal.ItemChanged == true)
                {
                    Form         oForm    = oSBOApplication.Forms.Item(formUID);
                    DBDataSource dtSource = oForm.DataSources.DBDataSources.Item("@SOL_CASHDISC");
                    Recordset    oRec     = oSBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                    try
                    {
                        oForm.Freeze(true);
                        string noMemo = GenerateNoMemo(oForm.Items.Item("tCusCd").Specific.Value);
                        dtSource.SetValue("Code", 0, noMemo);
                    }
                    catch (Exception ex)
                    {
                        bubbleEvent = false;
                        oSBOApplication.MessageBox(ex.Message);
                    }
                    finally
                    {
                        if (oForm != null)
                        {
                            oForm.Freeze(false);
                        }

                        Utils.releaseObject(oForm);
                        Utils.releaseObject(dtSource);
                        Utils.releaseObject(oRec);
                    }
                }
            }
        }
예제 #3
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);
        }
        public static string FormatMoneyToString(double _double, SAPbobsCOM.Company oCompany, BoMoneyPrecisionTypes _Precision)
        {
            SBObob    businessObject = (SBObob)oCompany.GetBusinessObject(BoObjectTypes.BoBridge);
            Recordset recordset      = (Recordset)oCompany.GetBusinessObject(BoObjectTypes.BoRecordset);

            recordset = businessObject.Format_MoneyToString(_double, _Precision);
            return((string)recordset.Fields.Item(0).Value);
        }
예제 #5
0
        private void removeTables(string[] tables)
        {
            SAPbouiCOM.Application b1App       = app.Resolve <SAPbouiCOM.Application>();
            UserTablesMD           userTableMD = (UserTablesMD)b1Company.GetBusinessObject(BoObjectTypes.oUserTables);

            foreach (var table in tables)
            {
                DoverSetup.removeTable(userTableMD, table, b1App, b1Company);
            }
            System.Runtime.InteropServices.Marshal.ReleaseComObject(userTableMD);
        }
예제 #6
0
        public static void Main(string[] args)
        {
            Company company = SAPHelper.GetCompany();

            if (company.Connected)
            {
                company.Disconnect();
            }
            int result = company.Connect();

            if (result != 0)
            {
                company.GetLastError(out ERROR_CODE, out ERROR_MESSAGE);
                Console.Error.Write($"({ERROR_CODE})-{ERROR_MESSAGE}");
                Console.Read();
                Environment.Exit(ERROR_CODE);
            }

            var udoManager = (FormattedSearches)company.GetBusinessObject(BoObjectTypes.oFormattedSearches);
            var oRecordSet = (Recordset)company.GetBusinessObject(BoObjectTypes.BoRecordset);

            oRecordSet.DoQuery("select FRQ.IndexID, QRY.IntrnalKey, CAT.CategoryId from OQCN CAT, OUQR QRY, CSHS FRQ where CAT.CategoryId = QRY.QCategory and QRY.IntrnalKey = FRQ.QueryId and CAT.CatName like '%BPVS - Producción Agrícola%'");
            while (!oRecordSet.EoF)
            {
                int mappedIndexForm = int.Parse(oRecordSet.Fields.Item("IndexID").Value.ToString());
                if (!udoManager.GetByKey(mappedIndexForm))
                {
                    Console.WriteLine("Don't exists the match between UDO form and query");
                    continue;
                }
                Console.WriteLine("Removing match between UDO form and query: {0}", udoManager.Remove() == 0);
                oRecordSet.MoveNext();
            }
            oRecordSet.MoveFirst();
            var userQueries = (UserQueries)company.GetBusinessObject(BoObjectTypes.oUserQueries);

            while (!oRecordSet.EoF)
            {
                int queryId    = int.Parse(oRecordSet.Fields.Item("IntrnalKey").Value.ToString());
                int categoryId = int.Parse(oRecordSet.Fields.Item("CategoryId").Value.ToString());
                if (!userQueries.GetByKey(queryId, categoryId))
                {
                    Console.Error.WriteLine("Don't exists the query");
                    continue;
                }
                Console.WriteLine("Removing the query: {0}", userQueries.Remove() == 0);
                oRecordSet.MoveNext();
            }
            Console.WriteLine("Finish process, press any key");
            Console.Read();
            company.Disconnect();
        }
예제 #7
0
        /// <summary>
        /// Decimal Separator
        /// </summary>
        private void NumericSeparators()
        {
            SAPbobsCOM.Recordset oRec;

            oRec = oSBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
            oRec.DoQuery(GeneralVariables.SQLHandler.SeparatorSQL());

            GeneralVariables.WinDecSep   = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
            GeneralVariables.SBODecSep   = oRec.Fields.Item("DecSep").Value.ToString();
            GeneralVariables.SBOThousSep = oRec.Fields.Item("ThousSep").Value.ToString();

            System.Runtime.InteropServices.Marshal.ReleaseComObject(oRec);
            oRec = null;
            GC.Collect();
        }
예제 #8
0
        public bool ExistsTable()
        {
            var userTable = _sboCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables) as SAPbobsCOM.UserTablesMD;

            try
            {
                return(userTable.GetByKey(_tableUserName));
            }
            finally
            {
                if (userTable != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(userTable);
                }
            }
        }
예제 #9
0
        public IHttpActionResult CreateItem(ItemDetails itemDetails)
        {
            //Inicializo mi conexión a SAP
            SAPConnection conncetion = new SAPConnection();

            SAPbobsCOM.Company company = conncetion.OpenConnection();

            SAPbobsCOM.Items oItems;
            oItems          = company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems);
            oItems.ItemCode = itemDetails.ItemCode;
            oItems.ItemName = itemDetails.ItemName;
            int status = oItems.Add();

            //Compruebo si el guardado se ha realizado correctamente
            if (status == 0)
            {
                responseCall.RespCode    = "00";
                responseCall.Description = "Guardado correctamente";
            }
            else
            {
                responseCall.RespCode    = "99";
                responseCall.Description = company.GetLastErrorDescription().ToString();
            }
            return(Ok(responseCall));
        }
        public static bool CheckUDOExists(string UDOName)
        {
            SAPbobsCOM.Company SBO_Company = Conexion.oCompany;

            SAPbobsCOM.UserObjectsMD oUdtMD = null /* TODO Change to default(_) if this is not a reference type */;
            bool ret = false;

            try
            {
                oUdtMD = (SAPbobsCOM.UserObjectsMD)SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD);

                if (oUdtMD.GetByKey(UDOName))
                {
                    ret = true;
                }
                else
                {
                    ret = false;
                }
            }
            catch (Exception)
            {
                ret = false;
            }
            finally
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oUdtMD);
                oUdtMD = null /* TODO Change to default(_) if this is not a reference type */;
                GC.Collect();
            }

            return(ret);
        }
예제 #11
0
        public static string UploadtoSAP()
        {
            int errCode = 0;

            try
            {
                Regex rx = new Regex("^[0-9]{5}$", RegexOptions.Compiled | RegexOptions.IgnoreCase);

                foreach (var file_path in
                         Directory
                         .EnumerateFiles(@"F:\apinvoice", "*.pdf")
                         .Where(x => rx.IsMatch(Path.GetFileNameWithoutExtension(x))))
                {
                    SAPbobsCOM.Company      oCompany = CompanyConnection("1");
                    SAPbobsCOM.Attachments2 oAtt     = (SAPbobsCOM.Attachments2)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oAttachments2);
                    oAtt.Lines.SourcePath    = @"F:\apinvoice";
                    oAtt.Lines.FileName      = Path.GetFileNameWithoutExtension(file_path);
                    oAtt.Lines.FileExtension = "pdf";
                    int iErr     = oAtt.Add();
                    int AttEntry = 0;
                    if (iErr == 0)
                    {
                        AttEntry = int.Parse(oCompany.GetNewObjectKey());
                        var apinvoice = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseInvoices);
                        if (apinvoice.GetByKey(Convert.ToInt32(Path.GetFileNameWithoutExtension(file_path))) == true)
                        {
                            apinvoice.AttachmentEntry = AttEntry;
                            errCode = apinvoice.Update();
                        }
                    }
                    if (iErr != 0)
                    {
                        (oCompany).GetLastError(out lErrCode, out sErrMsg);
                    }
                }
            }

            catch (Exception Ex)
            {
                sErrMsg = Ex.ToString();
            }


            return(errCode.ToString());
        }
예제 #12
0
        public static void CreateProducts()
        {
            try
            {
                using (var context = new POSStagingContext())
                {
                    var Products          = context.Products2.Where(P => P.Created == "N");
                    SAPbobsCOM.Items oitm = (SAPbobsCOM.Items)oCompany.GetBusinessObject(BoObjectTypes.oItems);

                    foreach (var item in Products)
                    {
                        if (item.Created == "N")
                        {
                            oitm.ItemCode       = item.ProductCode;
                            oitm.ItemName       = item.ProductDescText;
                            oitm.PurchaseItem   = BoYesNoEnum.tNO;
                            oitm.SalesItem      = BoYesNoEnum.tYES;
                            oitm.InventoryItem  = BoYesNoEnum.tNO;
                            oitm.ItemsGroupCode = 115;
                            oitm.SalesVATGroup  = "X0";

                            if (oitm.Add() != 0)
                            {
                                oCompany.GetLastError(out errCode, out errMsg);
                                Console.WriteLine(errMsg);


                                //oCompany.Disconnect();
                            }
                            else
                            {
                                item.Created = "Y";

                                Console.WriteLine(item.ProductCode + "- created successfully ");
                            }
                        }
                    }
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #13
0
        public Recordset _IDU_Recordset(SAPbobsCOM.Company oCompany, string ssql)
        {
            Recordset rs = null;

            rs = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
            rs.DoQuery(ssql);

            return(rs);
        }
예제 #14
0
        public IEnumerable <Kalemler> GetAllKalemler()
        {
            List <Kalemler> lstKalem = new List <Kalemler>();

            SAPbobsCOM.Company company = new SAPbobsCOM.Company();
            int    connectionResult;
            int    errorCode    = 0;
            string errorMessage = "";

            try
            {
                company.Server        = ConfigurationManager.AppSettings["server"].ToString();
                company.CompanyDB     = ConfigurationManager.AppSettings["companydb"].ToString();
                company.DbServerType  = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2016;
                company.DbUserName    = ConfigurationManager.AppSettings["dbuser"].ToString();
                company.DbPassword    = ConfigurationManager.AppSettings["dbpassword"].ToString();
                company.UserName      = ConfigurationManager.AppSettings["user"].ToString();
                company.Password      = ConfigurationManager.AppSettings["password"].ToString();
                company.language      = SAPbobsCOM.BoSuppLangs.ln_Turkish_Tr;
                company.UseTrusted    = false;
                company.LicenseServer = ConfigurationManager.AppSettings["licenseServer"].ToString();
                company.SLDServer     = ConfigurationManager.AppSettings["SLDServer"].ToString();

                connectionResult = company.Connect();

                if (connectionResult != 0)
                {
                    company.GetLastError(out errorCode, out errorMessage);
                }
                else
                {
                    //SAPbobsCOM.Items oItem = (Items)company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems);
                    var oRecordSet = (Recordset)company.GetBusinessObject(BoObjectTypes.BoRecordset);
                    oRecordSet.DoQuery("select ItemCode, ItemName from dbo.OITM");
                    while (!oRecordSet.EoF)
                    {
                        //sorgu ile çekmek en kolayı zannedersem
                        //var key = oRecordSet.Fields.Item(0).Value.ToString();
                        //oItem.GetByKey(key);

                        lstKalem.Add(new Kalemler {
                            ItemCode = oRecordSet.Fields.Item(0).Value.ToString(), ItemName = oRecordSet.Fields.Item(1).Value.ToString()
                        });

                        oRecordSet.MoveNext();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(lstKalem);
        }
예제 #15
0
        /// <summary>
        /// Header
        /// Show item name when item code choosed
        /// </summary>
        private void Validate_AltItem_CompItemCode(string formUID, ref ItemEvent pVal, ref bool bubbleEvent)
        {
            if (bubbleEvent)
            {
                if (pVal.BeforeAction == false && pVal.ActionSuccess == true && pVal.ItemChanged == true)
                {
                    Form         oForm    = oSBOApplication.Forms.Item(formUID);
                    DBDataSource dtSource = oForm.DataSources.DBDataSources.Item("@SOL_ALTITEM_H");
                    Recordset    oRec     = oSBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                    String       itemCode = oForm.Items.Item("tCode").Specific.Value;
                    try
                    {
                        oForm.Freeze(true);
                        string name = string.Empty;

                        oRec.DoQuery("SELECT \"ItemName\" FROM OITM WHERE \"ItemCode\" = '" + itemCode + "'");
                        if (oRec.RecordCount > 0)
                        {
                            name = oRec.Fields.Item(0).Value;
                        }

                        dtSource.SetValue("Name", 0, name);
                    }
                    catch (Exception ex)
                    {
                        bubbleEvent = false;
                        oSBOApplication.MessageBox(ex.Message);
                    }
                    finally
                    {
                        if (oForm != null)
                        {
                            oForm.Freeze(false);
                        }

                        Utils.releaseObject(oForm);
                        Utils.releaseObject(oRec);
                        Utils.releaseObject(dtSource);
                    }
                }
            }
        }
예제 #16
0
        internal static string GetCOGSAccount(SAPbobsCOM.Company oComp, string sItem)
        {
            SAPbobsCOM.Recordset oRS = oComp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset) as SAPbobsCOM.Recordset;
            String sSQL = String.Format("SELECT T1.SaleCostAc FROM OITM T0 JOIN OITB T1 ON T0.ItmsGrpCod = T1.ItmsGrpCod WHERE ItemCode = '{0}' ", sItem);

            oRS.DoQuery(sSQL);
            if (oRS.EoF)
            {
                return("");
            }
            return(oRS.Fields.Item(0).Value.ToString().Trim());
        }
예제 #17
0
        /// <summary>
        /// Preenche um ComboBox com os dados de uma query.
        /// </summary>
        /// <param name="comboBox"></param>
        /// <param name="company">O Company a ser utilizado para obter dos dados.</param>
        /// <param name="query">A query a ser utilizada para obter os dados.</param>
        /// <param name="fieldValue">O nome do Field que contém o valor para ComboBox.</param>
        /// <param name="fieldDescription">O nome do Field que contém a descrição para o ComboBox.</param>
        /// <param name="noLock">Indica se a query deve ser executada na forma de apenas leiura, isto é, se houver alguma escrita no momento não vai esperar a conclusão desta para continuar.</param>
        public static Recordset AddValuesFromQuery(this ComboBox comboBox, SAPbobsCOM.Company company, string query,
                                                   string fieldValue = null, string fieldDescription = null, bool noLock = true)
        {
            if (company == null)
            {
                throw new ArgumentNullException("company");
            }

            var recordset = (Recordset)company.GetBusinessObject(BoObjectTypes.BoRecordset);

            return(AddValuesFromQuery(comboBox, recordset, query, fieldValue, fieldDescription, noLock));
        }
예제 #18
0
        public static void Conectar_Aplicacion()
        {
            SAPbouiCOM.SboGuiApi SboGuiApi = new SAPbouiCOM.SboGuiApi();
            oCompany = new SAPbobsCOM.Company();
            SboGuiApi.Connect("0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056");
            oApplication = SboGuiApi.GetApplication();
            oCompany     = (SAPbobsCOM.Company)oApplication.Company.GetDICompany();

            oSBObob = (SAPbobsCOM.SBObob)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge);

            sCodUsuActual     = oCompany.UserSignature.ToString();
            sNomUsuActual     = Funciones.Current_User_Name();
            sAliasUsuActual   = oCompany.UserName;
            sCurrentCompanyDB = oCompany.CompanyDB;
        }
예제 #19
0
        static void Main(string[] args)
        {
            // PO in header
            //1. One PO with one grn
            //2. One PO with multiple grn total the sum, if got match post that grn for  apinovice
            //3. One PO with multiple grn check each amount, if any thing got match post that grn for apinvoice

            // PO in detail
            //1. Mulitple PO with muliple grn combine together and check the line Total amount + tax  and tally with the extracted amount and post ap invoice
            //2. Muitple PO with mulitple grn combine together and check the total line before discount + tax and tally the extracted amount and post ap invoice
            //UploadtoSAP();

            DataTable table = GetExtractedData();

            if (table.Rows.Count > 0)
            {
                SAPbobsCOM.Company oCompany = CompanyConnection("1");
                if (oCompany != null)
                {
                    // loop the extracted data
                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        string docnum = post_to_sap(table.Rows[i]["po_no"].ToString(), table.Rows[i]["invoice_number"].ToString(), Convert.ToDouble(table.Rows[i]["amount"].ToString()), table.Rows[i]["line_amount"].ToString(), table.Rows[i]["po_number_detail"].ToString(), oCompany);
                        if (!string.IsNullOrEmpty(docnum))
                        {
                            // get the sellername
                            if (docnum.All(char.IsDigit) == true)
                            {
                                string strSql;
                                var    recordset = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                                strSql = "select CardName from OPCH where DocNum= '" + docnum + "'";
                                recordset.DoQuery(strSql);
                                string seller_name = Convert.ToString(recordset.Fields.Item("CardName").Value);
                                send_email("[email protected],[email protected]", table.Rows[i]["invoice_number"].ToString(), TruncateLongString(seller_name, 50), docnum);
                            }

                            //1 for sucess
                            UpdateSAPSTATUS(table.Rows[i]["pdf_file_name"].ToString(), "1", docnum);
                        }
                        else
                        {
                            UpdateSAPSTATUS(table.Rows[i]["pdf_file_name"].ToString(), "2", "");
                        }
                    }
                }
            }
        }
예제 #20
0
        private int Get_Depth_Level_Subproject(int pProjectID)
        {
            int kq = 0;
            //Find Depth Level of Subproject in Project
            Recordset oR_Subproject_LV = null;

            oR_Subproject_LV = (Recordset)oCompany.GetBusinessObject(BoObjectTypes.BoRecordset);
            oR_Subproject_LV.DoQuery("Select ISNULL(MAX(Level),0) as Depth_Level from OPHA where ProjectID=" + pProjectID.ToString());
            kq = (int)oR_Subproject_LV.Fields.Item("Depth_Level").Value;
            return(kq);
        }
예제 #21
0
        public IHttpActionResult CreateDocument(createDocs createdocs)
        {
            //Inicializo mi conexión a SAP
            SAPConnection conncetion = new SAPConnection();

            SAPbobsCOM.Company   company = conncetion.OpenConnection();
            SAPbobsCOM.Documents draft;

            draft = company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
            draft.GetByKey(createdocs.DocEntry);
            draft.Comments   = createdocs.Comments;
            draft.EDocStatus = (EDocStatusEnum)BoBoeStatus.boes_Created;
            //draft.DocumentStatus = BoStatus.bost_Close;
            draft.Update();

            return(Ok(responseCall));
        }
예제 #22
0
        void Matrix_Data_Write()
        {
            SAPbobsCOM.Company   oCompany = (SAPbobsCOM.Company)SAPbouiCOM.Framework.Application.SBO_Application.Company.GetDICompany();
            SAPbobsCOM.Recordset oRset    = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
            oRset.DoQuery(Query);

            if (oRset.RecordCount > 0)
            {
                for (int i = 0; i < oRset.RecordCount; i++)
                {
                    Matrix0.AddRow();
                    ((SAPbouiCOM.EditText)Matrix0.Columns.Item("Name").Cells.Item(i + 1).Specific).Value       = oRset.Fields.Item("lastName").Value.ToString();
                    ((SAPbouiCOM.EditText)Matrix0.Columns.Item("Surname").Cells.Item(i + 1).Specific).Value    = oRset.Fields.Item("firstName").Value.ToString();
                    ((SAPbouiCOM.EditText)Matrix0.Columns.Item("FatherName").Cells.Item(i + 1).Specific).Value = oRset.Fields.Item("middleName").Value.ToString();
                    oRset.MoveNext();
                }
            }
        }
예제 #23
0
        private void processCurrency(SAPbobsCOM.Company oCompany)
        {
            SAPbobsCOM.Recordset oRS = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
            String oSql;


            //Precondiciones iniciales (Moneda Local, Cambio Directo o Indirecto, decimales a redondear)

            if (oCompany.DbServerType == SAPbobsCOM.BoDataServerTypes.dst_HANADB)
            {
                oSql = @"SELECT ""MainCurncy"", ""DirectRate"" , ""RateDec""   
                        FROM ""OADM""  ";
            }
            else
            {
                oSql = "SELECT MainCurncy, DirectRate , RateDec  " +
                       "FROM OADM  ";
            }
            oRS.DoQuery(oSql);
            if (oRS.RecordCount > 0)
            {
                string mainCurrency = ((System.String)oRS.Fields.Item("MainCurncy").Value).Trim();
                string tipoCambio   = ((System.String)oRS.Fields.Item("DirectRate").Value).Trim();
                int    redondeo     = ((System.Int32)oRS.Fields.Item("RateDec").Value);

                if (mainCurrency == "CLP" || mainCurrency == "$")  //si moneda sistema es pesos
                {
                    deployCurrency(oCompany);
                }
                else
                {
                    if (tipoCambio == "N")  //si tipo de cambio es indirecto
                    {
                        deployCurrencyCal(oCompany, mainCurrency);
                    }
                }
            }
            else
            {
                oLog.LogMsg("Parametros iniciales sin datos Tabla: OADM ", "A", "I");
            }
        }
예제 #24
0
파일: B1C.cs 프로젝트: valkiara/SB1Util
        public void copyDocuments(BoDocumentTypes docType)
        {
            try
            {
                SAPbobsCOM.Company comp = new SAPbobsCOM.Company();
                comp.CompanyDB    = "SBO_Digistar";
                comp.DbServerType = BoDataServerTypes.dst_MSSQL2008;
                comp.Server       = "B1DEV";
                comp.UserName     = "******";
                comp.Password     = "******";
                comp.DbUserName   = "******";
                comp.DbPassword   = "******";
                comp.Connect();

                Documents doc = (Documents)comp.GetBusinessObject(BoObjectTypes.oInvoices);
            }
            catch (Exception e)
            {
            }
        }
        public static string LoadObjectInfoFromRecordset(ref object Objeto, string Table, string WhereCondition)
        {
            string rpta = "N";

            SAPbobsCOM.Company SBO_Company = Conexion.oCompany;
            try
            {
                //get company service
                if (!SBO_Company.Connected)
                {
                    Conexion.Conectar_Aplicacion();
                }

                SAPbobsCOM.Recordset oRecordSet = (SAPbobsCOM.Recordset)SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                string sql = "select * from [" + Table + "] " + WhereCondition;
                oRecordSet.DoQuery(sql);

                if (oRecordSet.RecordCount > 0)
                {
                    rpta = "S";
                    oRecordSet.MoveFirst();
                    foreach (PropertyInfo propiedad in Objeto.GetType().GetProperties())
                    {
                        try
                        {
                            string tipoPropiedad   = propiedad.PropertyType.Name;
                            string NombrePropiedad = propiedad.Name;
                            object valorPropiedad  = propiedad.GetValue(Objeto, null);
                            propiedad.SetValue(Objeto, Convert.ChangeType(oRecordSet.Fields.Item(NombrePropiedad).Value, propiedad.PropertyType), null);
                        }
                        catch (Exception)
                        {
                            rpta = "N";
                        }
                    }
                }
            }
            catch (Exception) {}
            return(rpta);
        }
예제 #26
0
        public bool CheckCurrencyRate(SAPbobsCOM.Company pObjCompany)
        {
            DateTime  curDate           = DateTime.Today;
            bool      foundExchangeRate = false;
            Recordset oRecordSet        = null;
            SBObob    oSBObob           = null;

            //SAPbobsCOM.Company mObjCompany = null;
            try
            {
                oSBObob    = (SAPbobsCOM.SBObob)pObjCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge);
                oRecordSet = (Recordset)UGRS.Core.SDK.DI.DIApplication.Company.GetBusinessObject(BoObjectTypes.BoRecordset);

                try
                {
                    oRecordSet = oSBObob.GetCurrencyRate("USD", curDate);
                    var y = oRecordSet.RecordCount;

                    if (y >= 1)
                    {
                        foundExchangeRate = true;
                        //if (logWriter.DetLog == DetalleLog.FULL)
                        //{
                        //    logWriter.AppendLog("(9) Tipo de cambio ya registrado", currentCompany);
                        //}
                    }
                }
                catch (Exception ex)
                {
                    foundExchangeRate = false;  //-532462766: //Actualice el tipo de cambio
                }
            }
            catch (Exception ex)
            {
                foundExchangeRate = false;
            }
            MemoryUtility.ReleaseComObject(oSBObob);
            return(foundExchangeRate);
        }
        public static int GetNextCode(string UDO_Name)
        {
            int nProx = 0;

            SAPbobsCOM.Company SBO_Company = Conexion.oCompany;
            try
            {
                //get company service
                if (!SBO_Company.Connected)
                {
                    Conexion.Conectar_Aplicacion();
                }

                SAPbobsCOM.Recordset oRecorset = (SAPbobsCOM.Recordset)SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                string sql = "select isnull(max(CAST(Code as int)),0)+1 as Proximo from [@" + UDO_Name + "]";
                oRecorset.DoQuery(sql);
                nProx = (int)oRecorset.Fields.Item("Proximo").Value;
            }
            catch (Exception) { }

            return(nProx);
        }
예제 #28
0
        private void AddAuthorization(string strPermissionID, string strName, string strParentID, SAPbobsCOM.BoUPTOptions Option, string strFormId)
        {
            SAPbobsCOM.UserPermissionTree oUserPerTree;
            oUserPerTree = (SAPbobsCOM.UserPermissionTree)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserPermissionTree);

            if (!oUserPerTree.GetByKey(strPermissionID))
            {
                oUserPerTree.Name         = strName;
                oUserPerTree.PermissionID = strPermissionID;

                if (strParentID != "")
                {
                    oUserPerTree.ParentID = strParentID;
                    oUserPerTree.UserPermissionForms.FormType = strFormId;
                    oUserPerTree.IsItem = SAPbobsCOM.BoYesNoEnum.tYES;
                }

                oUserPerTree.Options = Option;
                int intStatus;
                intStatus = oUserPerTree.Add();

                string strErro = oCompany.GetLastErrorDescription();
            }
        }
예제 #29
0
        public void CorrectionJournalEntriesSecondLogic(CorrectionJournalEntriesParams entriesParams)
        {
            CleanIncompleteTransactions();
            SkipTransactionsWithoutAmount();

            Recordset recSet = (Recordset)_company.GetBusinessObject(BoObjectTypes.BoRecordset);
            string    query  = entriesParams.MustSkip
                ? $@"SELECT *
            FROM JDT1
            LEFT JOIN OJDT ON JDT1.TransId = OJDT.TransId
            WHERE CONVERT(DATE, OJDT.RefDate) >= '{entriesParams.StartDate:s}'
            AND CONVERT(DATE, OJDT.RefDate) <= '{entriesParams.EndDate:s}'   AND U_CorrectContraAcc is null AND OJDT.TransId Not In (select TransId from JDT1 where Line_ID > {entriesParams.MaxLine}) and U_ContraIsApproved = '02' ORDER BY OJDT.RefDate, OJDT.TransId, Line_ID"
                : $@"SELECT *
            FROM JDT1
            LEFT JOIN OJDT ON JDT1.TransId = OJDT.TransId
            WHERE CONVERT(DATE, OJDT.RefDate) >= '{entriesParams.StartDate:s}'
            AND CONVERT(DATE, OJDT.RefDate) <= '{entriesParams.EndDate:s}'    AND OJDT.TransId NOT IN (select TransId from JDT1 where Line_ID > {entriesParams.MaxLine}) and U_ContraIsApproved = '02' ORDER BY OJDT.RefDate, OJDT.TransId, Line_ID";

            recSet.DoQuery(query);

            List <JournalEntryLineModel> jdtLines = JournalEntryLineModelsFromRecordset(recSet);

            MainLogicSecond(jdtLines, entriesParams.WaitingTimeInMinutes);
        }
예제 #30
0
        public static void clsAPCreditMemo_ItemEvent(ref SAPbouiCOM.Application oApplication, ref SAPbobsCOM.Company oCompany, SAPbouiCOM.Form oSetupForm, ref SAPbouiCOM.ItemEvent pVal, ref bool BubbleEvent)
        {
            oForm            = oSetupForm;
            oHDBDataSource   = oForm.DataSources.DBDataSources.Item("ORPC");
            oChildDataSource = oForm.DataSources.DBDataSources.Item("RPC1");
            oMatrix          = (SAPbouiCOM.Matrix)oForm.Items.Item("38").Specific;

            if (pVal.BeforeAction)
            {
                switch (pVal.EventType)
                {
                case SAPbouiCOM.BoEventTypes.et_CLICK:
                    if (pVal.ItemUID == "38" && (pVal.ColUID == "U_Variance" || pVal.ColUID == "U_DiscExc"))
                    {
                        BubbleEvent = false;
                    }
                    if (oForm.Mode == SAPbouiCOM.BoFormMode.fm_OK_MODE || oForm.Mode == SAPbouiCOM.BoFormMode.fm_UPDATE_MODE)
                    {
                        if (pVal.ItemUID == "U_DocType")
                        {
                            BubbleEvent = false;
                        }
                    }
                    break;

                case SAPbouiCOM.BoEventTypes.et_PICKER_CLICKED:
                    if (pVal.ItemUID == "38" && pVal.ColUID == "U_Variance")
                    {
                        BubbleEvent = false;
                    }
                    break;

                case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED:
                    if (pVal.ItemUID == "btnSH")
                    {
                        if (((SAPbouiCOM.EditText)oForm.Items.Item("4").Specific).Value.Trim() == "")
                        {
                            oApplication.StatusBar.SetText("Select the Supplier....", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
                            BubbleEvent = false;
                        }

                        if (oHDBDataSource.GetValue("DocStatus", oHDBDataSource.Offset).ToString().Trim() != "O")
                        {
                            BubbleEvent = false;
                        }

                        // strDocEntry = oHDBDataSource.GetValue("DocEntry", 0).Trim();
                        //strDocType = oHDBDataSource.GetValue("U_DocType", 0).Trim();
                    }
                    break;

                default:
                    break;
                }
            }

            else if (pVal.BeforeAction == false)
            {
                switch (pVal.EventType)
                {
                case SAPbouiCOM.BoEventTypes.et_FORM_LOAD:
                    //Utilities.UtilitiesCls.CreateButtonItem(oForm, "btnSH", oForm.Items.Item("2").Left + oForm.Items.Item("2").Width + 6, oForm.Items.Item("2").Top, oForm.Items.Item("2").Width + 8, oForm.Items.Item("2").Height, "Purchase History", true, 0, "");
                    Utilities.UtilitiesCls.CreateButtonItem(oForm, "btnSH", oForm.Items.Item("46").Left, oForm.Items.Item("46").Top + 20, oForm.Items.Item("46").Width, oForm.Items.Item("2").Height, "Purchase History", true, 0, "46");
                    break;

                case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED:
                    if (pVal.ItemUID == "1")
                    {
                        if (pVal.ActionSuccess)
                        {
                            if (oWaitForm != null)
                            {
                                oWaitForm.Close();
                                oWaitForm = null;
                            }
                        }
                    }

                    if (pVal.ItemUID == "btnSH")
                    {
                        try
                        {
                            if (oWaitForm != null)
                            {
                                string strCardCode1 = ((SAPbouiCOM.EditText)oForm.Items.Item("4").Specific).Value.Trim();
                                string strCardCode2 = ((SAPbouiCOM.EditText)oWaitForm.Items.Item("6").Specific).Value.Trim();

                                if (strCardCode1 != strCardCode2)
                                {
                                    oWaitForm.Close();
                                    oWaitForm = null;
                                }
                            }
                        }
                        catch (Exception)
                        {
                            oWaitForm = null;
                        }

                        if (oWaitForm == null)
                        {
                            string strQry;
                            oWaitForm = clsSBO.LoadForm("EJ_OSSH.srf", "EJ_OSSH", oApplication);

                            ((SAPbouiCOM.EditText)oWaitForm.Items.Item("6").Specific).Value = ((SAPbouiCOM.EditText)oForm.Items.Item("4").Specific).Value.Trim();
                            ((SAPbouiCOM.EditText)oWaitForm.Items.Item("8").Specific).Value = ((SAPbouiCOM.EditText)oForm.Items.Item("54").Specific).Value.Trim();
                            oWaitForm.Freeze(true);
                            oWaitForm.DataSources.DataTables.Add("@dtTemp");
                            SAPbouiCOM.Grid oGrid;
                            oGrid      = (SAPbouiCOM.Grid)oWaitForm.Items.Item("4").Specific;
                            oRecordSet = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(BoObjectTypes.BoRecordset);
                            //  strQry = "Exec \"EJ_SupplierCMPurchaseHistory\"  '" + ((SAPbouiCOM.EditText)oForm.Items.Item("4").Specific).Value.Trim() + "'";
                            strQry = "Exec \"EJ_SupplierPurchaseHistory\"  '" + ((SAPbouiCOM.EditText)oForm.Items.Item("4").Specific).Value.Trim() + "'";

                            oWaitForm.DataSources.DataTables.Item(0).ExecuteQuery(strQry);
                            oGrid.DataTable = oWaitForm.DataSources.DataTables.Item(0);
                            oGrid.Columns.Item(0).Editable = true;
                            SAPbouiCOM.EditTextColumn oEditTxt = ((SAPbouiCOM.EditTextColumn)oGrid.Columns.Item(0));
                            oEditTxt.ChooseFromListUID     = "CFL_2";
                            oEditTxt.ChooseFromListAlias   = "ItemCode";
                            oGrid.Columns.Item(1).Editable = false;
                            oGrid.Columns.Item(2).Editable = true;
                            oGrid.Columns.Item(3).Editable = true;
                            oEditTxt = ((SAPbouiCOM.EditTextColumn)oGrid.Columns.Item(3));
                            oEditTxt.ChooseFromListUID     = "CFL_3";
                            oEditTxt.ChooseFromListAlias   = "UomCode";
                            oGrid.Columns.Item(4).Editable = true;
                            oGrid.Columns.Item(0).Editable = true;

                            for (int j = 5; j < oGrid.Columns.Count; j++)
                            {
                                oGrid.Columns.Item(j).Editable = false;
                            }

                            oGrid.AutoResizeColumns();
                            oGrid.DataTable.Rows.Add(1);

                            clsSupplierPurchaseHistory.oForm   = oWaitForm;
                            clsSupplierPurchaseHistory.oSOForm = oForm;
                            oWaitForm.Freeze(false);
                        }
                        else
                        {
                            oWaitForm.Visible = true;
                        }
                    }
                    break;

                case SAPbouiCOM.BoEventTypes.et_LOST_FOCUS:
                    if (oForm.Mode == SAPbouiCOM.BoFormMode.fm_ADD_MODE || oForm.Mode == SAPbouiCOM.BoFormMode.fm_UPDATE_MODE)
                    {
                        if (pVal.ItemUID == "12")
                        {
                            //oForm.DefButton = "btnSH";
                            // oForm.ActiveItem = "btnSH";
                            ((SAPbouiCOM.Button)oForm.Items.Item("btnSH").Specific).Item.Click(BoCellClickType.ct_Regular);
                        }
                    }
                    break;

                case SAPbouiCOM.BoEventTypes.et_FORM_CLOSE:
                    if (oWaitForm != null)
                    {
                        oWaitForm.Close();
                        oWaitForm = null;
                    }
                    break;

                default:
                    break;
                }
            }
        }