Exemplo n.º 1
1
        public static void AddAvarias(int idOOPR, string descricao, SAPbobsCOM.Company oCompany, SAPbouiCOM.Application SBO_Application)
        {
            SAPbobsCOM.GeneralService oGeneralService = null;
            SAPbobsCOM.GeneralData oGeneralData = null;
            SAPbobsCOM.GeneralDataParams oGeneralParams = null;
            SAPbobsCOM.CompanyService oCompanyService = null;
            string proxCode = GetProxCodeAvarias(oCompany);

            try
            {
                oCompanyService = oCompany.GetCompanyService();
                oGeneralService = oCompanyService.GetGeneralService("FLX_FB_AVR");
                oGeneralData = ((SAPbobsCOM.GeneralData)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)));
                oGeneralData.SetProperty("Code", proxCode);
                oGeneralData.SetProperty("Name", proxCode);
                oGeneralData.SetProperty("U_FLX_FB_AVR_IDOOPR", idOOPR);
                oGeneralData.SetProperty("U_FLX_FB_AVR_DESC", descricao);

                oGeneralParams = oGeneralService.Add(oGeneralData);
            }
            catch (Exception ex)
            {
                SBO_Application.MessageBox(ex.Message, 1, "Ok", "", "");
            }
        }
        public void CreateUserTable(string UserTableName, string UserTableDesc, SAPbobsCOM.BoUTBTableType UserTableType)
        {
            FindColumns = new GenericModel();
            FindColumns.Fields = new Dictionary<string, object>();
            Log.AppendLine();
            Log.AppendLine(UserTableName);
            Log.AppendFormat("Criação/Atualização da tabela de usuário {0}: ", UserTableName);

            SAPbobsCOM.UserTablesMD oUserTableMD = (SAPbobsCOM.UserTablesMD)SBOApp.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);
            // Remove a arroba do usertable Name
            UserTableName = UserTableName.Replace("@", "");

            bool bUpdate = oUserTableMD.GetByKey(UserTableName);

            oUserTableMD.TableName = UserTableName;
            oUserTableMD.TableDescription = UserTableDesc;
            oUserTableMD.TableType = UserTableType;

            if (bUpdate)
                //CodErro = oUserTableMD.Update();
                CodErro = 0;
            else
                CodErro = oUserTableMD.Add();
            this.ValidateAction();

            Marshal.ReleaseComObject(oUserTableMD);
            oUserTableMD = null;
        }
Exemplo n.º 3
1
        public static string GetProxCodeAvarias(SAPbobsCOM.Company oCompany)
        {
            SAPbobsCOM.Recordset RecSet = null;
            string QryStr = null;
            string proxCod = "";

            RecSet = ((SAPbobsCOM.Recordset)(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)));
            QryStr = "DECLARE @Numero AS INT SELECT @Numero = (select top 1 cast (Code as INT) + 1 from [SBO_SEA_Design_Prod].[dbo].[@FLX_FB_AVR] order by Code desc) if @Numero is null begin set @Numero = 0000000 + 1 end SELECT case len(CAST(@Numero AS varchar(7))) WHEN 1 THEN '000000' + CAST(@Numero AS varchar(7)) WHEN 2 THEN '00000' + CAST(@Numero AS varchar(7)) WHEN 3 THEN '0000' + CAST(@Numero AS varchar(7)) WHEN 4 THEN '000' + CAST(@Numero AS varchar(7)) WHEN 5 THEN '00' + CAST(@Numero AS varchar(7)) WHEN 6 THEN '0' + CAST(@Numero AS varchar(7)) WHEN 7 THEN CAST(@Numero AS varchar(7)) END";
            RecSet.DoQuery(QryStr);
            proxCod = Convert.ToString(RecSet.Fields.Item(0).Value);

            return proxCod;
        }
 public string ReadRecordSetData(SAPbobsCOM.Recordset oRecordSet, string field) //reordset data oku
 {
     return oRecordSet.Fields.Item(field).Value.ToString();
 }
        public void CreateUserField(string TableName, string FieldName, string FieldDescription, SAPbobsCOM.BoFieldTypes oType, SAPbobsCOM.BoFldSubTypes oSubType, int FieldSize, bool MandatoryYN = false, string DefaultValue = "")
        {
            if (FieldDescription.Length > 30)
            {
                FieldDescription = FieldDescription.Substring(0, 30);
            }
            if (FindColumns != null)
            {
                FindColumns.Fields.Add(FieldName, FieldDescription);
            }

            Log.AppendFormat(Environment.NewLine + "Criação/Atualização do Campo {0}.{1}: ", TableName, FieldName);
            SAPbobsCOM.UserFieldsMD oUserFieldsMD = ((SAPbobsCOM.UserFieldsMD)(SBOApp.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)));
            bool bUpdate;

            string Sql = " SELECT FieldId FROM CUFD WHERE TableID = '{0}' AND AliasID = '{1}' ";
            Sql = String.Format(Sql, TableName, FieldName);
            string FieldId = QueryForValue(Sql);

            if (FieldId != null)
            {
                bUpdate = oUserFieldsMD.GetByKey(TableName, Convert.ToInt32(FieldId));
            }
            else
                bUpdate = false;

            oUserFieldsMD.TableName = TableName;
            oUserFieldsMD.Name = FieldName;
            oUserFieldsMD.Description = FieldDescription;
            oUserFieldsMD.Type = oType;
            oUserFieldsMD.SubType = oSubType;
            oUserFieldsMD.Mandatory = GetSapBoolean(MandatoryYN);
            if (!String.IsNullOrEmpty(DefaultValue))
            {
                oUserFieldsMD.DefaultValue = DefaultValue;
            }

            if (FieldSize > 0)
                oUserFieldsMD.EditSize = FieldSize;

            if (bUpdate)
                //CodErro = oUserFieldsMD.Update();
                CodErro = 0;
            else
                CodErro = oUserFieldsMD.Add();
            this.ValidateAction();

            Marshal.ReleaseComObject(oUserFieldsMD);
            oUserFieldsMD = null;
        }
Exemplo n.º 6
0
        public static void UpdateAvarias(string code, string name, int idOOPR, string descricao, SAPbobsCOM.Company oCompany, SAPbouiCOM.Application SBO_Application)
        {
            SAPbobsCOM.GeneralService oGeneralService = null;
            SAPbobsCOM.GeneralData oGeneralData = null;
            SAPbobsCOM.CompanyService oCompanyService = null;

            try
            {
                oCompanyService = oCompany.GetCompanyService();
                oGeneralService = oCompanyService.GetGeneralService("FLX_FB_AVR");
                oGeneralData = ((SAPbobsCOM.GeneralData)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)));
                oGeneralData.SetProperty("Code", code);
                oGeneralData.SetProperty("Name", name);
                oGeneralData.SetProperty("U_FLX_FB_AVR_IDOOPR", idOOPR);
                oGeneralData.SetProperty("U_FLX_FB_AVR_DESC", descricao);

                oGeneralService.Update(oGeneralData);
            }
            catch (Exception ex)
            {
                SBO_Application.MessageBox(ex.Message, 1, "Ok", "", "");
            }
        }
        public bool SearchRecordset(SAPbobsCOM.Recordset oRecordSet, string field, string value)
        {
            HelperRecordset hrs = new HelperRecordset();

            if (oRecordSet.RecordCount != 0)
            {
                oRecordSet.MoveFirst();
                for (int i = 0; i < oRecordSet.RecordCount; i++)
                {
                    var val = oRecordSet.Fields.Item(field).Value.ToString();
                    if (val.Trim() == value.Trim())
                    {
                        return true;
                    }

                    oRecordSet.MoveNext();
                }

                return false;
            }
            else
                return false;
        }
Exemplo n.º 8
0
        public string Add_SalesQuotation(DataTable oDTSQData, SAPbobsCOM.Company oDICompany,
            string sCardCode, string sErrDesc)
        {
            string sReturnResult = string.Empty;
            string sFuncName = string.Empty;
            SAPbobsCOM.Documents oSalesQuotation;
            int lRetCode;

            try
            {
                sFuncName = "Add_SalesQuotation()";
                if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName);

                oSalesQuotation = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oQuotations);

                oSalesQuotation.CardCode = sCardCode;
                oSalesQuotation.DocDate = DateTime.Now.Date;
                oSalesQuotation.TaxDate = DateTime.Now.Date;
                oSalesQuotation.DocDueDate = DateTime.Now.Date;

                double iCount = 0;
                int sumOfQty = 0;

                foreach (DataRow iRow in oDTSQData.Rows)
                {
                    //if (iCount != 0)
                    //    oSalesQuotation.Lines.Add();
                    if (Convert.ToDouble(iRow["Qty"]) > 0)
                    {
                        //oSalesQuotation.Lines.SetCurrentLine();
                        oSalesQuotation.Lines.ItemCode = Convert.ToString(iRow["ItemCode"]);
                        oSalesQuotation.Lines.Quantity = Convert.ToInt32(iRow["Qty"]);
                        oSalesQuotation.Lines.Price = Convert.ToDouble(iRow["Price"]);

                        oSalesQuotation.Lines.UserFields.Fields.Item("U_STEP_CREATION_DT").Value = DateTime.Now.Date;
                        oSalesQuotation.Lines.UserFields.Fields.Item("U_STATUS").Value = "PENDING";
                        oSalesQuotation.Lines.UserFields.Fields.Item("U_NEXT_ACTION_BY").Value = Convert.ToString(iRow["ACTIONBY"]);
                        oSalesQuotation.Lines.UserFields.Fields.Item("U_INT_CASE_SEQ").Value = Convert.ToString(iRow["INTNO"]);
                        oSalesQuotation.Lines.Add();
                        //oSalesQuotation.Lines.VatGroup = "SR";
                        iCount = iCount + 1;
                        sumOfQty = sumOfQty + Convert.ToInt32(iRow["Qty"]);
                    }
                }

                if (sumOfQty > 0)
                {
                    lRetCode = oSalesQuotation.Add();

                    if (lRetCode != 0)
                    {
                        sErrDesc = oDICompany.GetLastErrorDescription();
                        sReturnResult = sErrDesc.ToString();
                        throw new ArgumentException(sErrDesc);
                    }
                    else
                    {
                        sReturnResult = "SUCCESS";
                        if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With SUCCESS ", sFuncName);
                    }
                }
                else
                {
                    sReturnResult = "";
                }
            }

            catch (Exception Ex)
            {

                sErrDesc = Ex.Message.ToString();
                oLog.WriteToErrorLogFile(sErrDesc, sFuncName);
                if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR  ", sFuncName);
                throw Ex;
            }

            return sReturnResult;
        }
Exemplo n.º 9
0
 internal static void removeUDO(UserObjectsMD uo, string name,
                     SAPbouiCOM.Application app, SAPbobsCOM.Company company)
 {
     int ret;
     string errMsg;
     if (uo.GetByKey(name))
     {
         ret = uo.Remove();
         if (ret != 0)
         {
             company.GetLastError(out ret, out errMsg);
             app.SetStatusBarMessage(string.Format("Error removing object {0}", name),
                 SAPbouiCOM.BoMessageTime.bmt_Short, true);
             throw new Exception(errMsg);
         }
         app.StatusBar.SetSystemMessage(string.Format("Removed field {0}", name),
             SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
     }
 }
Exemplo n.º 10
0
 internal static void removeTable(UserTablesMD ut, string name, SAPbouiCOM.Application app,
                                 SAPbobsCOM.Company company)
 {
     int ret;
     string errMsg;
     if (ut.GetByKey(name))
     {
         ret = ut.Remove();
         if (ret != 0)
         {
             company.GetLastError(out ret, out errMsg);
             app.SetStatusBarMessage("Error removing table " + name, SAPbouiCOM.BoMessageTime.bmt_Short, true);
             throw new Exception(errMsg);
         }
         app.StatusBar.SetSystemMessage("Removed table " + name,
             SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
     }
 }
Exemplo n.º 11
0
 internal static void removeField(UserFieldsMD uf, string tableName, int fieldID, 
                     SAPbouiCOM.Application app, SAPbobsCOM.Company company)
 {
     int ret;
     string errMsg;
     if (uf.GetByKey(tableName, fieldID))
     {
         ret = uf.Remove();
         if (ret != 0)
         {
             company.GetLastError(out ret, out errMsg);
             app.SetStatusBarMessage(string.Format("Error removing field {0}-{1}",
                 tableName, fieldID), SAPbouiCOM.BoMessageTime.bmt_Short, true);
             throw new Exception(errMsg);
         }
         app.StatusBar.SetSystemMessage(string.Format("Removed field {0}-{1}",
             tableName, fieldID),
             SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
     }
 }
Exemplo n.º 12
0
        public void loadComboEmGrid(string matrix, string combo, SAPbobsCOM.Recordset valores)
        {
            oMatrix = checked((SAPbouiCOM.Matrix)oForm.Items.Item(matrix).Specific);
            SAPbouiCOM.ComboBox oCombo = checked((SAPbouiCOM.ComboBox)oMatrix.Columns.Item(combo).Cells.Item(1).Specific);
            RemoveValoresDeCombo(ref oCombo);

            oCombo.ValidValues.Add("", "");

            int RecCount = valores.RecordCount;
            valores.MoveFirst();

            for (int RecIndex = 0; RecIndex <= RecCount - 1; RecIndex++)
            {
                oCombo.ValidValues.Add(Convert.ToString(valores.Fields.Item(0).Value), Convert.ToString(valores.Fields.Item(1).Value));
                valores.MoveNext();
            }
        }
Exemplo n.º 13
0
 public static string getItemCode(SAPbobsCOM.Company oCompany, string Col63)
 {
     string itemcode = "";
     SAPbobsCOM.Recordset ors = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
     ors.DoQuery("Select Left([@BOS_CCACT].U_Account,8) From [@BOS_CCACT] Where [@BOS_CCACT].U_Category = '"+ Col63 + "'");
     itemcode = ors.Fields.Item(0).Value.ToString();
     System.Runtime.InteropServices.Marshal.ReleaseComObject(ors);
     ors = null;
     GC.Collect();
     return itemcode;
 }
 public void CreateUserObject(string ObjectName, string ObjectDesc, string TableName, SAPbobsCOM.BoUDOObjType ObjectType, bool CanLog, bool CanYearTransfer, GenericModel findColumns)
 {
     this.CreateUserObject(ObjectName, ObjectDesc, TableName, ObjectType, CanLog, CanYearTransfer, false, false, false, true, true, 0, 0, findColumns);
 }
Exemplo n.º 15
0
 public static string getpodocnum(SAPbobsCOM.Company oCompany)
 {
     string itemcode = "";
     SAPbobsCOM.Recordset ors = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
     ors.DoQuery("Select DocNum From OPOR Where DocEntry=(Select MAX(DocEntry) From OPOR)");
     itemcode = ors.Fields.Item(0).Value.ToString();
     System.Runtime.InteropServices.Marshal.ReleaseComObject(ors);
     ors = null;
     GC.Collect();
     return itemcode;
 }
Exemplo n.º 16
0
        /// <summary>
        /// A method for adding new field to B1 table
        /// </summary>
        /// <param name="name">Field Name</param>
        /// <param name="description">Field description</param>
        /// <param name="tableName">Table the field will be added to</param>
        /// <param name="fieldType">Field Type</param>
        /// <param name="size">Field size in the database</param>
        /// <param name="subType"></param>
        /// <param name="mandatory"></param>
        /// <param name="addedToUDT">If this field will be added to system table or User defined table</param>
        /// <param name="valiedValue">The default selected value</param>
        /// <param name="validValues">Add the values seperated by comma "," for value and description ex:(Value,Description)</param>
        public static void AddField(string name, string description, string tableName, SAPbobsCOM.BoFieldTypes fieldType, Nullable<int> size, SAPbobsCOM.BoYesNoEnum mandatory, SAPbobsCOM.BoFldSubTypes subType, bool addedToUDT, string validValue, params string[] validValues)
        {
           
            var objUserFieldMD = B1Helper.diCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields) as SAPbobsCOM.UserFieldsMD;
            try
            {
                if (addedToUDT)
                    tableName = string.Format("@{0}", tableName);
                if (!IsFieldExists(name, tableName))
                {
                    objUserFieldMD.TableName = tableName;
                    objUserFieldMD.Name = name;
                    objUserFieldMD.Description = description;
                    objUserFieldMD.Type = fieldType;
                    objUserFieldMD.Mandatory = mandatory;

                    if (size == null || size <= 0)
                        size = 10;

                    if (fieldType != SAPbobsCOM.BoFieldTypes.db_Numeric)
                        objUserFieldMD.Size = (int)size;
                    else
                        objUserFieldMD.EditSize = (int)size;


                    objUserFieldMD.SubType = subType;

                    if (validValue != null)
                        objUserFieldMD.DefaultValue = validValue;

                    if (validValues != null)
                    {
                        foreach (string s in validValues)
                        {
                            var valuesAttributes = s.Split(',');
                            if (valuesAttributes.Length == 2)
                                objUserFieldMD.ValidValues.Description = valuesAttributes[1];
                            objUserFieldMD.ValidValues.Value = valuesAttributes[0];
                            objUserFieldMD.ValidValues.Add();
                        }
                    }

                    if (objUserFieldMD.Add() != 0)
                    {
                        var error = Utilities.GetErrorMessage();
                        Utilities.LogException(error);
                    }
                }
            }
            catch (Exception ex)
            {
                Utilities.LogException(ex);
            }
            finally
            {
                objUserFieldMD.ReleaseObject();
            }
        }
Exemplo n.º 17
0
 public static void AddTable(string tableName, string description, SAPbobsCOM.BoUTBTableType tableType)
 {
     var oUserTablesMD = B1Helper.DiCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables) as SAPbobsCOM.UserTablesMD;
     try
     {
         if (!oUserTablesMD.GetByKey(tableName))
         {
             oUserTablesMD.TableName = tableName;
             oUserTablesMD.TableDescription = description;
             oUserTablesMD.TableType = tableType;
             if (oUserTablesMD.Add() != 0)
             {
                 var error = B1Helper.DiCompany.GetLastErrorDescription();
             }
         }
     }
     catch (Exception ex)
     {
         Utilities.LogException(ex);
     }
     finally
     {
         oUserTablesMD.ReleaseObject();
     }
 }
Exemplo n.º 18
0
 public static string getProduct(SAPbobsCOM.Company oCompany, string Col6, string Col7)
 {
     string retvalue = "";
     SAPbobsCOM.Recordset ors = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
     string empname = Col7 + " " + Col6;
     ors.DoQuery("select[@BOS_CCDIM].U_Product From [@BOS_CCDIM] Where [@BOS_CCDIM].U_Employee ='" + empname + "'");
     retvalue = ors.Fields.Item(0).Value.ToString();
     System.Runtime.InteropServices.Marshal.ReleaseComObject(ors);
     ors = null;
     GC.Collect();
     return retvalue;
 }
        /// <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);
        }
Exemplo n.º 20
0
        public SAPbobsCOM.Company ConnectToTargetCompany(SAPbobsCOM.Company oCompany, string sUserName, string sPassword, string sDBName,
            string sServer, string sLicServerName, string sDBUserName
            , string sDBPassword, string sErrDesc)
        {
            string sFuncName = string.Empty;
            //SAPbobsCOM.Company oCompany = new SAPbobsCOM.Company();
            long lRetCode;

            try
            {
                sFuncName = "ConnectToTargetCompany()";

                if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName);

                if (oCompany != null)
                {
                    if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Disconnecting the Company object - Company Name " + oCompany.CompanyName, sFuncName);
                    oCompany.Disconnect();
                }
                oCompany = new SAPbobsCOM.Company();
                if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("After Initializing Company Connection ", sFuncName);
                oCompany.Server = sServer;
                oCompany.LicenseServer = sLicServerName;
                oCompany.DbUserName = sDBUserName;
                oCompany.DbPassword = sDBPassword;
                oCompany.language = SAPbobsCOM.BoSuppLangs.ln_English;
                oCompany.UseTrusted = false;
                oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2012;

                oCompany.CompanyDB = sDBName;// sDataBaseName;
                oCompany.UserName = sUserName;
                oCompany.Password = sPassword;

                if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Connecting the Database...", sFuncName);

                lRetCode = oCompany.Connect();

                if (lRetCode != 0)
                {

                    throw new ArgumentException(oCompany.GetLastErrorDescription());
                }
                else
                {
                    if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Company Connection Established", sFuncName);
                    if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With SUCCESS", sFuncName);
                    return oCompany;
                }

            }
            catch (Exception Ex)
            {

                sErrDesc = Ex.Message.ToString();
                if (p_iDebugMode == DEBUG_ON) oLog.WriteToErrorLogFile(sErrDesc, sFuncName);
                if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR  ", sFuncName);
                throw Ex;
            }
        }
Exemplo n.º 21
0
 /// <summary>
 /// A method for adding new field to B1 table
 /// </summary>
 /// <param name="name">Field Name</param>
 /// <param name="description">Field description</param>
 /// <param name="tableName">Table the field will be added to</param>
 /// <param name="fieldType">Field Type</param>
 /// <param name="size">Field size in the database</param>     
 /// <param name="mandatory">bool: if the value is mandatory to be filled</param>
 public static void AddField(string name, string description, string tableName, SAPbobsCOM.BoFieldTypes fieldType, SAPbobsCOM.BoYesNoEnum mandatory, bool addedToUDT)
 {
     AddField(name, description, tableName, fieldType, null, mandatory, 0, addedToUDT);
 }
 public void CreateUserObject(string ObjectName, string ObjectDesc, string TableName, SAPbobsCOM.BoUDOObjType ObjectType, bool CanLog, bool CanYearTransfer)
 {
     this.CreateUserObject(ObjectName, ObjectDesc, TableName, ObjectType, CanLog, CanYearTransfer, false, false, false, true, true, 0, 0, null);
 }
Exemplo n.º 23
0
        public string AddDocuments(DataTable oDt, SAPbobsCOM.Company oCompany, string sDocType)
        {
            string sFuncName = "AddSales_Order";
            string sItemCode;
            SAPbobsCOM.Documents oSalesOrder;
            SAPbobsCOM.Recordset oRecSet;
            string sSoDocEntry;
            string sSql;
            int iRetCode;
            double dPrice = 0;
            double dFee = 0;

            try
            {
                if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName);

                oSalesOrder = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
                double iCount = 0;

                foreach (DataRow iRow in oDt.Rows)
                {
                    if (Convert.ToDouble(iRow["Qty"]) > 0)
                    {
                        oSalesOrder.CardCode = Convert.ToString(iRow["CaseNo"]);
                        oSalesOrder.DocDate = DateTime.Now.Date;
                        oSalesOrder.TaxDate = DateTime.Now.Date;
                        oSalesOrder.DocDueDate = DateTime.Now.Date;
                        oSalesOrder.NumAtCard = Convert.ToString(iRow["DocNum"]) + "/" + Convert.ToString(iRow["LineNum"]);

                        if (iCount > 0)
                        {
                            oSalesOrder.Lines.Add();
                        }

                        sSql = "select U_PROPERTY_PURPRC [Price] from [OCRD] WITH (NOLOCK) where CardCode = '" + Convert.ToString(iRow["CaseNo"]) + "'";
                        if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("OCRD Price - SQL Query" + sSql, sFuncName);
                        oRecSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                        oRecSet.DoQuery(sSql);
                        if (oRecSet.RecordCount > 0)
                        {
                            dPrice = Convert.ToDouble(oRecSet.Fields.Item("Price").Value);
                        }

                        sSql = "SELECT DBO.GETFEE('" + Convert.ToString(iRow["ItemCode"]) + "','" + Convert.ToString(iRow["CaseNo"]) + "', '" + dPrice + "','','','') [FeePrice]";
                        if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("GetFEE - SQL Query" + sSql, sFuncName);
                        oRecSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                        oRecSet.DoQuery(sSql);
                        if (oRecSet.RecordCount > 0)
                        {
                            dFee = Convert.ToDouble(oRecSet.Fields.Item("FeePrice").Value);
                        }

                        sItemCode = Convert.ToString(iRow["ItemCode"]);
                        oSalesOrder.Lines.ItemCode = sItemCode;
                        oSalesOrder.Lines.Quantity = Convert.ToDouble(iRow["Qty"]);
                        //oSalesOrder.Lines.Price = Convert.ToDouble(iRow["Price"]);
                        //oSalesOrder.Lines.UnitPrice = Convert.ToDouble(iRow["Price"]);
                        oSalesOrder.Lines.Price = dFee;
                        oSalesOrder.Lines.UnitPrice = dFee;

                        sSql = "SELECT U_CASE_BRANCH,U_LOAN_MSTR_BANKCODE,ProjectCod FROM OCRD WITH (NOLOCK) WHERE CardCode = '" + Convert.ToString(iRow["CaseNo"]) + "'";
                        oRecSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                        oRecSet.DoQuery(sSql);
                        if (oRecSet.RecordCount > 0)
                        {
                            oSalesOrder.Lines.COGSCostingCode = oRecSet.Fields.Item("U_CASE_BRANCH").Value;
                            oSalesOrder.Lines.COGSCostingCode2 = oRecSet.Fields.Item("U_LOAN_MSTR_BANKCODE").Value;
                            oSalesOrder.Lines.ProjectCode = oRecSet.Fields.Item("ProjectCod").Value;
                        }

                        iCount = iCount + 1;
                    }
                }

                iRetCode = oSalesOrder.Add();
                if (iRetCode != 0)
                {
                    sErrDesc = oCompany.GetLastErrorDescription(); throw new ArgumentException(sErrDesc);
                }
                else
                {
                    sSoDocEntry = oCompany.GetNewObjectKey();
                }

                if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With SUCCESS ", sFuncName);
            }
            catch (Exception ex)
            {
                sErrDesc = ex.Message.ToString();
                oLog.WriteToErrorLogFile(sErrDesc, sFuncName);
                if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR  ", sFuncName);
                throw ex;
            }

            return sSoDocEntry;
        }
        public void CreateUserObject(string ObjectName, string ObjectDesc, string TableName, SAPbobsCOM.BoUDOObjType ObjectType, bool CanLog, bool CanYearTransfer, bool CanCancel, bool CanClose, bool CanCreateDefaultForm, bool CanDelete, bool CanFind, int FatherMenuId, int menuPosition, GenericModel findColumns)
        {
            // se não preenchido um table name separado, usa o mesmo do objeto
            if (String.IsNullOrEmpty(TableName))
                TableName = ObjectName;

            Log.AppendFormat("Criação/Atualização do Objeto de usuário {0}", ObjectName);

            SAPbobsCOM.UserObjectsMD UserObjectsMD = (SAPbobsCOM.UserObjectsMD)SBOApp.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD);

            // Remove a arroba do usertable Name
            TableName = TableName.Replace("@", "");

            bool bUpdate = UserObjectsMD.GetByKey(ObjectName);

            UserObjectsMD.Code = ObjectName;
            UserObjectsMD.Name = ObjectDesc;
            UserObjectsMD.ObjectType = ObjectType;
            UserObjectsMD.TableName = TableName;

            //UserObjectsMD.CanArchive = GetSapBoolean(CanArchive);
            UserObjectsMD.CanCancel = GetSapBoolean(CanCancel);
            UserObjectsMD.CanClose = GetSapBoolean(CanClose);
            UserObjectsMD.CanCreateDefaultForm = GetSapBoolean(CanCreateDefaultForm);
            UserObjectsMD.CanDelete = GetSapBoolean(CanDelete);
            UserObjectsMD.CanFind = GetSapBoolean(CanFind);
            UserObjectsMD.CanLog = GetSapBoolean(CanLog);
            UserObjectsMD.CanYearTransfer = GetSapBoolean(CanYearTransfer);

            if (CanCreateDefaultForm)
            {
                UserObjectsMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tYES;
                UserObjectsMD.CanCancel = GetSapBoolean(CanCancel);
                UserObjectsMD.CanClose = GetSapBoolean(CanClose);
                UserObjectsMD.CanDelete = GetSapBoolean(CanDelete);
                UserObjectsMD.CanFind = GetSapBoolean(CanFind);
                UserObjectsMD.ExtensionName = "";
                UserObjectsMD.OverwriteDllfile = SAPbobsCOM.BoYesNoEnum.tYES;
                UserObjectsMD.UseUniqueFormType = SAPbobsCOM.BoYesNoEnum.tYES;
                UserObjectsMD.ManageSeries = SAPbobsCOM.BoYesNoEnum.tYES;

                UserObjectsMD.FormColumns.FormColumnAlias = "Code";
                UserObjectsMD.FormColumns.FormColumnDescription = "Código";
                UserObjectsMD.FormColumns.Add();

                UserObjectsMD.FormColumns.FormColumnAlias = "Name";
                UserObjectsMD.FormColumns.FormColumnDescription = "Descrição";
                UserObjectsMD.FormColumns.Editable = SAPbobsCOM.BoYesNoEnum.tYES;
                UserObjectsMD.FormColumns.Add();

                UserObjectsMD.FindColumns.ColumnAlias = "Code";
                UserObjectsMD.FindColumns.ColumnDescription = "Código";
                UserObjectsMD.FindColumns.Add();

                UserObjectsMD.FindColumns.ColumnAlias = "Name";
                UserObjectsMD.FindColumns.ColumnDescription = "Descrição";
                UserObjectsMD.FindColumns.Add();

                if (findColumns != null)
                {
                    FindColumns = findColumns;
                }

                if (FindColumns != null && FindColumns.Fields != null)
                {
                    foreach (KeyValuePair<string, object> pair in FindColumns.Fields)
                    {
                        UserObjectsMD.FindColumns.ColumnAlias = pair.Key;
                        UserObjectsMD.FindColumns.ColumnDescription = pair.Value.ToString();
                        UserObjectsMD.FindColumns.Add();
                    }
                }

                UserObjectsMD.FatherMenuID = FatherMenuId;
                UserObjectsMD.Position = menuPosition;
                UserObjectsMD.MenuItem = SAPbobsCOM.BoYesNoEnum.tYES;
                UserObjectsMD.MenuUID = ObjectName;
                UserObjectsMD.MenuCaption = ObjectDesc;
            }

            if (bUpdate)
            {
                //CodErro = UserObjectsMD.Update();
            }
            else
                CodErro = UserObjectsMD.Add();

            this.ValidateAction();

            Marshal.ReleaseComObject(UserObjectsMD);
            UserObjectsMD = null;
            FindColumns = new GenericModel();
            FindColumns.Fields = new Dictionary<string, object>();
        }
Exemplo n.º 25
0
 public static int getPOCount(SAPbobsCOM.Company oCompany,string ponumber)
 {
     int pocount = 0;
     SAPbobsCOM.Recordset ors = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
     ors.DoQuery("Select Count(U_concurpo) from OPOR Where U_concurpo='"+ ponumber +"'");
     pocount = Int32.Parse(ors.Fields.Item(0).Value.ToString());
     System.Runtime.InteropServices.Marshal.ReleaseComObject(ors);
     ors = null;
     GC.Collect();
     return pocount;
 }
Exemplo n.º 26
0
 /// <summary>
 /// A method for adding new field to B1 table
 /// </summary>
 /// <param name="name">Field Name</param>
 /// <param name="description">Field description</param>
 /// <param name="tableName">Table the field will be added to</param>
 /// <param name="fieldType">Field Type</param>
 /// <param name="size">Field size in the database</param>       
 /// <param name="mandatory">bool: if the value is mandatory to be filled</param>
 /// <param name="subType"></param>
 /// <param name="addedToUDT">If this field will be added to system table or User defined table</param>
 public static void AddField(string name, string description, string tableName, SAPbobsCOM.BoFieldTypes fieldType, Nullable<int> size, SAPbobsCOM.BoYesNoEnum mandatory, SAPbobsCOM.BoFldSubTypes subType, bool addedToUDT)
 {
     AddField(name, description, tableName, fieldType, size, mandatory, subType, addedToUDT, null);
 }
Exemplo n.º 27
0
        public void loadCombo(string combo, SAPbobsCOM.Recordset valores)
        {
            string sPrimeirovalorCombo = "";
            oNewItem = oForm.Items.Item(combo);
            SAPbouiCOM.ComboBox oCombo = ((SAPbouiCOM.ComboBox)(oNewItem.Specific));
            RemoveValoresDeCombo(ref oCombo);

            oCombo.ValidValues.Add("", "");

            int RecCount = valores.RecordCount;
            valores.MoveFirst();

            for (int RecIndex = 0; RecIndex <= RecCount - 1; RecIndex++)
            {
                //Se for combo de ambientes da aba de Entrevista
                if ((combo == "Ent_Amb") & (RecIndex == 0))
                    sPrimeirovalorCombo = valores.Fields.Item(0).Value.ToString();
                oCombo.ValidValues.Add(Convert.ToString(valores.Fields.Item(0).Value), Convert.ToString(valores.Fields.Item(1).Value));
                valores.MoveNext();
            }

            //Se for combo de ambientes da aba de Entrevista
            if (combo == "Ent_Amb")
            {
                oCombo.Select(sPrimeirovalorCombo, SAPbouiCOM.BoSearchKey.psk_ByValue);
            }
        }
Exemplo n.º 28
0
        public static bool CreateUdo(string udoName, string description, string tableName, SAPbobsCOM.BoUDOObjType nObjectType, List<string> findFields, params string[] childTables)
        {
            var oUserObjectMD = B1Helper.DiCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD) as SAPbobsCOM.UserObjectsMD;
            try
            {
                if (!oUserObjectMD.GetByKey(udoName))
                {
                    oUserObjectMD.CanCancel = SAPbobsCOM.BoYesNoEnum.tYES;
                    oUserObjectMD.CanClose = SAPbobsCOM.BoYesNoEnum.tYES;
                    oUserObjectMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tNO;
                    oUserObjectMD.CanDelete = SAPbobsCOM.BoYesNoEnum.tYES;
                    oUserObjectMD.CanFind = SAPbobsCOM.BoYesNoEnum.tYES;
                    oUserObjectMD.FindColumns.ColumnAlias = "DocEntry";

                    if (findFields != null)
                    {
                        for (int i = 0; i < findFields.Count; i++)
                        {
                            if (i + 1 != findFields.Count)
                                oUserObjectMD.FindColumns.Add();

                            oUserObjectMD.FindColumns.SetCurrentLine(i);
                            oUserObjectMD.FindColumns.ColumnAlias = findFields[i];
                            
                        }
                    }

                    oUserObjectMD.CanLog = SAPbobsCOM.BoYesNoEnum.tNO;
                    oUserObjectMD.LogTableName = string.Empty;
                    oUserObjectMD.CanYearTransfer = SAPbobsCOM.BoYesNoEnum.tNO;
                    oUserObjectMD.ExtensionName = string.Empty;

                    if (childTables != null)
                    {
                        for (int i = 0; i < childTables.Length; i++)
                        {
                            //oUserObjectMD.ChildTables.TableName = childTables[i];
                            if (i + 1 != childTables.Length)
                                oUserObjectMD.ChildTables.Add();

                            oUserObjectMD.ChildTables.SetCurrentLine(i);
                            oUserObjectMD.ChildTables.TableName = childTables[i];

                        }
                    }

                    oUserObjectMD.ManageSeries = SAPbobsCOM.BoYesNoEnum.tNO;
                    oUserObjectMD.Code = udoName;
                    oUserObjectMD.Name = description;
                    oUserObjectMD.ObjectType = nObjectType;
                    oUserObjectMD.TableName = tableName;

                    if (oUserObjectMD.Add() != 0)
                    {
                        var err = Utilities.GetErrorMessage();
                        returnValue = false;
                    }
                    else
                        returnValue = true;

                }
            }
            catch (Exception ex)
            {
                Utilities.LogException(ex);
            }
            finally
            {
                oUserObjectMD.ReleaseObject();
            }

            return returnValue;
        }
Exemplo n.º 29
0
        public string CreateSalesQuote(DataTable oDt, SAPbobsCOM.Company oCompany)
        {
            string sFuncName = "CreateSalesQuote";
            SAPbobsCOM.Documents oSalesQuote;
            string sSql;
            int sumOfQty = 0;
            string sReturnResult = string.Empty;
            SAPbobsCOM.Recordset oRecSet;
            string sCaseNo = string.Empty;
            int sQuoteEntry = 0;

            try
            {
                if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName);

                oSalesQuote = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oQuotations);
                double iCount = 0;

                sCaseNo = Convert.ToString(oDt.Rows[0]["CaseNo"]);

                sSql = "SELECT DocEntry FROM OQUT WITH (NOLOCK) WHERE CardCode = '" + sCaseNo + "' AND DocStatus = 'O' AND CANCELED = 'N'";
                oRecSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                oRecSet.DoQuery(sSql);
                if (oRecSet.RecordCount > 0)
                {
                    sQuoteEntry = oRecSet.Fields.Item("DocEntry").Value;
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oRecSet);

                if (oSalesQuote.GetByKey(sQuoteEntry))
                {
                    foreach (DataRow iRow in oDt.Rows)
                    {
                        if (Convert.ToDouble(iRow["Qty"]) > 0)
                        {
                            if (oSalesQuote.Lines.Count > 0)
                            {
                                oSalesQuote.Lines.Add();
                            }
                            oSalesQuote.Lines.ItemCode = Convert.ToString(iRow["ItemCode"]);
                            oSalesQuote.Lines.Quantity = Convert.ToDouble(iRow["Qty"]);
                            oSalesQuote.Lines.Price = Convert.ToDouble(iRow["Price"]);
                            oSalesQuote.Lines.UnitPrice = Convert.ToDouble(iRow["Price"]);

                            oSalesQuote.Lines.UserFields.Fields.Item("U_STEP_CREATION_DT").Value = DateTime.Now.Date;
                            oSalesQuote.Lines.UserFields.Fields.Item("U_INT_CASE_SEQ").Value = Convert.ToString(iRow["IntNo"]);
                            oSalesQuote.Lines.UserFields.Fields.Item("U_NEXT_ACTION_BY").Value = Convert.ToString(iRow["ActionBy"]);

                            sSql = "SELECT U_CASE_BRANCH,U_LOAN_MSTR_BANKCODE,ProjectCod FROM OCRD WITH (NOLOCK) WHERE CardCode = '" + sCaseNo + "'";
                            oRecSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                            oRecSet.DoQuery(sSql);
                            if (oRecSet.RecordCount > 0)
                            {
                                oSalesQuote.Lines.COGSCostingCode = oRecSet.Fields.Item("U_CASE_BRANCH").Value;
                                oSalesQuote.Lines.COGSCostingCode2 = oRecSet.Fields.Item("U_LOAN_MSTR_BANKCODE").Value;
                                oSalesQuote.Lines.ProjectCode = oRecSet.Fields.Item("ProjectCod").Value;
                            }

                            sumOfQty = sumOfQty + Convert.ToInt32(iRow["Qty"]);
                        }
                    }
                    if (sumOfQty > 0)
                    {
                        if (oSalesQuote.Update() != 0)
                        {
                            sErrDesc = oCompany.GetLastErrorDescription();
                            sReturnResult = sErrDesc.ToString();
                            throw new ArgumentException(sErrDesc);
                        }
                        else
                        {
                            sReturnResult = "SUCCESS";
                            if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With SUCCESS ", sFuncName);
                        }
                    }
                    else
                    {
                        sReturnResult = "";
                    }
                }
                else
                {
                    foreach (DataRow iRow in oDt.Rows)
                    {
                        if (Convert.ToDouble(iRow["Qty"]) > 0)
                        {

                            oSalesQuote.CardCode = Convert.ToString(iRow["CaseNo"]);
                            oSalesQuote.DocDate = DateTime.Now.Date;
                            oSalesQuote.TaxDate = DateTime.Now.Date;
                            oSalesQuote.DocDueDate = DateTime.Now.Date;

                            if (iCount > 0)
                            {
                                oSalesQuote.Lines.Add();
                            }

                            oSalesQuote.Lines.ItemCode = Convert.ToString(iRow["ItemCode"]);
                            oSalesQuote.Lines.Quantity = Convert.ToDouble(iRow["Qty"]);
                            oSalesQuote.Lines.Price = Convert.ToDouble(iRow["Price"]);
                            oSalesQuote.Lines.UnitPrice = Convert.ToDouble(iRow["Price"]);

                            oSalesQuote.Lines.UserFields.Fields.Item("U_STEP_CREATION_DT").Value = DateTime.Now.Date;
                            oSalesQuote.Lines.UserFields.Fields.Item("U_INT_CASE_SEQ").Value = Convert.ToString(iRow["IntNo"]);
                            oSalesQuote.Lines.UserFields.Fields.Item("U_NEXT_ACTION_BY").Value = Convert.ToString(iRow["ActionBy"]);

                            sSql = "SELECT U_CASE_BRANCH,U_LOAN_MSTR_BANKCODE,ProjectCod FROM OCRD WITH (NOLOCK) WHERE CardCode = '" + Convert.ToString(iRow["CaseNo"]) + "'";
                            oRecSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                            oRecSet.DoQuery(sSql);
                            if (oRecSet.RecordCount > 0)
                            {
                                oSalesQuote.Lines.COGSCostingCode = oRecSet.Fields.Item("U_CASE_BRANCH").Value;
                                oSalesQuote.Lines.COGSCostingCode2 = oRecSet.Fields.Item("U_LOAN_MSTR_BANKCODE").Value;
                                oSalesQuote.Lines.ProjectCode = oRecSet.Fields.Item("ProjectCod").Value;
                            }

                            sumOfQty = sumOfQty + Convert.ToInt32(iRow["Qty"]);
                            iCount = iCount + 1;
                        }
                    }

                    if (sumOfQty > 0)
                    {
                        if (oSalesQuote.Add() != 0)
                        {
                            sErrDesc = oCompany.GetLastErrorDescription();
                            sReturnResult = sErrDesc.ToString();
                            throw new ArgumentException(sErrDesc);
                        }
                        else
                        {
                            sReturnResult = "SUCCESS";
                            if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With SUCCESS ", sFuncName);
                        }
                    }
                    else
                    {
                        sReturnResult = "";
                    }
                }
            }
            catch (Exception ex)
            {
                sErrDesc = ex.Message.ToString();
                oLog.WriteToErrorLogFile(sErrDesc, sFuncName);
                if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR  ", sFuncName);
                throw ex;
            }
            return sReturnResult;
        }
        public void SelectComboBoxValue(SAPbouiCOM.Form oForm, SAPbobsCOM.Recordset oRecordSet, string uniqId, string field) //combobox a değer set et
        {
            try
            {
                string val = oRecordSet.Fields.Item(field).Value.ToString();
                ((SAPbouiCOM.ComboBox)oForm.Items.Item(uniqId).Specific).Select(val);
            }
            catch
            {

            }
        }