コード例 #1
0
        public static List <ChildSupplements> GetChildSupplementsAsList(DataTable dt)
        {
            List <ChildSupplements> oList = new List <ChildSupplements>();

            foreach (DataRow row in dt.Rows)
            {
                try
                {
                    ChildSupplements o = new ChildSupplements();
                    o.Id         = Helper.ConvertToInt(row["ID"]);
                    o.ChildId    = Helper.ConvertToInt(row["CHILD_ID"]);
                    o.Vita       = Helper.ConvertToBoolean(row["VitA"]);
                    o.Mebendezol = Helper.ConvertToBoolean(row["Mebendezol"]);
                    o.Date       = Helper.ConvertToDate(row["DATE"]);
                    o.ModifiedOn = Helper.ConvertToDate(row["MODIFIED_ON"]);
                    o.ModifiedBy = Helper.ConvertToInt(row["MODIFIED_BY"]);
                    oList.Add(o);
                }
                catch (Exception ex)
                {
                    Log.InsertEntity("ChildSupplements", "GetChildSupplementsAsList", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
                    throw ex;
                }
            }
            return(oList);
        }
コード例 #2
0
 public static int Update(ChildSupplements o)
 {
     try
     {
         string query = @"UPDATE ""CHILD_SUPPLEMENTS"" SET ""ID"" = @Id, ""CHILD_ID"" = @ChildId, ""VitA"" = @Vita, ""Mebendezol"" = @Mebendezol, ""DATE"" = @Date, ""MODIFIED_ON"" = @ModifiedOn, ""MODIFIED_BY"" = @ModifiedBy WHERE ""ID"" = @Id ";
         List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@ChildId", DbType.Int32)
             {
                 Value = o.ChildId
             },
             new NpgsqlParameter("@Vita", DbType.Boolean)
             {
                 Value = o.Vita
             },
             new NpgsqlParameter("@Mebendezol", DbType.Boolean)
             {
                 Value = o.Mebendezol
             },
             new NpgsqlParameter("@Date", DbType.Date)
             {
                 Value = o.Date
             },
             new NpgsqlParameter("@ModifiedOn", DbType.DateTime)
             {
                 Value = o.ModifiedOn
             },
             new NpgsqlParameter("@ModifiedBy", DbType.Int32)
             {
                 Value = o.ModifiedBy
             },
             new NpgsqlParameter("@Id", DbType.Int32)
             {
                 Value = o.Id
             }
         };
         int rowAffected = DBManager.ExecuteNonQueryCommand(query, CommandType.Text, parameters);
         AuditTable.InsertEntity("ChildSupplements", o.Id.ToString(), 2, DateTime.Now, o.ModifiedBy);
         return(rowAffected);
     }
     catch (Exception ex)
     {
         Log.InsertEntity("ChildSupplements", "Update", 2, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
     }
     return(-1);
 }
コード例 #3
0
 public static int Insert(ChildSupplements o)
 {
     try
     {
         string query = @"INSERT INTO ""CHILD_SUPPLEMENTS"" (""CHILD_ID"", ""VitA"", ""Mebendezol"", ""DATE"", ""MODIFIED_ON"", ""MODIFIED_BY"") VALUES (@ChildId, @Vita, @Mebendezol, @Date, @ModifiedOn, @ModifiedBy) returning ""ID"" ";
         List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@ChildId", DbType.Int32)
             {
                 Value = o.ChildId
             },
             new NpgsqlParameter("@Vita", DbType.Boolean)
             {
                 Value = o.Vita
             },
             new NpgsqlParameter("@Mebendezol", DbType.Boolean)
             {
                 Value = o.Mebendezol
             },
             new NpgsqlParameter("@Date", DbType.Date)
             {
                 Value = o.Date
             },
             new NpgsqlParameter("@ModifiedOn", DbType.DateTime)
             {
                 Value = o.ModifiedOn
             },
             new NpgsqlParameter("@ModifiedBy", DbType.Int32)
             {
                 Value = o.ModifiedBy
             }
         };
         object id = DBManager.ExecuteScalarCommand(query, CommandType.Text, parameters);
         AuditTable.InsertEntity("ChildSupplements", id.ToString(), 1, DateTime.Now, o.ModifiedBy);
         return(int.Parse(id.ToString()));
     }
     catch (Exception ex)
     {
         Log.InsertEntity("ChildSupplements", "Insert", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
     }
     return(-1);
 }