private static SqlCommand FxSqlConnection(string pDatabase) { SqlConnection ObjSqlConnection = new SqlConnection(); SqlCommand ObjSqlCommand = new SqlCommand(); SqlConnectionStringBuilder ObjSqlConnectionString = FxSqlConnectionString(pDatabase); ObjSqlConnection.ConnectionString = ObjSqlConnectionString.ConnectionString; ObjSqlCommand.Connection = ObjSqlConnection; try { ObjSqlConnection.Open(); } catch { ObjSqlCommand = null; ClsFunctions.FxMessage(1, "No pudo conectarse con el servidor"); ClsFunctions.FxExit(); } ObjSqlConnectionString.Clear(); return(ObjSqlCommand); }
private static void FxSqlParametersImage(SqlCommand pSqlCommand, object[][] pParameters) { for (int lCounter = 0; lCounter < pParameters[0].Length; lCounter++) { string lParameter = "@" + pParameters[0][lCounter]; var lValue = pParameters[1][lCounter]; var lType = lValue.GetType(); if (lType == typeof(long)) { pSqlCommand.Parameters.AddWithValue(lParameter, lValue).SqlDbType = SqlDbType.Int; } else { byte[] ObjBuffer = ClsFunctions.FxConvertFileByte(lValue.ToString()); if (ObjBuffer != null) { pSqlCommand.Parameters.AddWithValue(lParameter, ObjBuffer).SqlDbType = SqlDbType.VarBinary; } else { pSqlCommand.Parameters.AddWithValue(lParameter, DBNull.Value).SqlDbType = SqlDbType.VarBinary; } } } }
public static long Fx_upt_tblModule(long pModuleId, string pName, string pDescription, string pExecutable, bool pEnabled) { long lId = 0; object[][] lParameters = new object[2][]; lParameters[0] = new object[] { "ModuleId", "Name", "Description", "Executable", "Enabled" }; lParameters[1] = new object[] { pModuleId, pName, pDescription, pExecutable, pEnabled }; DataTable ObjDt = ClsConnection.FxSqlExecute(ClsVariables.gDatabaseCore, lSchema, "sp_upt_tblModule", lParameters); if (ObjDt != null) { if (ObjDt.Rows.Count > 0) { try { lId = long.Parse(ObjDt.Rows[0][0].ToString()); } catch { lId = 0; } } ObjDt.Dispose(); } if (lId == 0) { ClsFunctions.FxMessage(1, "Registro no pudo ser guardado"); } return(lId); }
internal static DataTable FxSqlExecute(string pDatabase, string pSchema, string pStoredProcedure, object[][] pParameters) { DataTable ObjDt = new DataTable(); using (SqlDataAdapter ObjSqlDa = new SqlDataAdapter()) { using (SqlCommand ObjSqlCommand = FxSqlConnection(pDatabase)) { if (ObjSqlCommand != null) { if (pParameters[0] != null) { FxSqlParameters(ObjSqlCommand, pParameters); } ObjSqlCommand.CommandType = CommandType.StoredProcedure; ObjSqlCommand.CommandText = pSchema + "." + pStoredProcedure; ObjSqlDa.SelectCommand = ObjSqlCommand; try { ObjSqlDa.Fill(ObjDt); } catch { ObjDt = null; ClsFunctions.FxMessage(1, "Operación no fue completada"); ClsFunctions.FxExit(); } } if (ObjSqlCommand != null) { ObjSqlCommand.Connection.Close(); } } } return(ObjDt); }
public static long Fx_upt_tblCurrency(long pCurrencyId, string pName, string pIsoCode, string pSymbol, bool pEnabled) { long lId = 0; object[][] lParameters = new object[2][]; lParameters[0] = new object[] { "CurrencyId", "Name", "IsoCode", "Symbol", "Enabled" }; lParameters[1] = new object[] { pCurrencyId, pName, pIsoCode, pSymbol, pEnabled }; DataTable ObjDt = ClsConnection.FxSqlExecute(ClsVariables.gDatabaseCore, lSchema, "sp_upt_tblCurrency", lParameters); if (ObjDt != null) { if (ObjDt.Rows.Count > 0) { try { lId = long.Parse(ObjDt.Rows[0][0].ToString()); } catch { lId = 0; } } ObjDt.Dispose(); } if (lId == 0) { ClsFunctions.FxMessage(1, "Registro no pudo ser guardado"); } else { ClsFunctions.FxMessage("Proceso concluido"); } return(lId); }
public static long Fx_ins_tblLanguage(string pName) { long lId = 0; object[][] lParameters = new object[2][]; lParameters[0] = new object[] { "Name" }; lParameters[1] = new object[] { pName }; DataTable ObjDt = ClsConnection.FxSqlExecute(ClsVariables.gDatabaseCore, lSchema, "sp_ins_tblLanguage", lParameters); if (ObjDt != null) { if (ObjDt.Rows.Count > 0) { try { lId = long.Parse(ObjDt.Rows[0][0].ToString()); } catch { lId = 0; } } ObjDt.Dispose(); } if (lId == 0) { ClsFunctions.FxMessage(1, "Registro no pudo ser guardado"); } else { ClsFunctions.FxMessage("Proceso concluido"); } return(lId); }