public static List <ScheduledVaccination> GetScheduledVaccinationAsList(DataTable dt)
        {
            List <ScheduledVaccination> oList = new List <ScheduledVaccination>();

            foreach (DataRow row in dt.Rows)
            {
                try
                {
                    ScheduledVaccination o = new ScheduledVaccination();
                    o.Id         = Helper.ConvertToInt(row["ID"]);
                    o.Name       = row["NAME"].ToString();
                    o.Code       = row["CODE"].ToString();
                    o.ItemId     = Helper.ConvertToInt(row["ITEM_ID"]);
                    o.EntryDate  = Helper.ConvertToDate(row["ENTRY_DATE"]);
                    o.ExitDate   = Helper.ConvertToDate(row["EXIT_DATE"]);
                    o.Status     = Helper.ConvertToBoolean(row["STATUS"]);
                    o.Deseases   = row["DESEASES"].ToString();
                    o.Notes      = row["NOTES"].ToString();
                    o.IsActive   = Helper.ConvertToBoolean(row["IS_ACTIVE"]);
                    o.ModifiedOn = Helper.ConvertToDate(row["MODIFIED_ON"]);
                    o.ModifiedBy = Helper.ConvertToInt(row["MODIFIED_BY"]);
                    oList.Add(o);
                }
                catch (Exception ex)
                {
                    Log.InsertEntity("ScheduledVaccination", "GetScheduledVaccinationAsList", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
                    throw ex;
                }
            }
            return(oList);
        }
 public static int Update(ScheduledVaccination o)
 {
     try
     {
         string query = @"UPDATE ""SCHEDULED_VACCINATION"" SET ""ID"" = @Id, ""NAME"" = @Name, ""CODE"" = @Code, ""ITEM_ID"" = @ItemId, ""ENTRY_DATE"" = @EntryDate, ""EXIT_DATE"" = @ExitDate, ""STATUS"" = @Status, ""DESEASES"" = @Deseases, ""NOTES"" = @Notes, ""IS_ACTIVE"" = @IsActive, ""MODIFIED_ON"" = @ModifiedOn, ""MODIFIED_BY"" = @ModifiedBy WHERE ""ID"" = @Id ";
         List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@Name", DbType.String)
             {
                 Value = o.Name
             },
             new NpgsqlParameter("@Code", DbType.String)
             {
                 Value = o.Code
             },
             new NpgsqlParameter("@ItemId", DbType.Int32)
             {
                 Value = o.ItemId
             },
             new NpgsqlParameter("@EntryDate", DbType.Date)
             {
                 Value = o.EntryDate
             },
             new NpgsqlParameter("@ExitDate", DbType.Date)
             {
                 Value = (object)o.ExitDate ?? DBNull.Value
             },
             new NpgsqlParameter("@Status", DbType.Boolean)
             {
                 Value = o.Status
             },
             new NpgsqlParameter("@Deseases", DbType.String)
             {
                 Value = (object)o.Deseases ?? DBNull.Value
             },
             new NpgsqlParameter("@Notes", DbType.String)
             {
                 Value = (object)o.Notes ?? DBNull.Value
             },
             new NpgsqlParameter("@IsActive", DbType.Boolean)
             {
                 Value = o.IsActive
             },
             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("ScheduledVaccination", o.Id.ToString(), 2, DateTime.Now, o.ModifiedBy);
         return(rowAffected);
     }
     catch (Exception ex)
     {
         Log.InsertEntity("ScheduledVaccination", "Update", 2, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
     }
     return(-1);
 }
 public static int Insert(ScheduledVaccination o)
 {
     try
     {
         string query = @"INSERT INTO ""SCHEDULED_VACCINATION"" (""NAME"", ""CODE"", ""ITEM_ID"", ""ENTRY_DATE"", ""EXIT_DATE"", ""STATUS"", ""DESEASES"", ""NOTES"", ""IS_ACTIVE"", ""MODIFIED_ON"", ""MODIFIED_BY"") VALUES (@Name, @Code, @ItemId, @EntryDate, @ExitDate, @Status, @Deseases, @Notes, @IsActive, @ModifiedOn, @ModifiedBy) returning ""ID"" ";
         List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@Name", DbType.String)
             {
                 Value = o.Name
             },
             new NpgsqlParameter("@Code", DbType.String)
             {
                 Value = o.Code
             },
             new NpgsqlParameter("@ItemId", DbType.Int32)
             {
                 Value = o.ItemId
             },
             new NpgsqlParameter("@EntryDate", DbType.Date)
             {
                 Value = o.EntryDate
             },
             new NpgsqlParameter("@ExitDate", DbType.Date)
             {
                 Value = (object)o.ExitDate ?? DBNull.Value
             },
             new NpgsqlParameter("@Status", DbType.Boolean)
             {
                 Value = o.Status
             },
             new NpgsqlParameter("@Deseases", DbType.String)
             {
                 Value = (object)o.Deseases ?? DBNull.Value
             },
             new NpgsqlParameter("@Notes", DbType.String)
             {
                 Value = (object)o.Notes ?? DBNull.Value
             },
             new NpgsqlParameter("@IsActive", DbType.Boolean)
             {
                 Value = o.IsActive
             },
             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("ScheduledVaccination", id.ToString(), 1, DateTime.Now, o.ModifiedBy);
         return(int.Parse(id.ToString()));
     }
     catch (Exception ex)
     {
         Log.InsertEntity("ScheduledVaccination", "Insert", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
     }
     return(-1);
 }