Exemple #1
0
 public static int Update(Uom o)
 {
     try
     {
         string query = @"UPDATE ""UOM"" SET ""NAME"" = @Name, ""NOTES"" = @Notes, ""ID"" = @Id WHERE ""ID"" = @Id ";
         List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@Name", DbType.String)
             {
                 Value = o.Name
             },
             new NpgsqlParameter("@Notes", DbType.String)
             {
                 Value = (object)o.Notes ?? DBNull.Value
             },
             new NpgsqlParameter("@Id", DbType.Int32)
             {
                 Value = o.Id
             }
         };
         int rowAffected = DBManager.ExecuteNonQueryCommand(query, CommandType.Text, parameters);
         AuditTable.InsertEntity("Uom", o.Id.ToString(), 2, DateTime.Now, 1);
         return(rowAffected);
     }
     catch (Exception ex)
     {
         Log.InsertEntity("Uom", "Update", 2, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
     }
     return(-1);
 }
Exemple #2
0
 public static int Insert(Uom o)
 {
     try
     {
         string query = @"INSERT INTO ""UOM"" (""NAME"", ""NOTES"") VALUES (@Name, @Notes) returning ""ID"" ";
         List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@Name", DbType.String)
             {
                 Value = o.Name
             },
             new NpgsqlParameter("@Notes", DbType.String)
             {
                 Value = (object)o.Notes ?? DBNull.Value
             }
         };
         object id = DBManager.ExecuteScalarCommand(query, CommandType.Text, parameters);
         AuditTable.InsertEntity("Uom", id.ToString(), 1, DateTime.Now, 1);
         return(int.Parse(id.ToString()));
     }
     catch (Exception ex)
     {
         Log.InsertEntity("Uom", "Insert", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
     }
     return(-1);
 }
Exemple #3
0
 public static Uom GetUomAsObject(DataTable dt)
 {
     foreach (DataRow row in dt.Rows)
     {
         try
         {
             Uom o = new Uom();
             o.Name  = row["NAME"].ToString();
             o.Notes = row["NOTES"].ToString();
             o.Id    = Helper.ConvertToInt(row["ID"]);
             return(o);
         }
         catch (Exception ex)
         {
             Log.InsertEntity("Uom", "GetUomAsObject", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
             throw ex;
         }
     }
     return(null);
 }