public static int Update(ConfigurationDate o) { try { string query = @"UPDATE ""CONFIGURATION_DATE"" SET ""ID"" = @Id, ""DATE_FORMAT"" = @DateFormat, ""DATE_EXPRESION"" = @DateExpresion WHERE ""ID"" = @Id "; List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>() { new NpgsqlParameter("@DateFormat", DbType.String) { Value = o.DateFormat }, new NpgsqlParameter("@DateExpresion", DbType.String) { Value = o.DateExpresion }, new NpgsqlParameter("@Id", DbType.Int32) { Value = o.Id } }; int rowAffected = DBManager.ExecuteNonQueryCommand(query, CommandType.Text, parameters); AuditTable.InsertEntity("ConfigurationDate", o.Id.ToString(), 2, DateTime.Now, 1); return(rowAffected); } catch (Exception ex) { Log.InsertEntity("ConfigurationDate", "Update", 2, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", "")); } return(-1); }
public static int Insert(ConfigurationDate o) { try { string query = @"INSERT INTO ""CONFIGURATION_DATE"" (""DATE_FORMAT"", ""DATE_EXPRESION"") VALUES (@DateFormat, @DateExpresion) returning ""ID"" "; List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>() { new NpgsqlParameter("@DateFormat", DbType.String) { Value = o.DateFormat }, new NpgsqlParameter("@DateExpresion", DbType.String) { Value = o.DateExpresion } }; object id = DBManager.ExecuteScalarCommand(query, CommandType.Text, parameters); AuditTable.InsertEntity("ConfigurationDate", id.ToString(), 1, DateTime.Now, 1); return(int.Parse(id.ToString())); } catch (Exception ex) { Log.InsertEntity("ConfigurationDate", "Insert", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", "")); } return(-1); }
public static ConfigurationDate GetConfigurationDateAsObject(DataTable dt) { foreach (DataRow row in dt.Rows) { try { ConfigurationDate o = new ConfigurationDate(); o.Id = Helper.ConvertToInt(row["ID"]); o.DateFormat = row["DATE_FORMAT"].ToString(); o.DateExpresion = row["DATE_EXPRESION"].ToString(); return(o); } catch (Exception ex) { Log.InsertEntity("ConfigurationDate", "GetConfigurationDateAsObject", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", "")); throw ex; } } return(null); }