Ejemplo n.º 1
0
        public void LoadData()
        {
            listPhong = TSCD.Entities.Phong.getAll();
            if (listPhong.Count > 0)
            {
                infotr.Visible = true;
                listViTriHienThi = ViTriHienThi.getAll();
                if (listViTriHienThi.Count > 0)
                {
                    _ucTreeViTri.CreateTreeList();
                    _ucTreeViTri.ASPxTreeList_ViTri.DataSource = listViTriHienThi;
                    _ucTreeViTri.ASPxTreeList_ViTri.DataBind();
                    SearchFunction();
                    if (Convert.ToString(Page.Session["ShowInfo"]) == "1")
                    {
                        PanelChangePage.Visible = false;
                        Session["ShowInfo"] = null;
                    }
                    else
                    {
                        _ucCollectionPager_DanhSachPhong.ShowPanelPage(PanelChangePage);
                    }
                    if (Request.QueryString["key"] != null)
                    {
                        infotd.Visible = true;
                        string key = "";
                        try
                        {
                            key = Request.QueryString["key"].ToString();
                        }
                        catch
                        {
                            Response.Redirect(Request.Url.AbsolutePath);
                        }

                        DevExpress.Web.ASPxTreeList.TreeListNode node = _ucTreeViTri.ASPxTreeList_ViTri.FindNodeByKeyValue(key);
                        if (node != null)
                        {
                            _ucTreeViTri.FocusAndExpandToNode(node);
                            LoadFocusedNodeData();
                        }
                        else
                            Response.Redirect(Request.Url.AbsolutePath);
                        if (Request.QueryString["id"] != null)
                        {
                            ThongTinPhong.Visible = true;
                            thongtin.Visible = true;
                            idPhong = Guid.Empty;
                            try
                            {
                                idPhong = GUID.From(Request.QueryString["id"]);
                            }
                            catch
                            {
                                Response.Redirect(Request.Url.AbsolutePath);
                            }

                            objPhong = TSCD.Entities.Phong.getById(idPhong);
                            if (objPhong != null)
                            {
                                Label_ThongTinPhong.Text = "Thông tin phòng " + objPhong.ten;
                                Label_MaPhong.Text = objPhong.subId;
                                ucPhong_BreadCrumb.Label_TenPhong.Text = Label_TenPhong.Text = objPhong.ten;
                                Label_LoaiPhong.Text = objPhong.loaiphong.ten;
                                Label_ViTriPhong.Text = ViTriCuaPhong(objPhong);
                                Label_MoTaPhong.Text = StringHelper.ConvertRNToBR(objPhong.mota);
                            }
                            else
                            {
                                Response.Redirect(Request.Url.AbsolutePath);
                            }
                        }
                        else
                        {
                            ClearData();
                        }
                    }
                    else
                    {
                        DevExpress.Web.ASPxTreeList.TreeListNode node = _ucTreeViTri.ASPxTreeList_ViTri.FindNodeByKeyValue("");
                        node.Focus();
                        ChuaChonViTri.Visible = true;
                        ucWarning_ChuaChonViTri.LabelInfo.Text = "Chưa chọn vị trí";
                        ClearData();
                    }
                }
                else
                {
                    KhongCoDuLieu.Visible = true;
                    ucDanger_KhongCoDuLieu.LabelInfo.Text = "Chưa có phòng";
                }
            }
            else
            {
                KhongCoDuLieu.Visible = true;
                ucDanger_KhongCoDuLieu.LabelInfo.Text = "Chưa có phòng";
            }
        }
 public void LoadData()
 {
     listPhong = TSCD.Entities.Phong.getAll();
     if (listPhong.Count > 0)
     {
         TreeViTri.Visible = true;
         listViTriHienThi = ViTriHienThi.getAll();
         if (listViTriHienThi.Count > 0)
         {
             ucTreeViTri.CreateTreeList();
             ucTreeViTri.ASPxTreeList_ViTri.DataSource = listViTriHienThi;
             ucTreeViTri.ASPxTreeList_ViTri.DataBind();
             SearchFunction();
             if (Request.QueryString["key"] != null)
             {
                 DanhSach.Visible = true;
                 TreeViTri.Visible = false;
                 key = "";
                 try
                 {
                     key = Request.QueryString["key"].ToString();
                 }
                 catch
                 {
                     Response.Redirect(Request.Url.AbsolutePath);
                 }
                 DevExpress.Web.ASPxTreeList.TreeListNode node = ucTreeViTri.ASPxTreeList_ViTri.FindNodeByKeyValue(key);
                 if (node != null)
                 {
                     string strViTri = "";
                     DevExpress.Web.ASPxTreeList.TreeListNode Pnode = node.ParentNode;
                     while (!Object.Equals(Pnode.Key, ""))
                     {
                         strViTri = " - " + Pnode.GetValue("ten").ToString() + strViTri;
                         Pnode = Pnode.ParentNode;
                     }
                     if (!Object.Equals(strViTri, ""))
                     {
                         strViTri = string.Format("({0})", strViTri.Substring(3));
                         ucPhong_BreadCrumb.Label_TenViTri.Text = node.GetValue("ten").ToString() + " " + strViTri;
                     }
                     else
                         ucPhong_BreadCrumb.Label_TenViTri.Text = node.GetValue("ten").ToString();
                     if (Request.QueryString["id"] != null)
                     {
                         ThongTin.Visible = true;
                         idPhong = Guid.Empty;
                         try
                         {
                             idPhong = GUID.From(Request.QueryString["id"]);
                         }
                         catch
                         {
                             Response.Redirect(Request.Url.AbsolutePath);
                         }
                         objPhong = TSCD.Entities.Phong.getById(idPhong);
                         if (objPhong != null)
                         {
                             ucPhong_BreadCrumb.Label_TenPhong.Text = objPhong.ten;
                             Label_MaPhong.Text = objPhong.subId;
                             Label_TenPhong.Text = objPhong.ten;
                             Label_LoaiPhong.Text = objPhong.loaiphong.ten;
                             Label_ViTriPhong.Text = ViTriCuaPhong(objPhong);
                             Label_MoTaPhong.Text = StringHelper.ConvertRNToBR(objPhong.mota);
                         }
                         else
                         {
                             Response.Redirect(Request.Url.AbsolutePath);
                         }
                     }
                     LoadDanhSachPhong(GUID.From(node.GetValue("id")), node.GetValue("loai").ToString());
                 }
                 else
                     Response.Redirect(Request.Url.AbsolutePath);
             }
             else
             {
                 DevExpress.Web.ASPxTreeList.TreeListNode node = ucTreeViTri.ASPxTreeList_ViTri.FindNodeByKeyValue("");
                 node.Focus();
             }
         }
         else
         {
             KhongCoDuLieu.Visible = true;
             ucDanger_KhongCoDuLieu.LabelInfo.Text = "Chưa có phòng";
         }
     }
     else
     {
         KhongCoDuLieu.Visible = true;
         ucDanger_KhongCoDuLieu.LabelInfo.Text = "Chưa có phòng";
     }
 }