/// <summary> /// LLena un comboBox con los datos de una consulta sqlSelect /// </summary> /// <param name="sql">Select a ejecutar</param> /// <param name="combo">ComboBox a llenar</param> /// <param name="conex">Conexion Odbc</param> public void Llenar_Listbox(string sql, ComboBox combo, OdbcConnection conex) { try { if (conex.State == ConnectionState.Open) { conex.Close(); } conex.Open(); System.Data.Odbc.OdbcDataReader dr = new OdbcCommand(sql, conex).ExecuteReader(); if (dr.HasRows) { dr.Read(); //combo.Text = dr.GetString(0); combo.Text = "<Seleccione uno>"; do { combo.Items.Add(dr.GetString(0)); }while (dr.Read()); } } catch { throw new Exception("Error al momento de cargar el comoboBox con los prestamos"); } }
private void Fill_SubTables(int subtable_index) { if (subtable_index >= 0 && subtable_index < subtble_cnt) { int i = subtable_index; adps[i].Fill(tbls[i]); using (OdbcDataReader dr = new OdbcCommand(maxsqls[i], conn).ExecuteReader()) { if (dr.Read()) { if (dr[0].ToString() != "0") { try { cols[i].AutoIncrementSeed = long.Parse(dr[0].ToString()) + 1; } catch { cols[i].AutoIncrementSeed = 1; } } } } } }
public int getDataSelect_SQL3(string sqlselect, OdbcConnection conex) { int res = 0; if (conex.State == System.Data.ConnectionState.Open) { conex.Close(); } conex.Open(); OdbcDataReader dr = null; try { dr = new OdbcCommand(sqlselect, conex).ExecuteReader(); if (dr.HasRows) { dr.Read(); res = dr.GetInt32(0); } } catch { dr = null; res = 0; throw new Exception("Error al momento de devolver el datareader con los datos del SELECT"); } return(res); }
/// <summary> /// Performs a SQL query and returns the selected in the first found row as an Integer array. Useable for only one row. /// </summary> /// <param name="Query">The SQL query that selects a row and the fields to get. LIMIT 1 is added.</param> /// <param name="Tick">Just to differ the runReadRow functions; supply a null if you want to use this overload.</param> public static int[] runReadRow(string Query, object Tick) { try { ArrayList rowBuilder = new ArrayList(); OdbcDataReader rowReader = new OdbcCommand(Query + " LIMIT 1", dbConnection).ExecuteReader(); while (rowReader.Read()) { for (int i = 0; i < rowReader.FieldCount; i++) { try { rowBuilder.Add(rowReader.GetInt32(i)); } catch { rowBuilder.Add(0); } } } rowReader.Close(); return((int[])rowBuilder.ToArray(typeof(int))); } catch (Exception ex) { Out.WriteError("Error '" + ex.Message + "' at '" + Query + "'"); return(new int[0]); } }
public List <clsEntityDocument_Line_AdditionalComments> cs_fxObtenerTodoPorCabeceraId(string id) { var resultado = new List <clsEntityDocument_Line_AdditionalComments>(); try { OdbcDataReader datos = null; string sql = "SELECT * FROM " + cs_cmTabla + " WHERE cs_Document_Line_Id =" + id.ToString().Trim() + " ;"; //clsBaseConexion cn = new clsBaseConexion(); OdbcConnection cs_pxConexion_basedatos = new OdbcConnection(localDB.cs_prConexioncadenabasedatos()); cs_pxConexion_basedatos.Open(); datos = new OdbcCommand(sql, cs_pxConexion_basedatos).ExecuteReader(); while (datos.Read()) { var item = new clsEntityDocument_Line_AdditionalComments(localDB); int contador = 0; foreach (var prop in item.GetType().GetProperties()) { prop.SetValue(item, Convert.ChangeType(datos[contador].ToString(), prop.PropertyType), null); contador++; } resultado.Add(item); } cs_pxConexion_basedatos.Close(); } catch (Exception ex) { clsBaseLog.cs_pxRegistarAdd("clsEntityDocument_Line_AdditionalComments cs_fxObtenerTodoPorCabeceraId " + ex.ToString()); } return(resultado); }
/// <summary> /// Metodo para obtener todos los registros de una tabla en base de datos. /// </summary> /// <param name="tabla"></param> /// <param name="campos"></param> /// <param name="valores"></param> /// <param name="obtener_mensaje_respuesta"></param> /// <returns>Lista de listas de registros.</returns> public List <List <string> > cs_fxSeleccionartodo(string tabla, List <string> campos, List <string> valores, bool obtener_mensaje_respuesta) { List <List <string> > tabla_contenidos; try { tabla_contenidos = new List <List <string> >(); OdbcDataReader datos = null; string sql = "SELECT * FROM " + tabla; cs_cmConexion.Open(); datos = new OdbcCommand(sql, cs_cmConexion).ExecuteReader(); List <string> fila; while (datos.Read()) { fila = new List <string>(); for (int i = 0; i < datos.FieldCount; i++) { fila.Add(datos[i].ToString().Trim()); } tabla_contenidos.Add(fila); } cs_cmConexion.Close(); return(tabla_contenidos); } catch (Exception ex) { if (obtener_mensaje_respuesta) { clsBaseMensaje.cs_pxMsgEr("ERR6", ex.ToString()); } clsBaseLog.cs_pxRegistarAdd("clsBaseConexion cs_fxSeleccionartodo :" + tabla + " " + ex.ToString()); return(null); } }
/// <summary> /// Obtener la cantidad de items de resumen. /// </summary> /// <param name="Id">Id del Resumen</param> /// <returns>Número de items</returns> public Int64 cs_fxObtenerResumenNumeroItems(string Id) { Int64 filas = 0; List <string> tabla_contenidos; try { tabla_contenidos = new List <string>(); OdbcDataReader datos = null; string sql = "SELECT * FROM cs_SummaryDocuments_SummaryDocumentsLine WHERE 1=1"; sql += " AND cs_SummaryDocuments_Id = " + Id + " "; //clsBaseConexion cn = new clsBaseConexion(); OdbcConnection cs_pxConexion_basedatos = new OdbcConnection(localDB.cs_prConexioncadenabasedatos()); cs_pxConexion_basedatos.Open(); datos = new OdbcCommand(sql, cs_pxConexion_basedatos).ExecuteReader(); while (datos.Read()) { filas++; } cs_pxConexion_basedatos.Close(); return(filas); } catch (Exception ex) { clsBaseMensaje.cs_pxMsgEr("ERR6", ex.ToString()); clsBaseLog.cs_pxRegistarAdd("clsEntitySummaryDocuments cs_fxObtenerResumenNumeroItems" + ex.ToString()); return(0); } }
public List <string> cs_fxObtenerResumenesIdPorFechaEnvio_TOTAL(string fecha) { List <string> tabla_contenidos; try { tabla_contenidos = new List <string>(); OdbcDataReader datos = null; string sql = "SELECT * FROM " + cs_cmTabla + " WHERE 1=1"; sql += " AND cp3 = '" + DateTime.Now.ToString("yyyy-MM-dd") + "' "; // sql += " AND cp3 = '" + fecha_referencia + "' "; // sql += " AND cp8 = '0' "; // sql += " AND cp9 = '0' "; //clsBaseConexion cn = new clsBaseConexion(); OdbcConnection cs_pxConexion_basedatos = new OdbcConnection(localDB.cs_prConexioncadenabasedatos()); cs_pxConexion_basedatos.Open(); datos = new OdbcCommand(sql, cs_pxConexion_basedatos).ExecuteReader(); while (datos.Read()) { tabla_contenidos.Add(datos[0].ToString()); } cs_pxConexion_basedatos.Close(); return(tabla_contenidos); } catch (Exception ex) { clsBaseMensaje.cs_pxMsgEr("ERR6", ex.ToString()); clsBaseLog.cs_pxRegistarAdd("clsEntitySummaryDocuments cs_fxObtenerResumenesIdPorFechaEnvio_TOTAL" + ex.ToString()); return(null); } }
public List <clsEntityDocument_Advance> cs_fxObtenerTodoPorCabeceraId(string id) { List <clsEntityDocument_Advance> resultado = new List <clsEntityDocument_Advance>(); try { OdbcDataReader datos = null; string sql = "SELECT * FROM " + cs_cmTabla + " WHERE cs_Document_Id =" + id.ToString().Trim() + ";"; //clsBaseConexion cn = new clsBaseConexion(); OdbcConnection cs_pxConexion_basedatos = new OdbcConnection(localDB.cs_prConexioncadenabasedatos()); cs_pxConexion_basedatos.Open(); datos = new OdbcCommand(sql, cs_pxConexion_basedatos).ExecuteReader(); clsEntityDocument_Advance item; while (datos.Read()) { item = new clsEntityDocument_Advance(localDB); item.Cs_pr_Document_Advance_Id = datos[0].ToString(); item.Cs_pr_Document_Id = datos[1].ToString(); item.Cs_pr_TagId = datos[2].ToString(); item.Cs_pr_TagPaidAmount = datos[3].ToString(); item.Cs_pr_InstructionID = datos[4].ToString(); item.Cs_pr_TagPrepaidAmount = datos[5].ToString(); item.Cs_pr_Schema_ID = datos[6].ToString(); item.Cs_pr_Currency_ID = datos[7].ToString(); item.Cs_pr_Instruction_Schema_ID = datos[8].ToString(); resultado.Add(item); } cs_pxConexion_basedatos.Close(); } catch (Exception ex) { clsBaseLog.cs_pxRegistarAdd("clsEntityDocument_Advance cs_fxObtenerTodoPorCabeceraId " + ex.ToString()); } return(resultado); }
public bool cs_fxVerificarExistencia(string id) { try { int cantidad = 0; OdbcDataReader datos = null; string sql = "SELECT * FROM " + cs_cmTabla + " WHERE cs_Document_Id =" + id.ToString().Trim() + ";"; //clsBaseConexion cn = new clsBaseConexion(); OdbcConnection cs_pxConexion_basedatos = new OdbcConnection(localDB.cs_prConexioncadenabasedatos()); cs_pxConexion_basedatos.Open(); datos = new OdbcCommand(sql, cs_pxConexion_basedatos).ExecuteReader(); while (datos.Read()) { cantidad++; } cs_pxConexion_basedatos.Close(); if (cantidad > 0) { return(true); } else { return(false); } } catch (Exception ex) { clsBaseLog.cs_pxRegistarAdd("clsEntityDocument_AdditionalComments cs_fxVerificarExistencia" + ex.ToString()); return(false); } }
/// <summary> /// Performs a SQL query and returns all vertical matching fields as an integer array. Only the first supplied columname is looked for. /// </summary> /// <param name="Query">The SQL query that selects a column.</param> /// <param name="maxResults">Adds as LIMIT to the query. Using this, the array will never return more than xx fields in of the column. When maxResults is supplied as 0, then there is no max limit.</param> public static int[] runReadColumnIntegers(string Query, int maxResults) { if (maxResults > 0) { Query += " LIMIT " + maxResults; } try { ArrayList columnBuilder = new ArrayList(); OdbcDataReader columnReader = new OdbcCommand(Query, dbConnection).ExecuteReader(); while (columnReader.Read()) { try { columnBuilder.Add((int)columnReader[0]); } catch { columnBuilder.Add(0); } } columnReader.Close(); return((int[])columnBuilder.ToArray(typeof(int))); } catch (Exception ex) { Logging.logError(ex.Message + ", query = " + Query); return(new int[0]); } }
public List <clsEntityDocument_DespatchDocumentReference> cs_pxObtenerTodoPorCabeceraId(string id) { List <clsEntityDocument_DespatchDocumentReference> guia_remision; try { guia_remision = new List <clsEntityDocument_DespatchDocumentReference>(); OdbcDataReader datos = null; string sql = "SELECT * FROM " + cs_cmTabla + " WHERE cs_Document_Id=" + id.ToString().Trim() + " ;"; //clsBaseConexion cn = new clsBaseConexion(); OdbcConnection cs_pxConexion_basedatos = new OdbcConnection(localDB.cs_prConexioncadenabasedatos()); cs_pxConexion_basedatos.Open(); datos = new OdbcCommand(sql, cs_pxConexion_basedatos).ExecuteReader(); clsEntityDocument_DespatchDocumentReference entidad; while (datos.Read()) { entidad = new clsEntityDocument_DespatchDocumentReference(localDB); entidad.Cs_pr_Document_DespatchDocumentReference_Id = cs_cmValores[0]; entidad.Cs_tag_DespatchDocumentReference_ID = cs_cmValores[1]; entidad.Cs_tag_DocumentTypeCode = cs_cmValores[2]; guia_remision.Add(entidad); } cs_pxConexion_basedatos.Close(); return(guia_remision); } catch (Exception ex) { clsBaseMensaje.cs_pxMsgEr("ERR6", ex.ToString()); clsBaseLog.cs_pxRegistarAdd("clsEntityDocument_DespatchDocumentReference cs_pxObtenerTodoPorCabeceraId" + ex.ToString()); return(null); } }
public string cs_pxObtenerIdRelacionadoDescripcionUltimo(string idDiferente, string codigoProducto) { string tabla_contenidos = string.Empty; try { OdbcDataReader datos = null; string sql = "SELECT TOP 1 cs_Document_Line_Id FROM " + cs_cmTabla + " WHERE cs_Document_Id !=" + idDiferente.ToString().Trim() + " AND cp7='" + codigoProducto + "' ORDER BY cs_Document_Line_Id DESC ;"; //clsBaseConexion cn = new clsBaseConexion(); OdbcConnection cs_pxConexion_basedatos = new OdbcConnection(localDB.cs_prConexioncadenabasedatos()); cs_pxConexion_basedatos.Open(); datos = new OdbcCommand(sql, cs_pxConexion_basedatos).ExecuteReader(); while (datos.Read()) { tabla_contenidos = datos[0].ToString().Trim(); } cs_pxConexion_basedatos.Close(); } catch (Exception) { tabla_contenidos = string.Empty; } return(tabla_contenidos); }
public List <clsEntityDocument_AdditionalComments> cs_fxObtenerTodoPorIdReferencia(string id) { List <clsEntityDocument_AdditionalComments> resultado = new List <clsEntityDocument_AdditionalComments>(); try { OdbcDataReader datos = null; string sql = "SELECT * FROM " + cs_cmTabla + " WHERE cp1 ='" + id.ToString().Trim() + "';"; //clsBaseConexion cn = new clsBaseConexion(); OdbcConnection cs_pxConexion_basedatos = new OdbcConnection(localDB.cs_prConexioncadenabasedatos()); cs_pxConexion_basedatos.Open(); datos = new OdbcCommand(sql, cs_pxConexion_basedatos).ExecuteReader(); clsEntityDocument_AdditionalComments item; while (datos.Read()) { item = new clsEntityDocument_AdditionalComments(localDB); item.Cs_pr_Document_AdditionalComments_Id = datos[0].ToString(); item.Cs_pr_Document_Id = datos[1].ToString(); item.Cs_pr_Document_AdditionalComments_Reference_Id = datos[2].ToString(); item.Cs_pr_TagNombre = datos[3].ToString(); item.Cs_pr_TagValor = datos[4].ToString(); resultado.Add(item); } cs_pxConexion_basedatos.Close(); } catch (Exception ex) { clsBaseLog.cs_pxRegistarAdd("clsEntityDocument_AdditionalComments cs_fxObtenerTodoPorIdReferencia " + ex.ToString()); } return(resultado); }
internal List <clsEntitySummaryDocuments_SummaryDocumentsLine_BillingPayment> cs_fxObtenerTodoPorCabeceraId(string Id) { List <clsEntitySummaryDocuments_SummaryDocumentsLine_BillingPayment> List_SummaryDocumentsLine_BillingPayment = new List <clsEntitySummaryDocuments_SummaryDocumentsLine_BillingPayment>(); try { OdbcDataReader datos = null; string sql = "SELECT * FROM " + cs_cmTabla + " WHERE cs_SummaryDocuments_SummaryDocumentsLine_Id=" + Id.Trim() + " ;"; //clsBaseConexion cn = new clsBaseConexion(); OdbcConnection cs_pxConexion_basedatos = new OdbcConnection(localDB.cs_prConexioncadenabasedatos()); cs_pxConexion_basedatos.Open(); datos = new OdbcCommand(sql, cs_pxConexion_basedatos).ExecuteReader(); clsEntitySummaryDocuments_SummaryDocumentsLine_BillingPayment SummaryDocumentsLine_BillingPayment; while (datos.Read()) { SummaryDocumentsLine_BillingPayment = new clsEntitySummaryDocuments_SummaryDocumentsLine_BillingPayment(localDB); SummaryDocumentsLine_BillingPayment.Cs_pr_SummaryDocuments_SummaryDocumentsLine_BillingPayment_Id = datos[0].ToString(); SummaryDocumentsLine_BillingPayment.Cs_pr_SummaryDocuments_SummaryDocumentsLine_Id = datos[1].ToString(); SummaryDocumentsLine_BillingPayment.Cs_tag_PaidAmount = datos[2].ToString(); SummaryDocumentsLine_BillingPayment.Cs_tag_InstructionID = datos[3].ToString(); List_SummaryDocumentsLine_BillingPayment.Add(SummaryDocumentsLine_BillingPayment); } cs_pxConexion_basedatos.Close(); } catch (Exception ex) { clsBaseMensaje.cs_pxMsgEr("ERR6", ex.ToString()); clsBaseLog.cs_pxRegistarAdd("clsEntitySummaryDocuments_SummaryDocumentsLine_BillingPayment" + ex.ToString()); //return null; } return(List_SummaryDocumentsLine_BillingPayment); }
public string cs_fxObtenerResumenIdPorFechaReferencia_PENDIENTE(string fecha, string fecha_reference) { string tabla_contenidos = string.Empty; try { OdbcDataReader datos = null; string sql = "SELECT cs_SummaryDocuments_Id FROM " + cs_cmTabla + " WHERE 1=1"; sql += " AND cp3 = '" + fecha + "' "; sql += " AND cp2 = '" + fecha_reference + "' "; sql += " AND cp8 = '2' "; sql += " AND cp9 = '2' "; // clsBaseConexion cn = new clsBaseConexion(); OdbcConnection cs_pxConexion_basedatos = new OdbcConnection(localDB.cs_prConexioncadenabasedatos()); cs_pxConexion_basedatos.Open(); datos = new OdbcCommand(sql, cs_pxConexion_basedatos).ExecuteReader(); while (datos.Read()) { tabla_contenidos = datos[0].ToString(); } cs_pxConexion_basedatos.Close(); } catch (Exception ex) { //clsBaseMensaje.cs_pxMsgEr("ERR6", ex.ToString()); clsBaseLog.cs_pxRegistarAdd("clsEntitySummaryDocuments cs_fxObtenerResumenesIdPorFechaReferencia_PENDIENTES " + ex.ToString()); tabla_contenidos = string.Empty; } return(tabla_contenidos); }
//validar si existe resumen del dia para la fecha de referencia public bool cs_fxValidarResumenDiaFechaReferencia(string fecha, string fecha_referencia) { bool resultado = false; try { OdbcDataReader datos = null; string sql = "SELECT * FROM " + cs_cmTabla + " WHERE 1=1"; sql += " AND cp3 = '" + DateTime.Now.ToString("yyyy-MM-dd") + "' "; sql += " AND cp2 = '" + fecha_referencia + "' "; sql += " AND cp8 = '0' "; sql += " AND cp9 = '0' "; //clsBaseConexion cn = new clsBaseConexion(); OdbcConnection cs_pxConexion_basedatos = new OdbcConnection(localDB.cs_prConexioncadenabasedatos()); cs_pxConexion_basedatos.Open(); datos = new OdbcCommand(sql, cs_pxConexion_basedatos).ExecuteReader(); while (datos.Read()) { resultado = true; } cs_pxConexion_basedatos.Close(); return(resultado); } catch (Exception ex) { clsBaseMensaje.cs_pxMsgEr("ERR6", ex.ToString()); clsBaseLog.cs_pxRegistarAdd("clsEntitySummaryDocuments cs_fxValidarResumenDiaFechaReferencia" + ex.ToString()); return(false); } }
internal List <clsEntitySummaryDocuments_SummaryDocumentsLine_AllowanceCharge> cs_fxObtenerTodoPorCabeceraId(string Id) { List <clsEntitySummaryDocuments_SummaryDocumentsLine_AllowanceCharge> List_SummaryDocumentsLine_AllowanceCharge = new List <clsEntitySummaryDocuments_SummaryDocumentsLine_AllowanceCharge>(); try { OdbcDataReader datos = null; string sql = "SELECT * FROM " + cs_cmTabla + " WHERE cs_SummaryDocuments_SummaryDocumentsLine_Id=" + Id.Trim() + " ;"; //clsBaseConexion cn = new clsBaseConexion(); OdbcConnection cs_pxConexion_basedatos = new OdbcConnection(localDB.cs_prConexioncadenabasedatos()); cs_pxConexion_basedatos.Open(); datos = new OdbcCommand(sql, cs_pxConexion_basedatos).ExecuteReader(); clsEntitySummaryDocuments_SummaryDocumentsLine_AllowanceCharge SummaryDocumentsLine_AllowanceCharge; while (datos.Read()) { SummaryDocumentsLine_AllowanceCharge = new clsEntitySummaryDocuments_SummaryDocumentsLine_AllowanceCharge(localDB); SummaryDocumentsLine_AllowanceCharge.Cs_pr_SummaryDocuments_SummaryDocumentsLine_AllowanceCharge_Id = datos[0].ToString(); SummaryDocumentsLine_AllowanceCharge.Cs_pr_SummaryDocuments_SummaryDocumentsLine_Id = datos[1].ToString(); SummaryDocumentsLine_AllowanceCharge.Cs_tag_ChargeIndicator = datos[2].ToString(); SummaryDocumentsLine_AllowanceCharge.Cs_tag_Amount = datos[3].ToString(); List_SummaryDocumentsLine_AllowanceCharge.Add(SummaryDocumentsLine_AllowanceCharge); } cs_pxConexion_basedatos.Close(); } catch (Exception ex) { // System.Windows.Forms.MessageBox.Show(ex.ToString()); clsBaseMensaje.cs_pxMsgEr("ERR6", ex.ToString()); clsBaseLog.cs_pxRegistarAdd("clsEntitySummaryDocuments_SummaryDocumentsLine_AllowanceCharge cs_fxObtenerTodoPorCabeceraId" + ex.ToString()); //return null; } return(List_SummaryDocumentsLine_AllowanceCharge); }
/// <summary> /// Obtener los resúmenes diarios de boletas en un rango de fechas. /// </summary> /// <param name="fecha_inicio">Fecha en formato: YYYY-MM-DD (Reference Date)</param> /// <param name="fecha_fin">Fecha en formato: YYYY-MM-DD (Reference Date)</param> /// <returns>Lista de de resumenes diarios</returns> public List <List <string> > cs_fxObtenerResumenesPorRangoFecha(string fecha_inicio, string fecha_fin) { List <List <string> > tabla_contenidos; try { tabla_contenidos = new List <List <string> >(); OdbcDataReader datos = null; string sql = "SELECT * FROM " + cs_cmTabla + " WHERE 1=1"; sql += " AND cp2 >= '" + fecha_inicio + "' "; sql += " AND cp2 <= '" + fecha_fin + "' "; //clsBaseConexion cn = new clsBaseConexion(); OdbcConnection cs_pxConexion_basedatos = new OdbcConnection(localDB.cs_prConexioncadenabasedatos()); cs_pxConexion_basedatos.Open(); datos = new OdbcCommand(sql, cs_pxConexion_basedatos).ExecuteReader(); List <string> fila; while (datos.Read()) { fila = new List <string>(); for (int i = 0; i < datos.FieldCount; i++) { fila.Add(datos[i].ToString().Trim()); } tabla_contenidos.Add(fila); } cs_pxConexion_basedatos.Close(); return(tabla_contenidos); } catch (Exception ex) { clsBaseMensaje.cs_pxMsgEr("ERR6", ex.ToString()); clsBaseLog.cs_pxRegistarAdd("clsEntitySummaryDocuments cs_fxObtenerResumenesPorRangoFecha" + ex.ToString()); return(null); } }
internal List <clsEntityDespatch_PortLocation> cs_fxObtenerTodoPorCabeceraId(string Id) { List <clsEntityDespatch_PortLocation> List_ShipmentStagePort; try { List_ShipmentStagePort = new List <clsEntityDespatch_PortLocation>(); OdbcDataReader datos = null; string sql = "SELECT * FROM " + cs_cmTabla + " WHERE cs_Despatch_ID=" + Id.Trim() + ";"; // clsBaseConexion cn = new clsBaseConexion(); OdbcConnection cs_pxConexion_basedatos = new OdbcConnection(localDB.cs_prConexioncadenabasedatos()); cs_pxConexion_basedatos.Open(); datos = new OdbcCommand(sql, cs_pxConexion_basedatos).ExecuteReader(); clsEntityDespatch_PortLocation ShipmentStagePort_Line; while (datos.Read()) { ShipmentStagePort_Line = new clsEntityDespatch_PortLocation(localDB); ShipmentStagePort_Line.Cs_pr_Despatch_PortLocation_ID = datos[0].ToString(); ShipmentStagePort_Line.Cs_pr_Despatch_ID = datos[1].ToString(); ShipmentStagePort_Line.Cs_tag_ID = datos[2].ToString(); List_ShipmentStagePort.Add(ShipmentStagePort_Line); } cs_pxConexion_basedatos.Close(); return(List_ShipmentStagePort); } catch (Exception ex) { clsBaseMensaje.cs_pxMsgEr("ERR6", ex.ToString()); clsBaseLog.cs_pxRegistarAdd("clsEntityDespatch_PortLocation cs_fxObtenerTodoPorCabeceraId " + ex.ToString()); return(null); } }
/// <summary> /// Metodo para obtener un listado en list de list de los tax total segun id de la linea. /// </summary> /// <param name="id"></param> /// <returns></returns> public List <List <string> > cs_pxObtenerTodoPorId(string id) { List <List <string> > tabla_contenidos; try { tabla_contenidos = new List <List <string> >(); OdbcDataReader datos = null; string sql = "SELECT * FROM " + cs_cmTabla + " WHERE cs_Document_Line_Id=" + id.ToString().Trim() + " ;"; //clsBaseConexion cn = new clsBaseConexion(); OdbcConnection cs_pxConexion_basedatos = new OdbcConnection(localDB.cs_prConexioncadenabasedatos()); cs_pxConexion_basedatos.Open(); datos = new OdbcCommand(sql, cs_pxConexion_basedatos).ExecuteReader(); List <string> fila; while (datos.Read()) { fila = new List <string>(); for (int i = 0; i < datos.FieldCount; i++) { fila.Add(datos[i].ToString().Trim()); } tabla_contenidos.Add(fila); } cs_pxConexion_basedatos.Close(); return(tabla_contenidos); } catch (Exception ex) { clsBaseMensaje.cs_pxMsgEr("ERR6", ex.ToString()); clsBaseLog.cs_pxRegistarAdd("clsEntityDocument_Line_TaxTotal cs_pxObtenerTodoPorId" + ex.ToString()); return(null); } }
public string cs_pxObtenerDocumentoComuninicacionBajaExisente(string fecha_comunicacion, bool registro_mas_reciente, string tipoContiene)//Fecha a la que pertenece el conjunto de documentos. { string documento_id = string.Empty; try { clsEntityVoidedDocuments documento = new clsEntityVoidedDocuments(localDB); OdbcDataReader datos = null; string sql = "SELECT * FROM " + cs_cmTabla + " WHERE cp8!='2' AND cp2='" + fecha_comunicacion + "' AND cp14='" + tipoContiene + "' ORDER BY cp3 DESC;";//Estado SCC //clsBaseConexion cn = new clsBaseConexion(); OdbcConnection cs_pxConexion_basedatos = new OdbcConnection(localDB.cs_prConexioncadenabasedatos()); cs_pxConexion_basedatos.Open(); datos = new OdbcCommand(sql, cs_pxConexion_basedatos).ExecuteReader(); int count = 0; while (datos.Read()) { count++; if (count == 1) { documento_id = datos[0].ToString(); break; } } cs_pxConexion_basedatos.Close(); } catch (Exception ex) { clsBaseMensaje.cs_pxMsgEr("ERR6", ex.ToString()); clsBaseLog.cs_pxRegistarAdd("clsEntityVoidedDocuments cs_pxObtenerDocumentoComuninicacionBajaExisente 2 param " + ex.ToString()); } return(documento_id); }
/// <summary> /// Metodo que retorna la cadena de conexion del servidor para ODBC. /// </summary> /* public string cs_prConexioncadenaservidor * { * get * { * string cadena = ""; * switch (cs_cmConfiguracion.cs_prDbms) * { * case "MySQL": * cadena = "DRIVER={" + cs_cmConfiguracion.cs_prDbmsdriver + "};SERVER=" + cs_cmConfiguracion.cs_prDbmsservidor + ";PORT=" + cs_cmConfiguracion.cs_prDbmsservidorpuerto + ";USER="******";PASSWORD="******";OPTION=3;"; * break; * case "Microsoft SQL Server": * cadena = "Driver={" + cs_cmConfiguracion.cs_prDbmsdriver + "};Server=" + cs_cmConfiguracion.cs_prDbmsservidor + "," + cs_cmConfiguracion.cs_prDbmsservidorpuerto + ";Uid=" + cs_cmConfiguracion.cs_prDbusuario + ";Pwd=" + cs_cmConfiguracion.cs_prDbclave + ";"; * break; * case "SQLite": * cadena = "DRIVER={" + cs_cmConfiguracion.cs_prDbmsdriver + "}; Database=" + cs_cmConfiguracion.cs_prRutainstalacion + ".dbc\\" + cs_cmConfiguracion.cs_prDbnombre + "; LongNames=0; Timeout=1000; NoTXN=0; SyncPragma=NORMAL; StepAPI=0;"; * break; * } * return cadena; * } * } * /// <summary> * /// Metodo que retorna la cadena de conexion a base de datos en ODBC. * /// </summary> * public string cs_prConexioncadenabasedatos * { * get * { * string cadena = ""; * switch (cs_cmConfiguracion.cs_prDbms) * { * case "MySQL": * cadena = "DRIVER={" + cs_cmConfiguracion.cs_prDbmsdriver + "};SERVER=" + cs_cmConfiguracion.cs_prDbmsservidor + ";PORT=" + cs_cmConfiguracion.cs_prDbmsservidorpuerto + ";DATABASE=" + cs_cmConfiguracion.cs_prDbnombre + ";USER="******";PASSWORD="******";OPTION=3;"; * break; * case "Microsoft SQL Server": * cadena = "Driver={" + cs_cmConfiguracion.cs_prDbmsdriver + "};Server=" + cs_cmConfiguracion.cs_prDbmsservidor + "," + cs_cmConfiguracion.cs_prDbmsservidorpuerto + ";Database=" + cs_cmConfiguracion.cs_prDbnombre + ";Uid=" + cs_cmConfiguracion.cs_prDbusuario + ";Pwd=" + cs_cmConfiguracion.cs_prDbclave + ";"; * break; * case "SQLite": * cadena = "DRIVER={" + cs_cmConfiguracion.cs_prDbmsdriver + "}; Database=" + cs_cmConfiguracion.cs_prRutainstalacion + "\\" + cs_cmConfiguracion.cs_prDbnombre + ".dbc" + "; LongNames=0; Timeout=1000; NoTXN=0; SyncPragma=NORMAL; StepAPI=0;"; * break; * } * return cadena; * } * }*/ /// <summary> /// Metodo para obtener un registro de base de datos. /// </summary> /// <param name="tabla"></param> /// <param name="campos"></param> /// <param name="id"></param> /// <param name="obtener_mensaje_respuesta"></param> /// <returns>Listado de valores del registro</returns> public List <string> cs_fxObtenerUnoPorId(string tabla, List <string> campos, string id, bool obtener_mensaje_respuesta) { List <string> valores = new List <string>(); try { string sql = "SELECT * FROM " + tabla + " WHERE " + campos[0] + " =" + id + " "; cs_cmConexion.Open(); OdbcDataReader odr = new OdbcCommand(sql, cs_cmConexion).ExecuteReader(); while (odr.Read()) { for (int i = 0; i < campos.Count; i++) { valores.Add(odr[i].ToString().Trim()); } } cs_cmConexion.Close(); } catch (Exception ex) { if (obtener_mensaje_respuesta) { clsBaseMensaje.cs_pxMsgEr("ERR6", ex.ToString()); } clsBaseLog.cs_pxRegistarAdd("clsBaseConexion cs_fxObtenerUnoPorId " + tabla + " " + ex.ToString()); } return(valores); }
public bool cs_pxValidarMotivosDeBajaEnItems(string Id) { bool Valido = true; try { clsEntityVoidedDocuments documento = new clsEntityVoidedDocuments(localDB); OdbcDataReader datos = null; string sql = "SELECT * FROM cs_VoidedDocuments_VoidedDocumentsLine WHERE cs_VoidedDocuments_Id=" + Id + " ;"; //clsBaseConexion cn = new clsBaseConexion(); OdbcConnection cs_pxConexion_basedatos = new OdbcConnection(localDB.cs_prConexioncadenabasedatos()); cs_pxConexion_basedatos.Open(); datos = new OdbcCommand(sql, cs_pxConexion_basedatos).ExecuteReader(); while (datos.Read()) { if (datos[6].ToString() == "") { Valido = false; break; } } return(Valido); } catch (Exception ex) { clsBaseLog.cs_pxRegistarAdd("clsEntityVoidedDocuments cs_pxValidarMotivosDeBajaEnItems" + ex.ToString()); return(false); } }
/// <summary> /// Performs a SQL query and returns all vertical matching fields as an Integer array. Only the first supplied columname is looked for. /// </summary> /// <param name="Query">The SQL query that selects a column.</param> /// <param name="maxResults">Adds as LIMIT to the query. Using this, the array will never return more than xx fields in of the column. When maxResults is supplied as 0, then there is no max limit.</param> /// <param name="Tick">Just to differ the runReadColumn functions; supply a null if you want to use this overload.</param> public static int[] runReadColumn(string Query, int maxResults, object Tick) { if (maxResults > 0) { Query += " LIMIT " + maxResults; } try { ArrayList columnBuilder = new ArrayList(); OdbcDataReader columnReader = new OdbcCommand(Query, dbConnection).ExecuteReader(); while (columnReader.Read()) { try { columnBuilder.Add(columnReader.GetInt32(0)); } catch { columnBuilder.Add(0); } } columnReader.Close(); return((int[])columnBuilder.ToArray(typeof(int))); } catch (Exception ex) { Out.WriteError("Error '" + ex.Message + "' at '" + Query + "'"); return(new int[0]); } }
/// <summary> /// Performs a SQL query and returns all vertical matching fields as a String array. Only the first supplied columname is looked for. /// </summary> /// <param name="Query">The SQL query that selects a column.</param> /// <param name="maxResults">Adds as LIMIT to the query. Using this, the array will never return more than xx fields in of the column. When maxResults is supplied as 0, then there is no max limit.</param> public static string[] runReadColumn(string Query, int maxResults) { if (maxResults > 0) { Query += " LIMIT " + maxResults; } try { ArrayList columnBuilder = new ArrayList(); OdbcDataReader columnReader = new OdbcCommand(Query, dbConnection).ExecuteReader(); while (columnReader.Read()) { try { columnBuilder.Add(columnReader[0].ToString()); } catch { columnBuilder.Add(""); } } columnReader.Close(); return((string[])columnBuilder.ToArray(typeof(string))); } catch (Exception ex) { Log.AppendText("Error '" + ex.Message + "' at '" + Query + "'"); return(new string[0]); } }
/// <summary> /// Performs a SQL query and returns the selected in the first found row as a String array. Useable for only one row. /// </summary> /// <param name="Query">The SQL query that selects a row and the fields to get. LIMIT 1 is added.</param> public static string[] runReadRow(string Query) { try { ArrayList rowBuilder = new ArrayList(); OdbcDataReader rowReader = new OdbcCommand(Query + " LIMIT 1", dbConnection).ExecuteReader(); while (rowReader.Read()) { for (int i = 0; i < rowReader.FieldCount; i++) { try { rowBuilder.Add(rowReader[i].ToString()); } catch { rowBuilder.Add(""); } } } rowReader.Close(); return((string[])rowBuilder.ToArray(typeof(string))); } catch (Exception ex) { Log.AppendText("Error '" + ex.Message + "' at '" + Query + "'"); return(new string[0]); } }
public List <List <string> > cs_pxObtenerPendientesEnvio() { List <List <string> > tabla_contenidos; try { tabla_contenidos = new List <List <string> >(); OdbcDataReader datos = null; string sql = "SELECT * FROM " + cs_cmTabla + " WHERE 1=1"; sql += " AND cp33 ='2' "; //cn = new clsBaseConexion(); OdbcConnection cs_pxConexion_basedatos = new OdbcConnection(localDB.cs_prConexioncadenabasedatos()); cs_pxConexion_basedatos.Open(); datos = new OdbcCommand(sql, cs_pxConexion_basedatos).ExecuteReader(); List <string> fila; while (datos.Read()) { //Devuelve los datos en el mismo orden que aparecen en la tabla. Considerar al llenar el datagridview. fila = new List <string>(); for (int i = 0; i < datos.FieldCount; i++) { fila.Add(datos[i].ToString().Trim()); } tabla_contenidos.Add(fila); } cs_pxConexion_basedatos.Close(); return(tabla_contenidos); } catch (Exception) { //clsBaseMensaje.cs_pxMsgEr("ERR6", ex.ToString()); //clsBaseLog.cs_pxRegistarAdd(" clsEntityDocument cs_pxObtenerPendientesEnvio" + ex.ToString()); return(null); } }
public List <string> getDataSelect_SQL_Lista(string sqlselect) { List <string> res = new List <string>(); if (conexion.State == System.Data.ConnectionState.Open) { conexion.Close(); } conexion.Open(); OdbcDataReader dr = null; try { dr = new OdbcCommand(sqlselect, conexion).ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { res.Add(dr.GetString(0)); } } } catch { dr = null; res = null; throw new Exception("Error al momento de devolver el datareader con los datos del SELECT"); } return(res); }
public Persona getPersona(string p_cedula) { Persona res = new Persona(); string sql = "SELECT cedula, nombre, tipo FROM tpersonas WHERE cedula like '" + p_cedula + "%'"; try { con.Conectar(); OdbcDataReader dr = new OdbcCommand(sql, con.getConexion()).ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { res.Cedula = dr.GetString(0); res.Nombre = dr.GetString(1); res.Tipo = dr.GetInt16(2); } } } catch { res = null; } con.Desconectar(); return(res); }