private void UserControl1_Click(object sender, EventArgs e)
 {
     //lay so luong phong
     dataPhong_LinQDataContext data_phongtro = new dataPhong_LinQDataContext();
     var phong = (from p in data_phongtro.PHONGTROs select p).Count();
     int slphong = phong;
     taoControldong(slphong);  
 }
 public UserControl1()
 {
     InitializeComponent();
     //lay so luong phong
     dataPhong_LinQDataContext data_phongtro = new dataPhong_LinQDataContext();
     var phong = (from p in data_phongtro.PHONGTROs select p).Count();
     int slphong = phong;
     taoControldong(slphong);  
 }
        private void button1_Click(object sender, EventArgs e)
        {
            dataPhong_LinQDataContext dataphong = new dataPhong_LinQDataContext();
            var so_phong = (from p in dataphong.PHONGTROs where p.MaPT == maPTTextEdit.Text select p).Count();

            if (so_phong != 0)
            {
                MessageBox.Show("Đã tồn tại mã phòng !!!");
            }
            else
            {
                this.tableAdapterManager.PHONGTROTableAdapter.Insert(maPTTextEdit.Text, kHUVUCComboBox.SelectedValue.ToString().Trim(), bangGiaTien_DKComboBox.SelectedValue.ToString().Trim(), tenPhongTextEdit.Text, int.Parse(sLToiDaSpinEdit.Text), true, false, 0);
                this.pHONGTROTableAdapter.Fill(this.dataSet_phong.PHONGTRO);
                MessageBox.Show("Thêm Thành Công!!!");
            }
        }
 public string kt_trangthaithue(int sophong)
 {
     dataPhong_LinQDataContext dataphong = new dataPhong_LinQDataContext();
     if (sophong <= 9)
     {
         var tt_phong = from p in dataphong.PHONGTROs where p.MaPT == "PT00" + sophong select new { p.TrangThaiThue };
         foreach (var TT in tt_phong)
         {
             string x = TT.TrangThaiThue.ToString();
             return x;
         }
         return "";
     }
     else
     {
         var tt_phong = from p in dataphong.PHONGTROs where p.MaPT == "PT0" + sophong select new { p.TrangThaiThue };
         foreach (var TT in tt_phong)
         {
             string x = TT.TrangThaiThue.ToString();
             return x;
         }
         return "";
     }
 }