Exemplo n.º 1
0
        private void Load_control()
        {
            try
            {
                int x   = 0;
                int y   = 0;
                int dem = 0;

                foreach (DataRow row in ds.Tables["PHONG"].Rows)
                {
                    if (conn.cnn.State == ConnectionState.Closed)
                    {
                        conn.cnn.Open();
                    }
                    if (int.Parse(row["TINHTRANG"].ToString()) == 0)
                    {
                        frm_phongtrong phongtrong = new frm_phongtrong(this, conn);
                        phongtrong.get_sophong(row["MAPH"].ToString());
                        phongtrong.Location = new Point(x, y);
                        panelphong.Controls.Add(phongtrong);
                        x += 280;
                        if (dem >= 5)
                        {
                            y  += 250;
                            x   = 0;
                            dem = 0;
                        }
                        else
                        {
                            dem++;
                        }
                    }
                    if (int.Parse(row["TINHTRANG"].ToString()) == 1)
                    {
                        frm_phongsudung sudung = new frm_phongsudung(this, conn);
                        sudung.get_sophong(row["MAPH"].ToString());
                        sudung.Location = new Point(x, y);
                        panelphong.Controls.Add(sudung);
                        x += 280;
                        if (dem >= 5)
                        {
                            y  += 250;
                            x   = 0;
                            dem = 0;
                        }
                        else
                        {
                            dem++;
                        }
                    }
                    if (int.Parse(row["TINHTRANG"].ToString()) == 2)
                    {
                        frm_phongdattruoc dattruoc = new frm_phongdattruoc(this, conn);
                        dattruoc.get_sophong(row["MAPH"].ToString());
                        dattruoc.Location = new Point(x, y);
                        panelphong.Controls.Add(dattruoc);
                        x += 280;
                        if (dem >= 5)
                        {
                            y  += 250;
                            x   = 0;
                            dem = 0;
                        }
                        else
                        {
                            dem++;
                        }
                    }
                    if (int.Parse(row["TINHTRANG"].ToString()) == 3)
                    {
                        frm_phongdondep dondep = new frm_phongdondep(this, conn);
                        dondep.get_sophong(row["MAPH"].ToString());
                        dondep.Location = new Point(x, y);
                        panelphong.Controls.Add(dondep);
                        x += 280;
                        if (dem >= 5)
                        {
                            y  += 250;
                            x   = 0;
                            dem = 0;
                        }
                        else
                        {
                            dem++;
                        }
                    }
                    if (int.Parse(row["TINHTRANG"].ToString()) == 4)
                    {
                        frm_phongsuachua suachua = new frm_phongsuachua(this, conn);
                        suachua.get_sophong(row["MAPH"].ToString());
                        suachua.Location = new Point(x, y);
                        panelphong.Controls.Add(suachua);
                        x += 280;
                        if (dem >= 5)
                        {
                            y  += 250;
                            x   = 0;
                            dem = 0;
                        }
                        else
                        {
                            dem++;
                        }
                    }
                    conn.cnn.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                conn.cnn.Close();
            }
        }
Exemplo n.º 2
0
        private void Load_control()
        {
            int x   = 0;
            int y   = 0;
            int dem = 0;

            foreach (DataRow row in ds.Tables["PHONG"].Rows)
            {
                if (int.Parse(row["TINHTRANG"].ToString()) == 0)
                {
                    frm_phongtrong phongtrong = new frm_phongtrong(row["MAPH"].ToString(), panelphong);
                    phongtrong.Location = new Point(x, y);
                    panelphong.Controls.Add(phongtrong);
                    x += 280;
                    if (dem >= 5)
                    {
                        y  += 250;
                        x   = 0;
                        dem = 0;
                    }
                    else
                    {
                        dem++;
                    }
                }
                if (int.Parse(row["TINHTRANG"].ToString()) == 1)
                {
                    frm_phongsudung sudung = new frm_phongsudung(row["MAPH"].ToString(), panelphong);
                    sudung.Location = new Point(x, y);
                    panelphong.Controls.Add(sudung);
                    x += 280;
                    if (dem >= 5)
                    {
                        y  += 250;
                        x   = 0;
                        dem = 0;
                    }
                    else
                    {
                        dem++;
                    }
                }
                if (int.Parse(row["TINHTRANG"].ToString()) == 2)
                {
                    frm_phongdattruoc dattruoc = new frm_phongdattruoc(row["MAPH"].ToString());
                    dattruoc.Location = new Point(x, y);
                    panelphong.Controls.Add(dattruoc);
                    x += 280;
                    if (dem >= 5)
                    {
                        y  += 250;
                        x   = 0;
                        dem = 0;
                    }
                    else
                    {
                        dem++;
                    }
                }
                if (int.Parse(row["TINHTRANG"].ToString()) == 3)
                {
                    frm_phongdondep dondep = new frm_phongdondep(row["MAPH"].ToString(), this);
                    dondep.Location = new Point(x, y);
                    panelphong.Controls.Add(dondep);
                    x += 280;
                    if (dem >= 5)
                    {
                        y  += 250;
                        x   = 0;
                        dem = 0;
                    }
                    else
                    {
                        dem++;
                    }
                }
                if (int.Parse(row["TINHTRANG"].ToString()) == 4)
                {
                    frm_phongsuachua suachua = new frm_phongsuachua(row["MAPH"].ToString(), this);
                    suachua.Location = new Point(x, y);
                    panelphong.Controls.Add(suachua);
                    x += 280;
                    if (dem >= 5)
                    {
                        y  += 250;
                        x   = 0;
                        dem = 0;
                    }
                    else
                    {
                        dem++;
                    }
                }
            }
        }