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