Esempio n. 1
0
        int count = 0;//Dùng để trờ về trang ds phòng sau khi xem ds sv mỗi phòng

        #region Method
        void LoadPhong()
        {
            List <PHONG> dsp = PhongBLL.GetAll();

            foreach (PHONG item in ktx.PHONGs)
            {
                var dssv = MyDb.GetInstance().HOPDONGs.Where(x => x.Sophong == item.Sophong).Count();

                Button button1 = new Button();
                //
                // button1
                //
                button1.BackColor = System.Drawing.Color.DarkRed;
                button1.ForeColor = System.Drawing.Color.Coral;
                button1.Location  = new System.Drawing.Point(463, 10);
                button1.Name      = "button1";
                button1.Size      = new System.Drawing.Size(75, 23);
                button1.TabIndex  = 40;
                button1.Text      = "button1";
                button1.UseVisualStyleBackColor = false;
                IconButton iBtnPhong = new IconButton();
                if (item.LoaiPhong == "Nam")
                {
                    #region Phòng Nam
                    //Design button bằng code
                    iBtnPhong.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(6)))), ((int)(((byte)(137)))), ((int)(((byte)(255)))));
                    iBtnPhong.FlatAppearance.BorderSize = 0;
                    iBtnPhong.FlatStyle  = System.Windows.Forms.FlatStyle.Flat;
                    iBtnPhong.Flip       = FontAwesome.Sharp.FlipOrientation.Normal;
                    iBtnPhong.Font       = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    iBtnPhong.ForeColor  = System.Drawing.Color.White;
                    iBtnPhong.IconChar   = FontAwesome.Sharp.IconChar.Male;
                    iBtnPhong.IconColor  = System.Drawing.Color.White;
                    iBtnPhong.IconSize   = 40;
                    iBtnPhong.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
                    iBtnPhong.Location   = new System.Drawing.Point(403, 245);
                    iBtnPhong.Name       = "iconButton1";
                    iBtnPhong.Rotation   = 0D;
                    iBtnPhong.Size       = new System.Drawing.Size(123, 70);
                    iBtnPhong.TabIndex   = 15;
                    iBtnPhong.Text       = item.Sophong + "\r\n" + dssv.ToString() + "/" + item.Sluongsv.ToString() + " SV\r\n";
                    iBtnPhong.TextAlign  = System.Drawing.ContentAlignment.MiddleRight;
                    iBtnPhong.UseVisualStyleBackColor = false;
                    #endregion
                }
                else
                {
                    #region Phòng Nữ
                    iBtnPhong.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(77)))), ((int)(((byte)(214)))));
                    iBtnPhong.FlatAppearance.BorderSize = 0;
                    iBtnPhong.FlatStyle  = System.Windows.Forms.FlatStyle.Flat;
                    iBtnPhong.Flip       = FontAwesome.Sharp.FlipOrientation.Normal;
                    iBtnPhong.Font       = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    iBtnPhong.ForeColor  = System.Drawing.Color.White;
                    iBtnPhong.IconChar   = FontAwesome.Sharp.IconChar.Female;
                    iBtnPhong.IconColor  = System.Drawing.Color.White;
                    iBtnPhong.IconSize   = 40;
                    iBtnPhong.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
                    iBtnPhong.Location   = new System.Drawing.Point(403, 245);
                    iBtnPhong.Name       = "iconButton1";
                    iBtnPhong.Rotation   = 0D;
                    iBtnPhong.Size       = new System.Drawing.Size(123, 70);
                    iBtnPhong.TabIndex   = 15;
                    iBtnPhong.Text       = item.Sophong + "\r\n" + dssv.ToString() + "/" + item.Sluongsv.ToString() + " SV\r\n";
                    iBtnPhong.TextAlign  = System.Drawing.ContentAlignment.MiddleRight;
                    iBtnPhong.UseVisualStyleBackColor = false;
                    #endregion
                }
                iBtnPhong.Click += IBtnPhong_Click;
                //Design button phòng --> gắn event
                button1.Click += Button1_Click;
                button1.Tag    = item;
                //
                iBtnPhong.Tag = item;
                PanelPhong.Controls.Add(iBtnPhong);
            }
        }