public void HienThi(ListView list, ComboBox day, ComboBox trangthai)
        {
            PhongData phong = new PhongData();

            list.Items.Clear();
            DataTable table = phong.LayDSPhong();

            foreach (DataRow row in table.Rows)
            {
                PhongInfo    info = RowToInfo(row);
                ListViewItem item = new ListViewItem();
                item.Text = info.MaPhong;
                item.SubItems.Add(info.TenPhong);
                item.SubItems.Add(info.Day.TenDay);
                item.SubItems.Add(info.SoLuongToiDa.ToString());
                item.SubItems.Add(info.TrangThai.TenTrangThai);
                item.SubItems.Add((info.PhongNam == true?"Nam":"Nữ"));
                item.Tag = info;
                list.Items.Add(item);
            }

            //----------------
            DayCtrl dayctrl = new DayCtrl();

            dayctrl.LayDuLieuLenComboBox(day);
            TrangThaiPhongCtrl dayctrl1 = new TrangThaiPhongCtrl();

            dayctrl1.LayDuLieuLenComboBox(trangthai);
        }
Пример #2
0
        private void ToolStripCapNhat_Click(object sender, EventArgs e)
        {
            //Default();
            PhongData data = new PhongData();

            listViewEx1.Items.Clear();
            foreach (DataRow dr in data.LayMaPhong().Rows)
            {
                PhongInFo phong = new PhongInFo();
                phong.MaLoaiPhong    = (string)dr.ItemArray[1];
                phong.MaPhong        = (string)dr.ItemArray[0];
                phong.TinhTrangPhong = (int)dr.ItemArray[2];
                ListViewItem item = new ListViewItem(phong.MaPhong);

                if (phong.TinhTrangPhong == 1)
                {
                    item.ImageIndex = 0;
                }
                else if (phong.TinhTrangPhong == 2)
                {
                    item.ImageIndex = 1;
                }
                else
                {
                    item.ImageIndex = 2;
                }
                listViewEx1.Items.Add(item);
            }
        }
        public void LayDuLieuLenComboBox_DK_DAY(ComboBox cmb, string maday)
        {
            PhongData hd = new PhongData();

            cmb.DataSource    = hd.LayDSPhong_DK_DAY(maday);
            cmb.DisplayMember = "TENPHG";
            cmb.ValueMember   = "MAPHG";
        }
        public void LayDuLieuLenComboBox(ComboBoxEx cmb)
        {
            PhongData hd    = new PhongData();
            DataTable table = hd.LayDSPhong();

            cmb.DataSource    = table;
            cmb.DisplayMember = "TENPHG";
            cmb.ValueMember   = "MAPHG";
        }
        public void LayDuLieuLenComboBoxItem(ComboBoxItem cmb)
        {
            PhongData hd    = new PhongData();
            DataTable table = hd.LayDSPhong();

            foreach (DataRow row in table.Rows)
            {
                cmb.Items.Add(row["TenPHG"]);
            }
            //cmb.DisplayMember = "TENPHG";
            //cmb.ValueMember = "MAPHG";
        }
Пример #6
0
        private void saveToolStripButton_Click(object sender, EventArgs e)
        {
            bindingNavigatorPositionItem.Focus();
            this.Luu();
            status = Controll.Normal;
            this.Allow(false);

            foreach (DataGridViewRow row in dataGridViewX1.Rows)
            {
                if (row.Cells["MaPhong"].Value != null)
                {
                    String maphong = row.Cells["MaPhong"].Value.ToString();
                    PhongData.CapNhatMaLoaiTinhTrangPhong(maphong, 3);
                }
            }
        }
Пример #7
0
        public QUANLYKHACHSAN.BusinessObject.PhongInFo LayMaPhong(string maphong)
        {
            PhongData        p   = new PhongData();
            LoaiPhongControl lp  = new LoaiPhongControl();
            DataTable        tbl = p.LayMaPhong(maphong);

            QUANLYKHACHSAN.BusinessObject.PhongInFo pif = null;
            pif = new QUANLYKHACHSAN.BusinessObject.PhongInFo();

            if (tbl.Rows.Count > 0)
            {
                pif.MaPhong     = Convert.ToString(tbl.Rows[0]["MaPhong"]);
                pif.MaLoaiPhong = Convert.ToString(tbl.Rows[0]["MaLoaiPhong"]);
                pif.GhiChu      = Convert.ToString(tbl.Rows[0]["GhiChu"]);
            }
            return(pif);
        }
Пример #8
0
        protected void OnPaint(PaintEventArgs e)
        {
            PhongData data = new PhongData();
            Graphics  gp   = this.CreateGraphics();

            List <PhongInFo> phongdb = new List <PhongInFo>();
            List <PhongInFo> phongl1 = new List <PhongInFo>();
            List <PhongInFo> phongl2 = new List <PhongInFo>();

            int x = 10;
            int y = 60;

            for (int i = 0; i < phongdb.Count; i++)
            {
                if (x > 480)
                {
                    x = y + 40;
                    x = 10;
                }
                switch (phongdb[i].TinhTrangPhong)
                {
                case 1:
                {
                    StringFormat s = new StringFormat();
                    s.Alignment     = StringAlignment.Center;
                    s.LineAlignment = StringAlignment.Center;
                    Rectangle r = new Rectangle((x) + 15, y, 50, 30);
                    gp.DrawRectangle(new Pen(Color.White), r);
                    gp.FillRectangle(new SolidBrush(Color.LightSeaGreen), r);
                    gp.DrawString(phongdb[i].MaPhong.ToString(), this.Font, new SolidBrush(Color.White), r, s);
                    break;
                }

                case 2:
                {
                    StringFormat s = new StringFormat();
                    s.Alignment     = StringAlignment.Center;
                    s.LineAlignment = StringAlignment.Center;
                    Rectangle r = new Rectangle((x) + 15, y, 50, 30);
                    gp.DrawRectangle(new Pen(Color.White), r);
                    gp.FillRectangle(new SolidBrush(Color.MediumVioletRed), r);
                    gp.DrawString(phongdb[i].MaPhong.ToString(), this.Font, new SolidBrush(Color.White), r, s);
                    break;
                }

                case 3:
                {
                    StringFormat s = new StringFormat();
                    s.Alignment     = StringAlignment.Center;
                    s.LineAlignment = StringAlignment.Center;
                    Rectangle r = new Rectangle((x) + 15, y, 50, 30);
                    gp.DrawRectangle(new Pen(Color.White), r);
                    gp.FillRectangle(new SolidBrush(Color.Red), r);
                    gp.DrawString(phongl1[i].MaPhong.ToString(), this.Font, new SolidBrush(Color.White), r, s);
                    break;
                }
                }
                x = x + 70;
            }

            x = 10;
            y = y + 50;
            gp.DrawLine(new Pen(Color.Black, 3), new Point(25, y - 10), new Point(x + 485, y - 10));
            for (int i = 0; i < phongl2.Count; i++)
            {
                if (x > 480)
                {
                    x  = 10;
                    y += 40;
                }
                switch (phongl2[i].TinhTrangPhong)
                {
                case 1:
                {
                    StringFormat s = new StringFormat();
                    s.Alignment     = StringAlignment.Center;
                    s.LineAlignment = StringAlignment.Center;
                    Rectangle r = new Rectangle((x) + 15, y, 50, 30);
                    gp.DrawRectangle(new Pen(Color.White), r);
                    gp.FillRectangle(new SolidBrush(Color.LightSeaGreen), r);
                    gp.DrawString(phongl2[i].MaPhong.ToString(), this.Font, new SolidBrush(Color.White), r, s);
                    break;
                }

                case 2:
                {
                    StringFormat s = new StringFormat();
                    s.Alignment     = StringAlignment.Center;
                    s.LineAlignment = StringAlignment.Center;
                    Rectangle r = new Rectangle((x) + 15, y, 50, 30);
                    gp.DrawRectangle(new Pen(Color.White), r);
                    gp.FillRectangle(new SolidBrush(Color.MediumVioletRed), r);
                    gp.DrawString(phongl2[i].MaPhong.ToString(), this.Font, new SolidBrush(Color.White), r, s);
                    break;
                }

                case 3:
                {
                    StringFormat s = new StringFormat();
                    s.Alignment     = StringAlignment.Center;
                    s.LineAlignment = StringAlignment.Center;
                    Rectangle r = new Rectangle((x) + 15, y, 50, 30);
                    gp.DrawRectangle(new Pen(Color.White), r);
                    gp.FillRectangle(new SolidBrush(Color.Red), r);
                    gp.DrawString(phongl2[i].MaPhong.ToString(), this.Font, new SolidBrush(Color.White), r, s);
                    break;
                }
                }
                x += 70;
            }
            gp.Dispose();
        }
Пример #9
0
        static void Main()
        {
            if (!SharpDevice.IsDirectX11Supported())
            {
                System.Windows.Forms.MessageBox.Show("DirectX11 Not Supported");
                return;
            }

            //render form
            RenderForm form = new RenderForm();
            form.Text = "Tutorial 10: Render Target";
            //frame rate counter
            SharpFPS fpsCounter = new SharpFPS();

            using (SharpDevice device = new SharpDevice(form))
            {
                //load font
                SharpBatch font = new SharpBatch(device, "textfont.dds");

                //load model from wavefront obj file
                SharpMesh dogMesh = SharpMesh.CreateNormalMappedFromObj(device, "../../../Models/dog/dog.obj");
                SharpMesh cubeMesh = SharpMesh.CreateFromObj(device, "../../../Models/cube.obj");

                //init shader
                SharpShader phongShader = new SharpShader(device, "../../HLSL.txt",
                    new SharpShaderDescription() { VertexShaderFunction = "VS", PixelShaderFunction = "PS" },
                    new InputElement[] {
                        new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0),
                        new InputElement("NORMAL", 0, Format.R32G32B32_Float, 12, 0),
                        new InputElement("TANGENT", 0, Format.R32G32B32_Float, 24, 0),
                        new InputElement("BINORMAL", 0, Format.R32G32B32_Float, 36, 0),
                        new InputElement("TEXCOORD", 0, Format.R32G32_Float, 48, 0)
                    });

                SharpShader renderTargetShader = new SharpShader(device, "../../HLSL_RT.txt",
                    new SharpShaderDescription() { VertexShaderFunction = "VS", PixelShaderFunction = "PS" },
                    new InputElement[] {
                        new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0),
                        new InputElement("NORMAL", 0, Format.R32G32B32_Float, 12, 0),
                        new InputElement("TEXCOORD", 0, Format.R32G32_Float, 24, 0)
                    });

                //render target
                SharpRenderTarget target = new SharpRenderTarget(device, 512, 512, Format.R8G8B8A8_UNorm);

                //init constant buffer
                Buffer11 phongConstantBuffer = phongShader.CreateBuffer<PhongData>();
                Buffer11 renderTargetConstantBuffer = phongShader.CreateBuffer<RenderTargetData>();

                //init frame counter
                fpsCounter.Reset();

                //effect inside shader
                int mode = 0;
                form.KeyDown += (sender, e) =>
                {
                    switch (e.KeyCode)
                    {
                        case Keys.D1:
                            mode = 0;
                            break;
                        case Keys.D2:
                            mode = 1;
                            break;
                        case Keys.D3:
                            mode = 2;
                            break;
                        case Keys.D4:
                            mode = 3;
                            break;
                    }
                };

                //main loop
                RenderLoop.Run(form, () =>
                {
                    //Resizing
                    if (device.MustResize)
                    {
                        device.Resize();
                        font.Resize();
                    }

                    //apply states
                    device.UpdateAllStates();

                    //BEGIN RENDERING TO TEXTURE
                    target.Apply();
                    target.Clear(Color.CornflowerBlue);

                    //set transformation matrix
                    float ratio = (float)form.ClientRectangle.Width / (float)form.ClientRectangle.Height;
                    Matrix projection = Matrix.PerspectiveFovLH(3.14F / 3.0F, ratio, 1F, 1000.0F);

                    Vector3 from = new Vector3(0, 70, -150);
                    Vector3 to = new Vector3(0, 50, 0);

                    Matrix view = Matrix.LookAtLH(from, to, Vector3.UnitY);
                    Matrix world = Matrix.RotationY(Environment.TickCount / 2000.0F);

                    //light direction
                    Vector3 lightDirection = new Vector3(0.5f, 0, -1);
                    lightDirection.Normalize();

                    PhongData sceneInformation = new PhongData()
                    {
                        world = world,
                        worldViewProjection = world * view * projection,
                        lightDirection = new Vector4(lightDirection, 1),
                    };

                    //apply shader
                    phongShader.Apply();

                    //write data inside constant buffer
                    device.UpdateData<PhongData>(phongConstantBuffer, sceneInformation);

                    //apply constant buffer to shader
                    device.DeviceContext.VertexShader.SetConstantBuffer(0, phongConstantBuffer);
                    device.DeviceContext.PixelShader.SetConstantBuffer(0, phongConstantBuffer);

                    //draw mesh
                    dogMesh.Begin();
                    for (int i = 0; i < dogMesh.SubSets.Count; i++)
                    {
                        device.DeviceContext.PixelShader.SetShaderResource(0, dogMesh.SubSets[i].DiffuseMap);
                        device.DeviceContext.PixelShader.SetShaderResource(1, dogMesh.SubSets[i].NormalMap);
                        dogMesh.Draw(i);
                    }

                    //RENDERING TO DEVICE

                    //Set original targets
                    device.SetDefaultTargers();

                    //apply shader
                    renderTargetShader.Apply();

                    Matrix WVP =
                        Matrix.RotationY(Environment.TickCount / 2000.0F) *
                        Matrix.LookAtLH(new Vector3(7, 10, -13), new Vector3(), Vector3.UnitY) *
                        projection;
                    device.UpdateData<RenderTargetData>(renderTargetConstantBuffer, new RenderTargetData() { worldViewProjection = WVP, data = new Vector4(mode, 0, 0, 0) });

                    //clear color
                    device.Clear(Color.Black);

                    renderTargetShader.Apply();

                    //apply constant buffer to shader
                    device.DeviceContext.VertexShader.SetConstantBuffer(0, renderTargetConstantBuffer);
                    device.DeviceContext.PixelShader.SetConstantBuffer(0, renderTargetConstantBuffer);

                    //set target
                    device.DeviceContext.PixelShader.SetShaderResource(0, target.Resource);

                    cubeMesh.Draw();

                    //begin drawing text
                    font.Begin();

                    //draw string
                    fpsCounter.Update();
                    font.DrawString("FPS: " + fpsCounter.FPS, 0, 0, Color.White);
                    font.DrawString("Press 1 To 4 to change Effect", 0, 30, Color.White);

                    //flush text to view
                    font.End();
                    //present
                    device.Present();

                });

                //release resource
                font.Dispose();
                dogMesh.Dispose();
                cubeMesh.Dispose();
                phongConstantBuffer.Dispose();
                renderTargetConstantBuffer.Dispose();
                phongShader.Dispose();
                renderTargetShader.Dispose();

            }
        }
Пример #10
0
        static void Main()
        {
            if (!SharpDevice.IsDirectX11Supported())
            {
                System.Windows.Forms.MessageBox.Show("DirectX11 Not Supported");
                return;
            }

            //render form
            RenderForm form = new RenderForm();

            form.Text = "Tutorial 10: Render Target";
            //frame rate counter
            SharpFPS fpsCounter = new SharpFPS();


            using (SharpDevice device = new SharpDevice(form))
            {
                //load model from wavefront obj file
                SharpMesh dogMesh  = SharpMesh.CreateNormalMappedFromObj(device, "../../../Models/dog/dog.obj");
                SharpMesh cubeMesh = SharpMesh.CreateFromObj(device, "../../../Models/cube.obj");

                //init shader
                SharpShader phongShader = new SharpShader(device, "../../HLSL.txt",
                                                          new SharpShaderDescription()
                {
                    VertexShaderFunction = "VS", PixelShaderFunction = "PS"
                },
                                                          new InputElement[] {
                    new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0),
                    new InputElement("NORMAL", 0, Format.R32G32B32_Float, 12, 0),
                    new InputElement("TANGENT", 0, Format.R32G32B32_Float, 24, 0),
                    new InputElement("BINORMAL", 0, Format.R32G32B32_Float, 36, 0),
                    new InputElement("TEXCOORD", 0, Format.R32G32_Float, 48, 0)
                });

                SharpShader renderTargetShader = new SharpShader(device, "../../HLSL_RT.txt",
                                                                 new SharpShaderDescription()
                {
                    VertexShaderFunction = "VS", PixelShaderFunction = "PS"
                },
                                                                 new InputElement[] {
                    new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0),
                    new InputElement("NORMAL", 0, Format.R32G32B32_Float, 12, 0),
                    new InputElement("TEXCOORD", 0, Format.R32G32_Float, 24, 0)
                });

                //render target
                SharpRenderTarget target = new SharpRenderTarget(device, 512, 512, Format.B8G8R8A8_UNorm);

                //init constant buffer
                Buffer11 phongConstantBuffer        = phongShader.CreateBuffer <PhongData>();
                Buffer11 renderTargetConstantBuffer = phongShader.CreateBuffer <RenderTargetData>();

                //init frame counter
                fpsCounter.Reset();

                var capture = false;

                //effect inside shader
                int mode = 0;
                form.KeyDown += (sender, e) =>
                {
                    switch (e.KeyCode)
                    {
                    case Keys.D1:
                        mode = 0;
                        break;

                    case Keys.D2:
                        mode = 1;
                        break;

                    case Keys.D3:
                        mode = 2;
                        break;

                    case Keys.D4:
                        mode = 3;
                        break;

                    case Keys.D5:
                        capture = true;
                        break;
                    }
                };

                //main loop
                RenderLoop.Run(form, () =>
                {
                    //Resizing
                    if (device.MustResize)
                    {
                        device.Resize();
                    }

                    //apply states
                    device.UpdateAllStates();


                    //BEGIN RENDERING TO TEXTURE
                    target.Apply();
                    target.Clear(Color.CornflowerBlue);

                    //set transformation matrix
                    float ratio       = (float)form.ClientRectangle.Width / (float)form.ClientRectangle.Height;
                    Matrix projection = Matrix.PerspectiveFovLH(3.14F / 3.0F, ratio, 1F, 1000.0F);

                    Vector3 from = new Vector3(0, 70, -150);
                    Vector3 to   = new Vector3(0, 50, 0);

                    Matrix view  = Matrix.LookAtLH(from, to, Vector3.UnitY);
                    Matrix world = Matrix.RotationY(Environment.TickCount / 2000.0F);

                    //light direction
                    Vector3 lightDirection = new Vector3(0.5f, 0, -1);
                    lightDirection.Normalize();


                    PhongData sceneInformation = new PhongData()
                    {
                        world = world,
                        worldViewProjection = world * view * projection,
                        lightDirection      = new Vector4(lightDirection, 1),
                    };


                    //apply shader
                    phongShader.Apply();

                    //write data inside constant buffer
                    device.UpdateData <PhongData>(phongConstantBuffer, sceneInformation);

                    //apply constant buffer to shader
                    device.DeviceContext.VertexShader.SetConstantBuffer(0, phongConstantBuffer);
                    device.DeviceContext.PixelShader.SetConstantBuffer(0, phongConstantBuffer);

                    //draw mesh
                    dogMesh.Begin();
                    for (int i = 0; i < dogMesh.SubSets.Count; i++)
                    {
                        device.DeviceContext.PixelShader.SetShaderResource(0, dogMesh.SubSets[i].DiffuseMap);
                        device.DeviceContext.PixelShader.SetShaderResource(1, dogMesh.SubSets[i].NormalMap);
                        dogMesh.Draw(i);
                    }


                    //RENDERING TO DEVICE

                    //Set original targets
                    device.SetDefaultTargers();

                    if (capture)
                    {
                        target.ToBitmap().Save("Test.jpg");
                        capture = false;
                    }

                    //apply shader
                    renderTargetShader.Apply();

                    Matrix WVP =
                        Matrix.RotationY(Environment.TickCount / 2000.0F) *
                        Matrix.LookAtLH(new Vector3(7, 10, -13), new Vector3(), Vector3.UnitY) *
                        projection;
                    device.UpdateData <RenderTargetData>(renderTargetConstantBuffer, new RenderTargetData()
                    {
                        worldViewProjection = WVP, data = new Vector4(mode, 0, 0, 0)
                    });


                    //clear color
                    device.Clear(Color.Black);

                    renderTargetShader.Apply();

                    //apply constant buffer to shader
                    device.DeviceContext.VertexShader.SetConstantBuffer(0, renderTargetConstantBuffer);
                    device.DeviceContext.PixelShader.SetConstantBuffer(0, renderTargetConstantBuffer);

                    //set target
                    device.DeviceContext.PixelShader.SetShaderResource(0, target.Resource);

                    cubeMesh.Draw();


                    //begin drawing text
                    device.Font.Begin();

                    //draw string
                    fpsCounter.Update();
                    device.Font.DrawString("FPS: " + fpsCounter.FPS, 0, 0);
                    device.Font.DrawString("Press 1 To 4 to change Effect", 0, 30);

                    //flush text to view
                    device.Font.End();
                    //present
                    device.Present();
                });


                //release resource
                dogMesh.Dispose();
                cubeMesh.Dispose();
                phongConstantBuffer.Dispose();
                renderTargetConstantBuffer.Dispose();
                phongShader.Dispose();
                renderTargetShader.Dispose();
            }
        }
Пример #11
0
        protected void  OnPaint(PaintEventArgs e)
        //public override void On  pu l
        {
            PhongData data = new PhongData();
            Graphics  gp   = this.CreateGraphics();

            List <PhongInFo> phongdb = new List <PhongInFo>();
            List <PhongInFo> phongl1 = new List <PhongInFo>();
            List <PhongInFo> phongl2 = new List <PhongInFo>();


            //foreach (DataRow dr in data.LayMaPhong().Rows)
            //{
            //    PhongInFo phong = new PhongInFo();
            //    phong.MaLoaiPhong = (string)dr.ItemArray[1];
            //    phong.MaPhong = (string)dr.ItemArray[0];
            //    phong.TinhTrangPhong = (int)dr.ItemArray[2];

            //    switch (phong.MaLoaiPhong)
            //    {
            //        case "DB": phongdb.Add(phong); break;
            //        case "LI": phongl1.Add(phong); break;
            //        case "LII": phongl2.Add(phong); break;
            //    }
            //}

            //ve
            int x = 10;
            int y = 60;

            for (int i = 0; i < phongdb.Count; i++)
            {
                if (x > 480)
                {
                    y = y + 40;
                    x = 10;
                }
                switch (phongdb[i].TinhTrangPhong)
                {
                case 1:
                {
                    StringFormat s = new StringFormat();
                    s.Alignment     = StringAlignment.Center;
                    s.LineAlignment = StringAlignment.Center;
                    Rectangle r = new Rectangle((x) + 15, y, 50, 30);
                    gp.DrawRectangle(new Pen(Color.White), r);
                    gp.FillRectangle(new SolidBrush(Color.LightSeaGreen), r);
                    gp.DrawString(phongdb[i].MaPhong.ToString(), this.Font, new SolidBrush(Color.White), r, s);
                    break;
                }

                case 2:
                {
                    StringFormat s = new StringFormat();
                    s.Alignment     = StringAlignment.Center;
                    s.LineAlignment = StringAlignment.Center;
                    Rectangle r = new Rectangle((x) + 15, y, 50, 30);
                    gp.DrawRectangle(new Pen(Color.White), r);
                    gp.FillRectangle(new SolidBrush(Color.MediumVioletRed), r);
                    gp.DrawString(phongdb[i].MaPhong.ToString(), this.Font, new SolidBrush(Color.White), r, s);
                    break;
                }

                case 3:
                {
                    StringFormat s = new StringFormat();
                    s.Alignment     = StringAlignment.Center;
                    s.LineAlignment = StringAlignment.Center;
                    Rectangle r = new Rectangle((x) + 15, y, 50, 30);
                    gp.DrawRectangle(new Pen(Color.White), r);
                    gp.FillRectangle(new SolidBrush(Color.Red), r);
                    gp.DrawString(phongdb[i].MaPhong.ToString(), this.Font, new SolidBrush(Color.White), r, s);
                    break;
                }
                }
                x = x + 70;
            }
            x = 10;
            y = y + 50;
            gp.DrawLine(new Pen(Color.Black, 3), new Point(25, y - 10), new Point(x + 485, y - 10));
            for (int i = 0; i < phongl1.Count; i++)
            {
                if (x > 480)
                {
                    y = y + 40;
                    x = 10;
                }
                switch (phongl1[i].TinhTrangPhong)
                {
                case 1:
                {
                    StringFormat s = new StringFormat();
                    s.Alignment     = StringAlignment.Center;
                    s.LineAlignment = StringAlignment.Center;
                    Rectangle r = new Rectangle((x) + 15, y, 50, 30);
                    gp.DrawRectangle(new Pen(Color.White), r);
                    gp.FillRectangle(new SolidBrush(Color.LightSeaGreen), r);
                    gp.DrawString(phongl1[i].MaPhong.ToString(), this.Font, new SolidBrush(Color.White), r, s);
                    break;
                }

                case 2:
                {
                    StringFormat s = new StringFormat();
                    s.Alignment     = StringAlignment.Center;
                    s.LineAlignment = StringAlignment.Center;
                    Rectangle r = new Rectangle((x) + 15, y, 50, 30);
                    gp.DrawRectangle(new Pen(Color.White), r);
                    gp.FillRectangle(new SolidBrush(Color.MediumVioletRed), r);
                    gp.DrawString(phongl1[i].MaPhong.ToString(), this.Font, new SolidBrush(Color.White), r, s);
                    break;
                }

                case 3:
                {
                    StringFormat s = new StringFormat();
                    s.Alignment     = StringAlignment.Center;
                    s.LineAlignment = StringAlignment.Center;
                    Rectangle r = new Rectangle((x) + 15, y, 50, 30);
                    gp.DrawRectangle(new Pen(Color.White), r);
                    gp.FillRectangle(new SolidBrush(Color.Red), r);
                    gp.DrawString(phongl1[i].MaPhong.ToString(), this.Font, new SolidBrush(Color.White), r, s);
                    break;
                }
                }
                x = x + 70;
            }

            x = 10;
            y = y + 50;
            gp.DrawLine(new Pen(Color.Black, 3), new Point(25, y - 10), new Point(x + 485, y - 10));
            for (int i = 0; i < phongl2.Count; i++)
            {
                if (x > 480)
                {
                    x  = 10;
                    y += 40;
                }
                switch (phongl2[i].TinhTrangPhong)
                {
                case 1:
                {
                    StringFormat s = new StringFormat();
                    s.Alignment     = StringAlignment.Center;
                    s.LineAlignment = StringAlignment.Center;
                    Rectangle r = new Rectangle((x) + 15, y, 50, 30);
                    gp.DrawRectangle(new Pen(Color.White), r);
                    gp.FillRectangle(new SolidBrush(Color.LightSeaGreen), r);
                    gp.DrawString(phongl2[i].MaPhong.ToString(), this.Font, new SolidBrush(Color.White), r, s);
                    break;
                }

                case 2:
                {
                    StringFormat s = new StringFormat();
                    s.Alignment     = StringAlignment.Center;
                    s.LineAlignment = StringAlignment.Center;
                    Rectangle r = new Rectangle((x) + 15, y, 50, 30);
                    gp.DrawRectangle(new Pen(Color.White), r);
                    gp.FillRectangle(new SolidBrush(Color.MediumVioletRed), r);
                    gp.DrawString(phongl2[i].MaPhong.ToString(), this.Font, new SolidBrush(Color.White), r, s);
                    break;
                }

                case 3:
                {
                    StringFormat s = new StringFormat();
                    s.Alignment     = StringAlignment.Center;
                    s.LineAlignment = StringAlignment.Center;
                    Rectangle r = new Rectangle((x) + 15, y, 50, 30);
                    gp.DrawRectangle(new Pen(Color.White), r);
                    gp.FillRectangle(new SolidBrush(Color.Red), r);
                    gp.DrawString(phongl2[i].MaPhong.ToString(), this.Font, new SolidBrush(Color.White), r, s);
                    break;
                }
                }
                x += 70;
            }
            gp.Dispose();
        }
        public bool Sua(PhongInfo phong)
        {
            PhongData data = new PhongData();

            return(data.Sua(phong));
        }
        public bool Them(PhongInfo phong)
        {
            PhongData data = new PhongData();

            return(data.Them(phong));
        }