//Verificar existencia de campos de usuário public bool fExiteCampo(string cTable, string cField) { sboRecordSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); strQuery = string.Format("Select Count(*) From CUFD (NOLOCK) Where TableID='{0}' and AliasID='{1}'", cTable, cField); sboRecordSet.DoQuery(strQuery); sboRecordSet.MoveFirst(); if (sboRecordSet.Fields.Item(0).Value <= 0) { sboRecordSet = null; return(false); } else { sboRecordSet = null; return(true); } }
//Verificar se campo existe dentro de tabela public int fFieldId(string cTabela, string cCampo) { sboRecordSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); strQuery = " SELECT FieldID FROM CUFD (NOLOCK) "; strQuery += " Where TableID='" + cTabela + "' and "; strQuery += " AliasID='" + cCampo + "'"; sboRecordSet.DoQuery(strQuery); sboRecordSet.MoveFirst(); if (sboRecordSet.Fields.Item(0).Value >= 0) { return(sboRecordSet.Fields.Item(0).Value); } else { sboRecordSet = null; return(-1); } }
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); }
// Seta valor com defalut em campo de usuário public bool fExisteValorDefaultSet(string cTabela, string cCampoID, string Valor) { sboRecordSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); strQuery = "Select Count(*) From CUFD (NOLOCK) "; strQuery += "Where TableID='" + cTabela + "' and "; strQuery += " FieldID='" + cCampoID + "' and"; strQuery += " dflt='" + Valor + "'"; sboRecordSet.DoQuery(strQuery); sboRecordSet.MoveFirst(); if ((sboRecordSet.Fields.Item(0).Value) <= 0) { sboRecordSet = null; return(false); } else { sboRecordSet = null; return(true); } }
public static string CheckIfValidOrNotAllLine(SAPbobsCOM.Recordset rsConfigData, string documentType) { try { string controlName = rsConfigData.Fields.Item("U_ControlName").Value.ToString(); string controlType = rsConfigData.Fields.Item("U_ControlType").Value.ToString(); string accessMatrixKey = rsConfigData.Fields.Item("U_AccessMatrixKey").Value.ToString(); string itemId = rsConfigData.Fields.Item("U_ItemId").Value.ToString(); string colId = rsConfigData.Fields.Item("U_ColumnId").Value.ToString(); string relatedItemId = rsConfigData.Fields.Item("U_RelatedItem").Value.ToString(); string relatedColId = rsConfigData.Fields.Item("U_RelatedColumn").Value.ToString(); string relatedItemId2 = rsConfigData.Fields.Item("U_RelatedItem2").Value.ToString(); string relatedColId2 = rsConfigData.Fields.Item("U_RelatedColumn2").Value.ToString(); string result = "Invalid " + controlName + " at line : "; bool isValid = true, isValidAll = true; SAPbobsCOM.Recordset rs = null; if (controlName == "Business Partners") { rs = GetBusinessPartnersByUser(); } else if (controlName.Contains("Dimension")) { string branch = ""; bool isBranchId = false; dynamic BranchControl = AddOnUtilities.oApplication.Forms.ActiveForm.Items.Item(relatedItemId2).Specific; if (BranchControl is SAPbouiCOM.ComboBox) { branch = ((SAPbouiCOM.ComboBox)AddOnUtilities.oApplication.Forms.ActiveForm.Items.Item(relatedItemId2).Specific).Value; isBranchId = true; } else //if(BranchControl is SAPbouiCOM.EditText) { branch = ((SAPbouiCOM.EditText)AddOnUtilities.oApplication.Forms.ActiveForm.Items.Item(relatedItemId2).Specific).Value; isBranchId = false; } rs = GetDimensionsByBranch(controlName, branch, isBranchId); } else if (controlName == "Project") { rs = GetProjectsByUser(); } else if (controlName == "G/L Account") { rs = GetAccountsByUser(); } SAPbouiCOM.Matrix oMatrix = (SAPbouiCOM.Matrix)AddOnUtilities.oApplication.Forms.ActiveForm.Items.Item(relatedItemId).Specific; int RowCount = oMatrix.RowCount; for (int CurrentRow = 1; CurrentRow < RowCount; CurrentRow++) { string input = ((SAPbouiCOM.EditText)(oMatrix.Columns.Item(relatedColId).Cells.Item(CurrentRow).Specific)).Value; rs.MoveFirst(); if (input != "") { while (!rs.EoF) { string retrievedData = rs.Fields.Item(0).Value.ToString(); rs.MoveNext(); if (input == retrievedData) { isValid = true; break; } else { isValid = false; } } if (!isValid && rs.EoF) { isValidAll = false; result += CurrentRow.ToString() + ", "; } } } if (!isValidAll) { result = result.Substring(0, result.Length - 2) + "."; return(result); } return(""); } catch (Exception ex) { AddOnUtilities.MsgBoxWrapper(ex.Message + " " + ex.StackTrace); return(ex.Message + " " + ex.StackTrace); } }
/// <summary> /// carga los valores que se encuentra en el Webservice /// </summary> /// <param name="oCompany"></param> private void deployCurrency(SAPbobsCOM.Company oCompany) { SAPbobsCOM.Recordset oRS = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); SAPbobsCOM.SBObob pSBObob = (SAPbobsCOM.SBObob)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge); TasaCambioSBO oTasaCambioSBO = new TasaCambioSBO(); List <TasaCambioSBO> oTasasCambio = new List <TasaCambioSBO>(); DateTime Fecha = DateTime.Now; Dictionary <DateTime, Decimal> AuxDict = new Dictionary <DateTime, decimal>(); String oSql; int diasAProcesar; // Validar definicion de monedas if (oCompany.DbServerType == SAPbobsCOM.BoDataServerTypes.dst_HANADB) { oSql = @"SELECT ""CurrCode"", ""CurrName"" , ""ISOCurrCod"" , ""DocCurrCod"" FROM ""OCRN"" WHERE ""Locked"" = 'N' "; } else { oSql = "SELECT CurrCode, CurrName , ISOCurrCod , DocCurrCod " + "FROM OCRN " + "WHERE Locked = 'N' "; } oRS.DoQuery(oSql); if (oRS.RecordCount > 0) { if (SBO_VID_Currency.Properties.Settings.Default.DiasAnterioresAProcesar > 0) { diasAProcesar = 0; } else { diasAProcesar = SBO_VID_Currency.Properties.Settings.Default.DiasAnterioresAProcesar; } oLog.LogMsg("Dias a procesar : " + diasAProcesar, "F", "D"); for (int x = diasAProcesar; x <= 1; x++) { Fecha = Fecha.AddDays(x); string dateFormat = Fecha.ToString("yyyy-MM-dd"); oLog.LogMsg("Dia: " + dateFormat, "F", "D"); string url = SBO_VID_Currency.Properties.Settings.Default.WEBPage; string responseRest = restGETWhitParameter(url, dateFormat); if (responseRest != "[]") { var listTC = JsonConvert.DeserializeObject <List <TC> >(responseRest); for (int i = 0; i < oRS.RecordCount; i++) //Monedas en SAP { string moneda = ((System.String)oRS.Fields.Item("CurrCode").Value).Trim(); string monedaISO = ((System.String)oRS.Fields.Item("ISOCurrCod").Value).Trim(); string monedaInternacional = ((System.String)oRS.Fields.Item("DocCurrCod").Value).Trim(); for (int y = 0; y < listTC.Count; y++) { if (moneda == listTC[y].codigo) { oLog.LogMsg("procesado por CurrCode: " + Fecha + " Currency: " + moneda, "F", "D"); UpdateSBOSAP(ref oCompany, Fecha, (Double)listTC[y].valor, ref pSBObob, moneda); y = listTC.Count; } else { if (monedaISO == listTC[y].codigo) { oLog.LogMsg("procesado por ISOCurrCod: " + Fecha + " Currency: " + monedaISO, "F", "D"); UpdateSBOSAP(ref oCompany, Fecha, (Double)listTC[y].valor, ref pSBObob, moneda); y = listTC.Count; } else { if (monedaInternacional == listTC[y].codigo) { oLog.LogMsg("procesado por DocCurrCod: " + Fecha + " Currency: " + monedaInternacional, "F", "D"); UpdateSBOSAP(ref oCompany, Fecha, (Double)listTC[y].valor, ref pSBObob, moneda); y = listTC.Count; } } } } oRS.MoveNext(); } oRS.MoveFirst(); } Fecha = DateTime.Now; } } }