Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string GalID = Request.QueryString["ID"];

            Label1.Text = galleryName(int.Parse(GalID));
            List <ImageButton> images = new List <ImageButton>();
            //string QueryText = $"select * from Picture_List where Gallery_ID={int.Parse(GalID)}";
            string DB = @"Data Source=DESKTOP-5582JAK\SQLEXPRESS; Initial Catalog=Galery; Integrated Security=true";

            List <PhotoField> imagesPh  = new List <PhotoField>();
            string            QueryText = $"select * from Picture_List where Gallery_ID={int.Parse(GalID)}";

            using (SqlConnection Conn = new SqlConnection(DB))
            {
                Conn.Open();
                SqlCommand    Comm = new SqlCommand(QueryText, Conn);
                SqlDataReader R    = Comm.ExecuteReader();
                while (R.Read())
                {
                    imagesPh.Add(new PhotoField(R.GetInt32(0), R.GetInt32(1), R.GetInt32(2), R[3].ToString(), R[4].ToString(), R[5].ToString()));
                }
                imagesPh.Sort((x, y) => PhotoField.Compare(x, y));

                for (int i = 0; i < imagesPh.Count; i++)
                {
                    images.Add(createImage(imagesPh[i].mini_version, imagesPh[i].full_version, imagesPh[i].description));
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Default.auth)
            {
                Response.Redirect("~/Default.aspx");
            }

            string GalID = Request.QueryString["ID"];

            Label1.Text = galleryName(int.Parse(GalID));

            images = new List <PhotoField>();
            string QueryText = $"select * from Picture_List where Gallery_ID={int.Parse(GalID)}";

            using (SqlConnection Conn = new SqlConnection(DB))
            {
                Conn.Open();
                SqlCommand    Comm = new SqlCommand(QueryText, Conn);
                SqlDataReader R    = Comm.ExecuteReader();
                while (R.Read())
                {
                    images.Add(new PhotoField(R.GetInt32(0), R.GetInt32(1), R.GetInt32(2), R[3].ToString(), R[4].ToString(), R[5].ToString()));
                }
                images.Sort((x, y) => PhotoField.Compare(x, y));
                Table1.Width = 200 + 3 * PhotoField.ButtonsWidth;

                for (int i = 0; i < images.Count; i++)
                {
                    TableRow tr = new TableRow();
                    tr.Width = Table1.Width;

                    TableCell tc1 = new TableCell();
                    images[i].pic.Command += new CommandEventHandler(redirect);
                    tc1.Controls.Add(images[i].pic);

                    tr.Cells.Add(tc1);

                    TableCell td2 = new TableCell();
                    images[i].Up.Command += new CommandEventHandler(upRecord);

                    td2.Controls.Add(images[i].Up);
                    tr.Cells.Add(td2);

                    TableCell td3 = new TableCell();
                    images[i].Down.Command += new CommandEventHandler(downRecord);
                    td3.Controls.Add(images[i].Down);
                    tr.Cells.Add(td3);

                    TableCell td4 = new TableCell();
                    images[i].Delete.Command += new CommandEventHandler(deleteRecord);
                    td4.Controls.Add(images[i].Delete);
                    tr.Cells.Add(td4);
                    Table1.Rows.Add(tr);
                }
            }
        }
Esempio n. 3
0
 public static int Compare(PhotoField arg1, PhotoField arg2)
 {
     if (arg1.Number >= arg2.Number)
     {
         return(1);
     }
     if (arg1.Number <= arg2.Number)
     {
         return(-1);
     }
     return(0);
 }