public static BE.PhotoGalleryCatagory[] SelectApproved()
        {
            ArrayList photoGalleryCatagorys = new ArrayList();

            BE.PhotoGalleryCatagory photoGalleryCatagory;
            string     SQLQuery = "SELECT * FROM [PhotoGalleryCatagory] where Publish=@Publish ";
            SqlCommand command  = new SqlCommand();

            command.CommandText = SQLQuery;
            command.Parameters.AddWithValue("@Publish", "P");
            SqlDataReader reader = SQLHelper.ExecuteReader(command);

            while (reader.Read())
            {
                photoGalleryCatagory = new BE.PhotoGalleryCatagory();

                photoGalleryCatagory.Id           = Convert.ToInt32(reader["Id"]);
                photoGalleryCatagory.CatagoryName = Convert.ToString(reader["CatagoryName"]);
                photoGalleryCatagory.Publish      = Convert.ToString(reader["Publish"]);
                photoGalleryCatagorys.Add(photoGalleryCatagory);
            }


            reader.Close();
            reader.Dispose();
            return((BE.PhotoGalleryCatagory[])photoGalleryCatagorys.ToArray(typeof(BE.PhotoGalleryCatagory)));
        }
        public static bool Update(BE.PhotoGalleryCatagory photoGalleryCatagory)
        {
            string SQLQuery = "UPDATE [PhotoGalleryCatagory] SET Id = @Id, CatagoryName= @CatagoryName, Publish= @Publish WHERE [Id]=@Id ";

            SqlCommand command = new SqlCommand();

            command.CommandText = SQLQuery;

            AddParameters(command, photoGalleryCatagory);

            return(Convert.ToBoolean(SQLHelper.ExecuteNonQuery(command)));
        }
        public static bool Insert(BE.PhotoGalleryCatagory photoGalleryCatagory)
        {
            string SQLQuery = "INSERT INTO [PhotoGalleryCatagory] ( id,catagoryName,publish ) VALUES	(@id, @catagoryName, @publish)";

            SqlCommand command = new SqlCommand();

            command.CommandText = SQLQuery;

            AddParameters(command, photoGalleryCatagory);

            return(Convert.ToBoolean(SQLHelper.ExecuteNonQuery(command)));
        }
        public static bool Save(BE.PhotoGalleryCatagory photoGalleryCatagory)
        {
            bool IsAffected = false;

            if (photoGalleryCatagory.State == BE.RowState.Added)
            {
                IsAffected = Insert(photoGalleryCatagory);
            }
            else if (photoGalleryCatagory.State == BE.RowState.Modified)
            {
                IsAffected = Update(photoGalleryCatagory);
            }
            else if (photoGalleryCatagory.State == BE.RowState.Deleted)
            {
                IsAffected = Delete(photoGalleryCatagory.Id);
            }
            return(IsAffected);
        }
        public static BE.PhotoGalleryCatagory Select(Int32 Id)
        {
            BE.PhotoGalleryCatagory photoGalleryCatagory = new BE.PhotoGalleryCatagory();
            string SQLQuery = "SELECT * FROM [PhotoGalleryCatagory] WHERE [Id]=@Id ";

            SqlCommand command = new SqlCommand();

            command.CommandText = SQLQuery;
            command.Parameters.AddWithValue("@Id", Id);

            SqlDataReader reader = SQLHelper.ExecuteReader(command);

            reader.Read();

            photoGalleryCatagory.Id           = Convert.ToInt32(reader["Id"]);
            photoGalleryCatagory.CatagoryName = Convert.ToString(reader["CatagoryName"]);
            photoGalleryCatagory.Publish      = Convert.ToString(reader["Publish"]);

            reader.Close();
            reader.Dispose();
            return(photoGalleryCatagory);
        }
 private static void AddParameters(SqlCommand command, BE.PhotoGalleryCatagory photoGalleryCatagory)
 {
     command.Parameters.AddWithValue("@Id", photoGalleryCatagory.Id);
     command.Parameters.AddWithValue("@CatagoryName", photoGalleryCatagory.CatagoryName);
     command.Parameters.AddWithValue("@Publish", photoGalleryCatagory.Publish);
 }