Esempio n. 1
0
        private int SearchPage(Guid GuidPhong, Guid GuidSuCoPhong)
        {
            int Page = -1;

            objPhong      = PTB.Entities.Phong.getById(GuidPhong);
            listSuCoPhong = objPhong.sucophongs.ToList();
            int index = listSuCoPhong.IndexOf(listSuCoPhong.Where(item => Object.Equals(item.id, GuidSuCoPhong)).FirstOrDefault());

            if (index != -1)
            {
                Page = index / _ucCollectionPager_DanhSachSuCo.CollectionPager_Object.PageSize + 1;
            }
            return(Page);
        }
Esempio n. 2
0
 private void SearchFunction()
 {
     if (Request.QueryString["Search"] != null)
     {
         Guid SearchID = Guid.Empty;
         try
         {
             SearchID     = GUID.From(Request.QueryString["Search"]);
             objSuCoPhong = PTB.Entities.SuCoPhong.getById(SearchID);
         }
         catch
         {
             Response.Redirect(Request.Url.AbsolutePath);
         }
         PTB.Entities.Phong PhongSearch = objSuCoPhong.phong;
         if (PhongSearch != null)
         {
             Guid nodeGuid = PhongSearch.id;
             DevExpress.Web.ASPxTreeList.TreeListNode node = _ucTreeViTri.ASPxTreeList_ViTri.GetAllNodes().Where(item => Object.Equals(item.GetValue("id").ToString(), nodeGuid.ToString())).FirstOrDefault();
             if (node != null)
             {
                 int Page = SearchPage(nodeGuid, SearchID);
                 if (Page != -1)
                 {
                     Session["ShowInfo"] = "1";
                     Response.Redirect(string.Format("{0}?key={1}&id={2}&Page={3}", Request.Url.AbsolutePath, node.Key.ToString(), SearchID.ToString(), Page.ToString()));
                 }
                 else
                 {
                     Response.Redirect(Request.Url.AbsolutePath);
                 }
             }
             else
             {
                 Response.Redirect(Request.Url.AbsolutePath);
             }
         }
         else
         {
             Response.Redirect(Request.Url.AbsolutePath);
         }
     }
     else
     {
         return;
     }
 }
Esempio n. 3
0
        public override int delete()
        {
            try
            {
                //trước khi delete phải ghi log
                Phong backup = Phong.getById(phong.id);
                this.phong = null;

                writelog();

                this.phong = backup;
                return(base.delete());
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(-1);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Tìm kiếm thiết bị với 3 yếu tố
        /// </summary>
        /// <param name="ph"></param>
        /// <param name="tb"></param>
        /// <param name="tr"></param>
        /// <returns></returns>
        public static CTThietBi search(Phong ph, ThietBi tb, TinhTrang tr)
        {
            try
            {
                IQueryable <CTThietBi> query = db.CTTHIETBIS.AsQueryable();
                if (ph == null)
                {
                    query = query.Where(c => c.phong_id == null);
                }
                else
                {
                    query = query.Where(c => c.phong_id == ph.id);
                }
                query = query.Where(c => c.thietbi_id == tb.id && c.tinhtrang_id == tr.id);

                return(query.FirstOrDefault());
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(null);
            }
        }
Esempio n. 5
0
        //protected void ButtonBack_ThongTinPhong_Click(object sender, EventArgs e)
        //{
        //    if (!key.Equals(""))
        //        Response.Redirect(Libraries.StringHelper.AddParameter(new Uri(Request.Url.AbsoluteUri), "key", key, new List<string>(new string[] { "id" })).ToString());
        //    else
        //        Response.Redirect(Request.Url.AbsolutePath);
        //}

        //protected void ButtonBack_DanhSachPhong_Click(object sender, EventArgs e)
        //{
        //    Response.Redirect(Request.Url.AbsolutePath);
        //}

        private void SearchFunction()
        {
            if (Request.QueryString["Search"] != null)
            {
                Guid SearchID = Guid.Empty;
                try
                {
                    SearchID = GUID.From(Request.QueryString["Search"]);
                }
                catch
                {
                    Response.Redirect(Request.Url.AbsolutePath);
                }
                PTB.Entities.Phong PhongSearch = listPhong.Where(item => Object.Equals(item.id, SearchID)).FirstOrDefault();
                if (PhongSearch != null)
                {
                    Guid nodeGuid = Guid.Empty;
                    int  type     = 0;
                    if (PhongSearch.vitri != null)
                    {
                        if (PhongSearch.vitri.tang != null)
                        {
                            nodeGuid = PhongSearch.vitri.tang.id;
                            type     = 3;
                        }
                        else if (PhongSearch.vitri.day != null)
                        {
                            nodeGuid = PhongSearch.vitri.day.id;
                            type     = 2;
                        }
                        else if (PhongSearch.vitri.coso != null)
                        {
                            nodeGuid = PhongSearch.vitri.coso.id;
                            type     = 1;
                        }
                        else
                        {
                            Response.Redirect(Request.Url.AbsolutePath);
                        }
                    }
                    else
                    {
                        Response.Redirect(Request.Url.AbsolutePath);
                    }
                    DevExpress.Web.ASPxTreeList.TreeListNode node = _ucTreeViTri.ASPxTreeList_ViTri.GetAllNodes().Where(item => Object.Equals(item.GetValue("id").ToString(), nodeGuid.ToString())).FirstOrDefault();
                    if (node != null)
                    {
                        int Page = SearchPage(nodeGuid, PhongSearch.id, type);
                        if (Page != -1)
                        {
                            Response.Redirect(string.Format("{0}?key={1}&id={2}&Page={3}", Request.Url.AbsolutePath, node.Key.ToString(), PhongSearch.id.ToString(), Page.ToString()));
                        }
                        else
                        {
                            Response.Redirect(Request.Url.AbsolutePath);
                        }
                    }
                    else
                    {
                        Response.Redirect(Request.Url.AbsolutePath);
                    }
                }
                else
                {
                    Response.Redirect(Request.Url.AbsolutePath);
                }
            }
            else
            {
                return;
            }
        }
        public void LoadData()
        {
            listViTriHienThi = ViTriHienThi.getAllHavePhong();
            if (listViTriHienThi.Count > 0)
            {
                if (listViTriHienThi.Where(item => Object.Equals(item.loai, typeof(PTB.Entities.Phong).Name)).FirstOrDefault() != null)
                {
                    _ucTreeViTri.CreateTreeList();
                    _ucTreeViTri.ASPxTreeList_ViTri.DataSource = listViTriHienThi;
                    _ucTreeViTri.ASPxTreeList_ViTri.DataBind();
                    if (Request.QueryString["key"] != null)
                    {
                        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;
                            }
                            strViTri = string.Format("({0})", strViTri.Substring(3));
                            ucPhongThietBi_BreadCrumb.Label_TenPhong.Text = node.GetValue("ten").ToString() + " " + strViTri;
                            objPhong = PTB.Entities.Phong.getById(GUID.From(node.GetValue("id")));
                            if (objPhong != null)
                            {
                                if (Request.QueryString["id"] != null)
                                {
                                    idThietBi = Guid.Empty;
                                    try
                                    {
                                        idThietBi = GUID.From(Request.QueryString["id"]);
                                    }
                                    catch
                                    {
                                        Response.Redirect(Request.Url.AbsolutePath);
                                    }
                                    objThietBi = PTB.Entities.ThietBi.getById(idThietBi);
                                    if (objThietBi != null)
                                    {
                                        Label_ThongTinThietBi.Text = string.Format("Thông tin {0}", objThietBi.ten);
                                        Panel_ThietBi.Visible = true;
                                        Libraries.ImageHelper.LoadImageWeb(objThietBi.hinhanhs.ToList(), _ucASPxImageSlider_Mobile.ASPxImageSlider_Object);
                                        Label_MaThietBi.Text = objThietBi.subId;
                                        ucPhongThietBi_BreadCrumb.Label_TenThietBi.Text = Label_TenThietBi.Text = objThietBi.ten;
                                        if (objThietBi.loaithietbi != null)
                                        {
                                            Label_LoaiThietBi.Text = objThietBi.loaithietbi.ten;
                                            if (objThietBi.loaithietbi.loaichung)
                                            {
                                                Panel_NgayMua.Visible = false;
                                                Label_NgayMua.Text = "";
                                                Label_KieuQuanLy.Text = "Theo số lượng";
                                            }
                                            else
                                            {
                                                Panel_NgayMua.Visible = true;
                                                Label_NgayMua.Text = objThietBi.ngaymua.ToString();
                                                Label_KieuQuanLy.Text = "Theo cá thể";
                                            }
                                        }
                                        else
                                        {
                                            Label_LoaiThietBi.Text = "[Loại thiết bị]";
                                            Panel_NgayMua.Visible = false;
                                            Label_NgayMua.Text = "";
                                            Label_KieuQuanLy.Text = "Chưa rõ";
                                        }
                                        Label_Phong.Text = objPhong.ten;
                                        Label_NgayLap.Text = objThietBi.ctthietbis != null ? objThietBi.ctthietbis.Where(item => item.phong_id == objPhong.id).FirstOrDefault().ngay.ToString() : "";
                                        Label_MoTa.Text = Libraries.StringHelper.ConvertRNToBR(objThietBi.mota);
                                        Button_XemLog.OnClientClick = string.Format("location.href='{0}'; return false;", Libraries.StringHelper.AddParameter(new Uri("http://" + Request.Url.Authority + "/" + ResolveClientUrl("~/LogThietBi.aspx")), new List<string>(new string[] { "id", "idp" }), new List<string>(new string[] { idThietBi.ToString(), objPhong.id.ToString() })));
                                    }
                                    else
                                    {
                                        Response.Redirect(Request.Url.AbsolutePath);
                                    }
                                }
                                else
                                {
                                    LoadDataObjPhong();
                                    Panel_DanhSachThietBi.Visible = true;
                                }
                            }
                            else
                            {
                                Response.Redirect(Request.Url.AbsolutePath);
                            }
                        }
                        else
                        {
                            Response.Redirect(Request.Url.AbsolutePath);
                        }
                    }
                    else
                    {
                        Panel_TreeListViTri.Visible = true;
                    }
                }
                else
                {
                    ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
                    ucThongBaoLoi.Label_ThongBaoLoi.Text = "Chưa có phòng";
                }
            }
            else
            {
                ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
                ucThongBaoLoi.Label_ThongBaoLoi.Text = "Chưa có vị trí";
            }
        }
Esempio n. 7
0
 public void LoadData()
 {
     listViTriHienThi = ViTriHienThi.getAllHavePhong();
     if (listViTriHienThi.Count > 0)
     {
         if (listViTriHienThi.Where(item => Object.Equals(item.loai, typeof(PTB.Entities.Phong).Name)).FirstOrDefault() != null)
         {
             Panel_Chinh.Visible = true;
             _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_DanhSachSuCo.ShowPanelPage(PanelChangePage);
             }
             if (Request.QueryString["key"] != null)
             {
                 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);
                     objPhong = PTB.Entities.Phong.getById(GUID.From(node.GetValue("id")));
                     if (objPhong != null)
                     {
                         LoadDataObjPhong();
                         if (Request.QueryString["id"] != null)
                         {
                             idSuCo = Guid.Empty;
                             try
                             {
                                 idSuCo = GUID.From(Request.QueryString["id"]);
                             }
                             catch
                             {
                                 Response.Redirect(Request.Url.AbsolutePath);
                             }
                             objSuCoPhong = PTB.Entities.SuCoPhong.getById(idSuCo);
                             if (objSuCoPhong != null)
                             {
                                 Panel_SuCo.Visible      = true;
                                 Label_SuCo.Visible      = false;
                                 Label_SuCo.Text         = "";
                                 Label_ThongTinSuCo.Text = "Thông tin " + objSuCoPhong.ten;
                                 Libraries.ImageHelper.LoadImageWeb(objSuCoPhong.hinhanhs.ToList(), _ucASPxImageSlider_Web.ASPxImageSlider_Object);
                                 _ucASPxImageSlider_Web.urlHinhAnh = string.Format("http://{0}/HinhAnh.aspx?id={1}&type=SUCOPHONG", HttpContext.Current.Request.Url.Authority, objSuCoPhong.id);
                                 Session["TenSuCo"]          = Label_TenSuCo.Text = objSuCoPhong.ten;
                                 Label_TinhTrang.Text        = objSuCoPhong.tinhtrang != null ? objSuCoPhong.tinhtrang.value : "[Tình trạng]";
                                 Label_NgayTao.Text          = ((DateTime)objSuCoPhong.date_create).ToString();
                                 Label_MoTa.Text             = Libraries.StringHelper.ConvertRNToBR(objSuCoPhong.mota);
                                 Button_XemLog.OnClientClick = string.Format("OnMoreInfoClick('{0}'); return false;", Libraries.StringHelper.AddParameter(new Uri("http://" + Request.Url.Authority + "/" + ResolveClientUrl("~/LogSuCo.aspx")), "id", idSuCo.ToString()));
                             }
                             else
                             {
                                 Response.Redirect(Request.Url.AbsolutePath);
                             }
                         }
                         else
                         {
                             Panel_SuCo.Visible = false;
                             Label_SuCo.Visible = true;
                             Label_SuCo.Text    = "Chưa chọn sự cố";
                         }
                     }
                     else
                     {
                         Response.Redirect(Request.Url.AbsolutePath);
                     }
                 }
                 else
                 {
                     Response.Redirect(Request.Url.AbsolutePath);
                 }
             }
             else
             {
                 DevExpress.Web.ASPxTreeList.TreeListNode node = _ucTreeViTri.ASPxTreeList_ViTri.FindNodeByKeyValue("");
                 node.Focus();
                 Label_DanhSachSuCo.Text = "Chưa chọn phòng";
                 ClearData();
             }
         }
         else
         {
             ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
             ucThongBaoLoi.Label_ThongBaoLoi.Text    = "Chưa có phòng";
         }
     }
     else
     {
         ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
         ucThongBaoLoi.Label_ThongBaoLoi.Text    = "Chưa có sự cố";
     }
 }
        public void LoadData()
        {
            listPhong = PTB.Entities.Phong.getAll();
            if (listPhong.Count > 0)
            {
                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);
                    }
                    Panel_Chinh.Visible = true;
                    if (Request.QueryString["key"] != null)
                    {
                        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)
                        {
                            idPhong = Guid.Empty;
                            try
                            {
                                idPhong = GUID.From(Request.QueryString["id"]);
                            }
                            catch
                            {
                                Response.Redirect(Request.Url.AbsolutePath);
                            }

                            objPhong = PTB.Entities.Phong.getById(idPhong);
                            if (objPhong != null)
                            {
                                Panel_Phong.Visible      = true;
                                Label_Phong.Visible      = false;
                                Label_ThongTinPhong.Text = "Thông tin " + objPhong.ten;
                                Libraries.ImageHelper.LoadImageWeb(objPhong.hinhanhs.ToList(), _ucASPxImageSlider_Web_Phong.ASPxImageSlider_Object);
                                _ucASPxImageSlider_Web_Phong.urlHinhAnh = string.Format("http://{0}/HinhAnh.aspx?id={1}&type=PHONG", HttpContext.Current.Request.Url.Authority, objPhong.id);
                                Label_MaPhong.Text = objPhong.subId;
                                ucPhong_BreadCrumb.Label_TenPhong.Text = Label_TenPhong.Text = objPhong.ten;
                                string strCoSo, strDay, strTang;
                                strCoSo = objPhong.vitri.coso != null ? objPhong.vitri.coso.ten : "";
                                strDay  = objPhong.vitri.day != null ? objPhong.vitri.day.ten : "";
                                strTang = objPhong.vitri.tang != null ? objPhong.vitri.tang.ten : "";
                                if (!strCoSo.Equals(""))
                                {
                                    Label_ViTriPhong.Text += strCoSo;
                                    if (!strDay.Equals(""))
                                    {
                                        Label_ViTriPhong.Text += " - " + strDay;
                                        if (!strTang.Equals(""))
                                        {
                                            Label_ViTriPhong.Text += " - " + strTang;
                                        }
                                    }
                                }
                                else
                                {
                                    Label_ViTriPhong.Text = "[Không rõ]";
                                }
                                Label_MoTaPhong.Text        = Libraries.StringHelper.ConvertRNToBR(objPhong.mota);
                                Label_NhanVienPhuTrach.Text = objPhong.nhanvienpt != null ? objPhong.nhanvienpt.hoten : "";

                                if (objPhong.nhanvienpt != null)
                                {
                                    Panel_NhanVienPT.Visible = true;
                                    Label_NhanVienPT.Visible = false;
                                    Label_NhanVienPT.Text    = "";
                                    Libraries.ImageHelper.LoadImageWeb(objPhong.nhanvienpt.hinhanhs.ToList(), _ucASPxImageSlider_Web_NhanVienPT.ASPxImageSlider_Object);
                                    _ucASPxImageSlider_Web_NhanVienPT.urlHinhAnh = string.Format("http://{0}/HinhAnh.aspx?id={1}&type=NHANVIEN", HttpContext.Current.Request.Url.Authority, objPhong.nhanvienpt_id);
                                    Label_MaNhanVien.Text  = objPhong.nhanvienpt.subId;
                                    Label_HoTen.Text       = objPhong.nhanvienpt.hoten;
                                    Label_SoDienThoai.Text = objPhong.nhanvienpt.sodienthoai;
                                }
                                else
                                {
                                    Panel_NhanVienPT.Visible = false;
                                    Label_NhanVienPT.Visible = true;
                                    Label_NhanVienPT.Text    = "Phòng này chưa có nhân viên phụ trách";
                                    Libraries.ImageHelper.LoadImageWeb(null, _ucASPxImageSlider_Web_NhanVienPT.ASPxImageSlider_Object);
                                    Label_MaNhanVien.Text  = "";
                                    Label_HoTen.Text       = "";
                                    Label_SoDienThoai.Text = "";
                                }
                            }
                            else
                            {
                                Response.Redirect(Request.Url.AbsolutePath);
                            }
                        }
                        else
                        {
                            ClearData();
                            Label_Phong.Visible = true;
                            Label_Phong.Text    = "Chưa chọn phòng";
                        }
                    }
                    else
                    {
                        DevExpress.Web.ASPxTreeList.TreeListNode node = _ucTreeViTri.ASPxTreeList_ViTri.FindNodeByKeyValue("");
                        node.Focus();
                        Label_TextDanhSachPhong.Text = "Chưa chọn vị trí";
                        ClearData();
                        Label_Phong.Visible = true;
                        Label_Phong.Text    = "Chưa chọn phòng";
                    }
                }
                else
                {
                    ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
                    ucThongBaoLoi.Label_ThongBaoLoi.Text    = "Chưa có phòng";
                }
            }
            else
            {
                ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
                ucThongBaoLoi.Label_ThongBaoLoi.Text    = "Chưa có phòng";
            }
        }
        public void LoadData()
        {
            listViTriHienThi = ViTriHienThi.getAllHavePhong();
            if (listViTriHienThi.Count > 0)
            {
                if (listViTriHienThi.Where(item => Object.Equals(item.loai, typeof(PTB.Entities.Phong).Name)).FirstOrDefault() != null)
                {
                    Panel_Chinh.Visible = true;
                    _ucTreeViTri.CreateTreeList();
                    _ucTreeViTri.ASPxTreeList_ViTri.DataSource = listViTriHienThi;
                    _ucTreeViTri.ASPxTreeList_ViTri.DataBind();
                    if (Request.QueryString["key"] != null)
                    {
                        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);
                            objPhong = PTB.Entities.Phong.getById(GUID.From(node.GetValue("id")));
                            if (objPhong != null)
                            {
                                string strViTri = "";
                                DevExpress.Web.ASPxTreeList.TreeListNode Pnode = node.ParentNode;
                                while (!Object.Equals(Pnode.Key, ""))
                                {
                                    strViTri = " - " + Pnode.GetValue("ten").ToString() + strViTri;
                                    Pnode    = Pnode.ParentNode;
                                }
                                strViTri = string.Format("({0})", strViTri.Substring(3));
                                ucPhongThietBi_BreadCrumb.Label_TenPhong.Text = objPhong.ten + " " + strViTri;
                                LoadDataObjPhong();
                                if (Request.QueryString["id"] != null)
                                {
                                    idThietBi = Guid.Empty;
                                    try
                                    {
                                        idThietBi = GUID.From(Request.QueryString["id"]);
                                    }
                                    catch
                                    {
                                        Response.Redirect(Request.Url.AbsolutePath);
                                    }
                                    objThietBi = PTB.Entities.ThietBi.getById(idThietBi);
                                    if (objThietBi != null)
                                    {
                                        Label_ThongTinThietBi.Text = string.Format("Thông tin {0}", objThietBi.ten);
                                        Panel_ThietBi.Visible      = true;
                                        Libraries.ImageHelper.LoadImageWeb(objThietBi.hinhanhs.ToList(), _ucASPxImageSlider_Web.ASPxImageSlider_Object);
                                        _ucASPxImageSlider_Web.urlHinhAnh = string.Format("http://{0}/HinhAnh.aspx?id={1}&type=THIETBI", HttpContext.Current.Request.Url.Authority, objThietBi.id);
                                        Label_MaThietBi.Text = objThietBi.subId;
                                        ucPhongThietBi_BreadCrumb.Label_TenThietBi.Text = Label_TenThietBi.Text = objThietBi.ten;
                                        if (objThietBi.loaithietbi != null)
                                        {
                                            Label_LoaiThietBi.Text = objThietBi.loaithietbi.ten;
                                            if (objThietBi.loaithietbi.loaichung)
                                            {
                                                Panel_NgayMua.Visible = false;
                                                Label_NgayMua.Text    = "";
                                                Label_KieuQuanLy.Text = "Theo số lượng";
                                            }
                                            else
                                            {
                                                Panel_NgayMua.Visible = true;
                                                Label_NgayMua.Text    = objThietBi.ngaymua.ToString();
                                                Label_KieuQuanLy.Text = "Theo cá thể";
                                            }
                                        }
                                        else
                                        {
                                            Label_LoaiThietBi.Text = "[Loại thiết bị]";
                                            Panel_NgayMua.Visible  = false;
                                            Label_NgayMua.Text     = "";
                                            Label_KieuQuanLy.Text  = "Chưa rõ";
                                        }
                                        Label_Phong.Text   = objPhong.ten;
                                        Label_NgayLap.Text = objThietBi.ctthietbis != null?objThietBi.ctthietbis.Where(item => item.phong_id == objPhong.id).FirstOrDefault().ngay.ToString() : "";

                                        Label_MoTa.Text             = Libraries.StringHelper.ConvertRNToBR(objThietBi.mota);
                                        Button_XemLog.OnClientClick = string.Format("OnMoreInfoClick('{0}'); return false;", Libraries.StringHelper.AddParameter(new Uri("http://" + Request.Url.Authority + "/" + ResolveClientUrl("~/LogThietBi.aspx")), new List <string>(new string[] { "id", "idp" }), new List <string>(new string[] { idThietBi.ToString(), objPhong.id.ToString() })));
                                        Label_ThietBi.Visible       = false;
                                        Label_ThietBi.Text          = "";
                                    }
                                    else
                                    {
                                        Response.Redirect(Request.Url.AbsolutePath);
                                    }
                                }
                                else
                                {
                                    ClearData();
                                }
                            }
                            else
                            {
                                Response.Redirect(Request.Url.AbsolutePath);
                            }
                        }
                        else
                        {
                            Response.Redirect(Request.Url.AbsolutePath);
                        }
                    }
                    else
                    {
                        DevExpress.Web.ASPxTreeList.TreeListNode node = _ucTreeViTri.ASPxTreeList_ViTri.FindNodeByKeyValue("");
                        node.Focus();
                        Label_DanhSachThietBi.Text = "Chưa chọn phòng";
                        ClearData();
                    }
                }
                else
                {
                    ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
                    ucThongBaoLoi.Label_ThongBaoLoi.Text    = "Chưa có phòng";
                }
            }
            else
            {
                ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
                ucThongBaoLoi.Label_ThongBaoLoi.Text    = "Chưa có vị trí";
            }
        }
 public void LoadData()
 {
     listViTriHienThi = ViTriHienThi.getAllHavePhong();
     if (listViTriHienThi.Count > 0)
     {
         if (listViTriHienThi.Where(item => Object.Equals(item.loai, typeof(PTB.Entities.Phong).Name)).FirstOrDefault() != null)
         {
             _ucTreeViTri.CreateTreeList();
             _ucTreeViTri.ASPxTreeList_ViTri.DataSource = listViTriHienThi;
             _ucTreeViTri.ASPxTreeList_ViTri.DataBind();
             if (Request.QueryString["key"] != null)
             {
                 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)
                 {
                     node.Focus();
                     objPhong = PTB.Entities.Phong.getById(GUID.From(node.GetValue("id")));
                     if (objPhong != null)
                     {
                         if (Request.QueryString["id"] != null)
                         {
                             idSuCo = Guid.Empty;
                             try
                             {
                                 idSuCo = GUID.From(Request.QueryString["id"]);
                             }
                             catch
                             {
                                 Response.Redirect(Request.Url.AbsolutePath);
                             }
                             objSuCoPhong = PTB.Entities.SuCoPhong.getById(idSuCo);
                             if (objSuCoPhong != null)
                             {
                                 Panel_SuCo.Visible = true;
                                 Label_ThongTinSuCo.Text = "Thông tin " + objSuCoPhong.ten;
                                 Libraries.ImageHelper.LoadImageWeb(objSuCoPhong.hinhanhs.ToList(), _ucASPxImageSlider_Mobile.ASPxImageSlider_Object);
                                 Session["TenSuCo"] = Label_TenSuCo.Text = objSuCoPhong.ten;
                                 Label_TinhTrang.Text = objSuCoPhong.tinhtrang != null ? objSuCoPhong.tinhtrang.value : "[Tình trạng]";
                                 Label_NgayTao.Text = ((DateTime)objSuCoPhong.date_create).ToString();
                                 Label_MoTa.Text = Libraries.StringHelper.ConvertRNToBR(objSuCoPhong.mota);
                                 Button_XemLog.OnClientClick = string.Format("location.href='{0}'; return false;", Libraries.StringHelper.AddParameter(new Uri("http://" + Request.Url.Authority + "/" + ResolveClientUrl("~/LogSuCo.aspx")), "id", idSuCo.ToString()));
                             }
                             else
                             {
                                 Response.Redirect(Request.Url.AbsolutePath);
                             }
                         }
                         else
                         {
                             LoadDataObjPhong();
                             Panel_DanhSachSuCo.Visible = true;
                         }
                     }
                     else
                     {
                         Response.Redirect(Request.Url.AbsolutePath);
                     }
                 }
                 else
                 {
                     Response.Redirect(Request.Url.AbsolutePath);
                 }
             }
             else
             {
                 Panel_TreeViTri.Visible = true;
             }
         }
         else
         {
             ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
             ucThongBaoLoi.Label_ThongBaoLoi.Text = "Chưa có phòng";
         }
     }
     else
     {
         ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
         ucThongBaoLoi.Label_ThongBaoLoi.Text = "Chưa có vị trí";
     }
 }
        public void LoadData()
        {
            HyperLinkXemLogTheoPhong.NavigateUrl   = Libraries.StringHelper.AddParameter(new Uri(Request.Url.AbsoluteUri), "type", "phong").ToString();;
            HyperLinkXemLogTheoThietBi.NavigateUrl = Libraries.StringHelper.AddParameter(new Uri(Request.Url.AbsoluteUri), "type", "thietbi").ToString();

            if (Request.QueryString["id"] != null && Request.QueryString["idp"] != null)
            {
                Guid id  = Guid.Empty;
                Guid idp = Guid.Empty;
                try
                {
                    id  = GUID.From(Request.QueryString["id"]);
                    idp = GUID.From(Request.QueryString["idp"]);
                }
                catch
                {
                    Response.Redirect("~/");
                }
                objThietBi = PTB.Entities.ThietBi.getById(id);
                objPhong   = PTB.Entities.Phong.getById(idp);
                if (objThietBi != null)
                {
                    try
                    {
                        if (Request.QueryString["type"] == "thietbi")
                        {
                            XemLogTheoThietBi();
                        }
                        else
                        {
                            XemLogTheoPhong();
                        }
                    }
                    catch (Exception)
                    {
                        Response.Redirect("~/");
                    }

                    if (listLogThietBi.Count == 0)
                    {
                        Panel_ThongBaoLoi.Visible = true;
                        Label_ThongBaoLoi.Text    = string.Format("Thiết bị {0} không có log", objThietBi.ten);
                    }
                    else
                    {
                        Panel_Chinh.Visible = true;
                        if (Request.QueryString["idLog"] != null)
                        {
                            idLog = Guid.Empty;
                            try
                            {
                                idLog = GUID.From(Request.QueryString["idLog"]);
                            }
                            catch
                            {
                                Response.Redirect(Request.Url.AbsolutePath);
                            }
                        }
                        else
                        {
                            idLog = listLogThietBi.ElementAt(0).id;
                        }
                        objLogThietBi = listLogThietBi.Where(item => item.id == idLog).FirstOrDefault();
                        if (objLogThietBi == null)
                        {
                            idLog         = listLogThietBi.ElementAt(0).id;
                            objLogThietBi = listLogThietBi.Where(item => item.id == idLog).FirstOrDefault();
                        }

                        Label_ThongTinLog.Text = string.Format("Thông tin log ngày {0}", ((DateTime)objLogThietBi.date_create).ToString("d/M/yyyy"));
                        Libraries.ImageHelper.LoadImageWeb(objLogThietBi.hinhanhs.ToList(), _ucASPxImageSlider_Web.ASPxImageSlider_Object);
                        Label_TenThietBi.Text  = objThietBi.ten;
                        Label_TinhTrang.Text   = objLogThietBi.tinhtrang != null ? objLogThietBi.tinhtrang.value : "[Tình trạng]";
                        Label_SoLuong.Text     = objLogThietBi.soluong.ToString();
                        Label_Phong.Text       = objLogThietBi.phong != null ? objLogThietBi.phong.ten : "[Phòng]";
                        Label_Ngay.Text        = objLogThietBi.date_create.ToString();
                        Label_QuanTriVien.Text = objLogThietBi.quantrivien != null ? objLogThietBi.quantrivien.hoten : "[Quản trị viên]";
                        Label_GhiChu.Text      = Libraries.StringHelper.ConvertRNToBR(objLogThietBi.mota);
                    }
                }
                else
                {
                    if (Request.UrlReferrer == null)
                    {
                        Response.Redirect("~/");
                    }
                    else
                    {
                        Panel_ThongBaoLoi.Visible = true;
                        Label_ThongBaoLoi.Text    = "Không có thiết bị này";
                    }
                }
            }
            else
            {
                Response.Redirect("~/");
            }
        }
        //protected void Button_Back_Click(object sender, EventArgs e)
        //{
        //    if (Request.QueryString[_ucCollectionPager_DanhSachNhanVien.CollectionPager_Object.QueryStringKey] != null)
        //    {
        //        int Page = 1;
        //        try
        //        {
        //            Page = Convert.ToInt32(Request.QueryString[_ucCollectionPager_DanhSachNhanVien.CollectionPager_Object.QueryStringKey].ToString());
        //        }
        //        catch
        //        {
        //            Response.Redirect(Request.Url.AbsolutePath);
        //        }
        //        Response.Redirect(string.Format(Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.IndexOf(Request.Url.AbsolutePath) + Request.Url.AbsolutePath.Length) + "?{0}={1}", _ucCollectionPager_DanhSachNhanVien.CollectionPager_Object.QueryStringKey, Page.ToString()));
        //    }
        //    else
        //        Response.Redirect(Request.Url.AbsolutePath);
        //}

        public string getVitri(PTB.Entities.Phong _objPhong)
        {
            return(Libraries.StringHelper.StringViTriPhong(_objPhong));
        }
        public void LoadData()
        {
            listPhong = PTB.Entities.Phong.getAll();
            if (listPhong.Count > 0)
            {
                listViTriHienThi = ViTriHienThi.getAll();
                if (listViTriHienThi.Count > 0)
                {
                    _ucTreeViTri.CreateTreeList();
                    _ucTreeViTri.ASPxTreeList_ViTri.DataSource = listViTriHienThi;
                    _ucTreeViTri.ASPxTreeList_ViTri.DataBind();
                    SearchFunction();
                    if (Request.QueryString["key"] != null)
                    {
                        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)
                            {
                                Guid idPhong = Guid.Empty;
                                try
                                {
                                    idPhong = GUID.From(Request.QueryString["id"]);
                                }
                                catch
                                {
                                    Response.Redirect(Request.Url.AbsolutePath);
                                }
                                objPhong = PTB.Entities.Phong.getById(idPhong);
                                if (objPhong != null)
                                {
                                    ucPhong_BreadCrumb.Label_TenPhong.Text = objPhong.ten;
                                    Panel_ThongTinPhong.Visible = true;
                                    Libraries.ImageHelper.LoadImageWeb(objPhong.hinhanhs.ToList(), _ucASPxImageSlider_Mobile_Phong.ASPxImageSlider_Object);
                                    Label_MaPhong.Text = objPhong.subId;
                                    Label_TenPhong.Text = objPhong.ten;
                                    string strCoSo, strDay, strTang;
                                    strCoSo = objPhong.vitri.coso != null ? objPhong.vitri.coso.ten : "";
                                    strDay = objPhong.vitri.day != null ? objPhong.vitri.day.ten : "";
                                    strTang = objPhong.vitri.tang != null ? objPhong.vitri.tang.ten : "";
                                    if (!strCoSo.Equals(""))
                                    {
                                        Label_ViTriPhong.Text += strCoSo;
                                        if (!strDay.Equals(""))
                                        {
                                            Label_ViTriPhong.Text += " - " + strDay;
                                            if (!strTang.Equals(""))
                                            {
                                                Label_ViTriPhong.Text += " - " + strTang;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Label_ViTriPhong.Text = "[Không rõ]";
                                    }
                                    Label_MoTaPhong.Text = Libraries.StringHelper.ConvertRNToBR(objPhong.mota);
                                    Label_NhanVienPhuTrach.Text = objPhong.nhanvienpt != null ? objPhong.nhanvienpt.hoten : "";

                                    if (objPhong.nhanvienpt != null)
                                    {
                                        Panel_NhanVienPT.Visible = true;
                                        Label_NhanVienPT.Visible = false;
                                        Label_NhanVienPT.Text = "";
                                        Libraries.ImageHelper.LoadImageWeb(objPhong.nhanvienpt.hinhanhs.ToList(), _ucASPxImageSlider_Mobile_NhanVienPT.ASPxImageSlider_Object);
                                        Label_MaNhanVien.Text = objPhong.nhanvienpt.subId;
                                        Label_HoTen.Text = objPhong.nhanvienpt.hoten;
                                        Label_SoDienThoai.Text = objPhong.nhanvienpt.sodienthoai;
                                    }
                                    else
                                    {
                                        Panel_NhanVienPT.Visible = false;
                                        Label_NhanVienPT.Visible = true;
                                        Label_NhanVienPT.Text = "Phòng này chưa có nhân viên phụ trách";
                                        Libraries.ImageHelper.LoadImageWeb(null, _ucASPxImageSlider_Mobile_NhanVienPT.ASPxImageSlider_Object);
                                        Label_MaNhanVien.Text = "";
                                        Label_HoTen.Text = "";
                                        Label_SoDienThoai.Text = "";
                                    }
                                }
                                else
                                {
                                    Response.Redirect(Request.Url.AbsolutePath);
                                }
                            }
                            else
                            {
                                LoadDanhSachPhong(GUID.From(node.GetValue("id")), node.GetValue("loai").ToString());
                                Panel_DanhSachPhong.Visible = true;
                            }
                        }
                        else
                            Response.Redirect(Request.Url.AbsolutePath);
                    }
                    else
                    {
                        Panel_TreeListViTri.Visible = true;
                    }
                }
                else
                {
                    ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
                    ucThongBaoLoi.Label_ThongBaoLoi.Text = "Chưa có phòng";
                }
            }
            else
            {
                ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
                ucThongBaoLoi.Label_ThongBaoLoi.Text = "Chưa có phòng";
            }
        }
        public void LoadData()
        {
            listPhong = PTB.Entities.Phong.getAll();
            if (listPhong.Count > 0)
            {
                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);
                    }
                    Panel_Chinh.Visible = true;
                    if (Request.QueryString["key"] != null)
                    {
                        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)
                        {
                            idPhong = Guid.Empty;
                            try
                            {
                                idPhong = GUID.From(Request.QueryString["id"]);
                            }
                            catch
                            {
                                Response.Redirect(Request.Url.AbsolutePath);
                            }

                            objPhong = PTB.Entities.Phong.getById(idPhong);
                            if (objPhong != null)
                            {
                                Panel_Phong.Visible = true;
                                Label_Phong.Visible = false;
                                Label_ThongTinPhong.Text = "Thông tin " + objPhong.ten;
                                Libraries.ImageHelper.LoadImageWeb(objPhong.hinhanhs.ToList(), _ucASPxImageSlider_Web_Phong.ASPxImageSlider_Object);
                                _ucASPxImageSlider_Web_Phong.urlHinhAnh = string.Format("http://{0}/HinhAnh.aspx?id={1}&type=PHONG", HttpContext.Current.Request.Url.Authority, objPhong.id);
                                Label_MaPhong.Text = objPhong.subId;
                                ucPhong_BreadCrumb.Label_TenPhong.Text = Label_TenPhong.Text = objPhong.ten;
                                string strCoSo, strDay, strTang;
                                strCoSo = objPhong.vitri.coso != null ? objPhong.vitri.coso.ten : "";
                                strDay = objPhong.vitri.day != null ? objPhong.vitri.day.ten : "";
                                strTang = objPhong.vitri.tang != null ? objPhong.vitri.tang.ten : "";
                                if (!strCoSo.Equals(""))
                                {
                                    Label_ViTriPhong.Text += strCoSo;
                                    if (!strDay.Equals(""))
                                    {
                                        Label_ViTriPhong.Text += " - " + strDay;
                                        if (!strTang.Equals(""))
                                        {
                                            Label_ViTriPhong.Text += " - " + strTang;
                                        }
                                    }
                                }
                                else
                                {
                                    Label_ViTriPhong.Text = "[Không rõ]";
                                }
                                Label_MoTaPhong.Text = Libraries.StringHelper.ConvertRNToBR(objPhong.mota);
                                Label_NhanVienPhuTrach.Text = objPhong.nhanvienpt != null ? objPhong.nhanvienpt.hoten : "";

                                if (objPhong.nhanvienpt != null)
                                {
                                    Panel_NhanVienPT.Visible = true;
                                    Label_NhanVienPT.Visible = false;
                                    Label_NhanVienPT.Text = "";
                                    Libraries.ImageHelper.LoadImageWeb(objPhong.nhanvienpt.hinhanhs.ToList(), _ucASPxImageSlider_Web_NhanVienPT.ASPxImageSlider_Object);
                                    _ucASPxImageSlider_Web_NhanVienPT.urlHinhAnh = string.Format("http://{0}/HinhAnh.aspx?id={1}&type=NHANVIEN", HttpContext.Current.Request.Url.Authority, objPhong.nhanvienpt_id);
                                    Label_MaNhanVien.Text = objPhong.nhanvienpt.subId;
                                    Label_HoTen.Text = objPhong.nhanvienpt.hoten;
                                    Label_SoDienThoai.Text = objPhong.nhanvienpt.sodienthoai;
                                }
                                else
                                {
                                    Panel_NhanVienPT.Visible = false;
                                    Label_NhanVienPT.Visible = true;
                                    Label_NhanVienPT.Text = "Phòng này chưa có nhân viên phụ trách";
                                    Libraries.ImageHelper.LoadImageWeb(null, _ucASPxImageSlider_Web_NhanVienPT.ASPxImageSlider_Object);
                                    Label_MaNhanVien.Text = "";
                                    Label_HoTen.Text = "";
                                    Label_SoDienThoai.Text = "";
                                }
                            }
                            else
                            {
                                Response.Redirect(Request.Url.AbsolutePath);
                            }
                        }
                        else
                        {
                            ClearData();
                            Label_Phong.Visible = true;
                            Label_Phong.Text = "Chưa chọn phòng";
                        }
                    }
                    else
                    {
                        DevExpress.Web.ASPxTreeList.TreeListNode node = _ucTreeViTri.ASPxTreeList_ViTri.FindNodeByKeyValue("");
                        node.Focus();
                        Label_TextDanhSachPhong.Text = "Chưa chọn vị trí";
                        ClearData();
                        Label_Phong.Visible = true;
                        Label_Phong.Text = "Chưa chọn phòng";
                    }
                }
                else
                {
                    ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
                    ucThongBaoLoi.Label_ThongBaoLoi.Text = "Chưa có phòng";
                }
            }
            else
            {
                ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
                ucThongBaoLoi.Label_ThongBaoLoi.Text = "Chưa có phòng";
            }
        }
        public void LoadData()
        {
            HyperLinkXemLogTheoPhong.NavigateUrl = Libraries.StringHelper.AddParameter(new Uri(Request.Url.AbsoluteUri), "type", "phong").ToString(); ;
            HyperLinkXemLogTheoThietBi.NavigateUrl = Libraries.StringHelper.AddParameter(new Uri(Request.Url.AbsoluteUri), "type", "thietbi").ToString();

            if (Request.QueryString["id"] != null && Request.QueryString["idp"] != null)
            {
                Guid id = Guid.Empty;
                Guid idp = Guid.Empty;
                try
                {
                    id = GUID.From(Request.QueryString["id"]);
                    idp = GUID.From(Request.QueryString["idp"]);
                }
                catch
                {
                    Response.Redirect("~/");
                }
                objThietBi = PTB.Entities.ThietBi.getById(id);
                objPhong = PTB.Entities.Phong.getById(idp);
                if (objThietBi != null)
                {
                    try
                    {
                        if (Request.QueryString["type"] == "thietbi")
                        {
                            XemLogTheoThietBi();
                        }
                        else
                        {
                            XemLogTheoPhong();
                        }
                    }
                    catch (Exception)
                    {
                        Response.Redirect("~/");
                    }

                    if (listLogThietBi.Count == 0)
                    {
                        Panel_ThongBaoLoi.Visible = true;
                        Label_ThongBaoLoi.Text = string.Format("Thiết bị {0} không có log", objThietBi.ten);
                    }
                    else
                    {
                        Panel_Chinh.Visible = true;
                        if (Request.QueryString["idLog"] != null)
                        {
                            idLog = Guid.Empty;
                            try
                            {
                                idLog = GUID.From(Request.QueryString["idLog"]);
                            }
                            catch
                            {
                                Response.Redirect(Request.Url.AbsolutePath);
                            }
                        }
                        else
                        {
                            idLog = listLogThietBi.ElementAt(0).id;
                        }
                        objLogThietBi = listLogThietBi.Where(item => item.id == idLog).FirstOrDefault();
                        if (objLogThietBi == null)
                        {
                            idLog = listLogThietBi.ElementAt(0).id;
                            objLogThietBi = listLogThietBi.Where(item => item.id == idLog).FirstOrDefault();
                        }

                        Label_ThongTinLog.Text = string.Format("Thông tin log ngày {0}", ((DateTime)objLogThietBi.date_create).ToString("d/M/yyyy"));
                        Libraries.ImageHelper.LoadImageWeb(objLogThietBi.hinhanhs.ToList(), _ucASPxImageSlider_Web.ASPxImageSlider_Object);
                        Label_TenThietBi.Text = objThietBi.ten;
                        Label_TinhTrang.Text = objLogThietBi.tinhtrang != null ? objLogThietBi.tinhtrang.value : "[Tình trạng]";
                        Label_SoLuong.Text = objLogThietBi.soluong.ToString();
                        Label_Phong.Text = objLogThietBi.phong != null ? objLogThietBi.phong.ten : "[Phòng]";
                        Label_Ngay.Text = objLogThietBi.date_create.ToString();
                        Label_QuanTriVien.Text = objLogThietBi.quantrivien != null ? objLogThietBi.quantrivien.hoten : "[Quản trị viên]";
                        Label_GhiChu.Text = Libraries.StringHelper.ConvertRNToBR(objLogThietBi.mota);
                    }
                }
                else
                {
                    if (Request.UrlReferrer == null)
                    {
                        Response.Redirect("~/");
                    }
                    else
                    {
                        Panel_ThongBaoLoi.Visible = true;
                        Label_ThongBaoLoi.Text = "Không có thiết bị này";
                    }
                }
            }
            else
            {
                Response.Redirect("~/");
            }
        }
Esempio n. 16
0
        public void LoadData()
        {
            listPhong = PTB.Entities.Phong.getAll();
            if (listPhong.Count > 0)
            {
                listViTriHienThi = ViTriHienThi.getAll();
                if (listViTriHienThi.Count > 0)
                {
                    _ucTreeViTri.CreateTreeList();
                    _ucTreeViTri.ASPxTreeList_ViTri.DataSource = listViTriHienThi;
                    _ucTreeViTri.ASPxTreeList_ViTri.DataBind();
                    SearchFunction();
                    if (Request.QueryString["key"] != null)
                    {
                        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)
                            {
                                Guid idPhong = Guid.Empty;
                                try
                                {
                                    idPhong = GUID.From(Request.QueryString["id"]);
                                }
                                catch
                                {
                                    Response.Redirect(Request.Url.AbsolutePath);
                                }
                                objPhong = PTB.Entities.Phong.getById(idPhong);
                                if (objPhong != null)
                                {
                                    ucPhong_BreadCrumb.Label_TenPhong.Text = objPhong.ten;
                                    Panel_ThongTinPhong.Visible            = true;
                                    Libraries.ImageHelper.LoadImageWeb(objPhong.hinhanhs.ToList(), _ucASPxImageSlider_Mobile_Phong.ASPxImageSlider_Object);
                                    Label_MaPhong.Text  = objPhong.subId;
                                    Label_TenPhong.Text = objPhong.ten;
                                    string strCoSo, strDay, strTang;
                                    strCoSo = objPhong.vitri.coso != null ? objPhong.vitri.coso.ten : "";
                                    strDay  = objPhong.vitri.day != null ? objPhong.vitri.day.ten : "";
                                    strTang = objPhong.vitri.tang != null ? objPhong.vitri.tang.ten : "";
                                    if (!strCoSo.Equals(""))
                                    {
                                        Label_ViTriPhong.Text += strCoSo;
                                        if (!strDay.Equals(""))
                                        {
                                            Label_ViTriPhong.Text += " - " + strDay;
                                            if (!strTang.Equals(""))
                                            {
                                                Label_ViTriPhong.Text += " - " + strTang;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Label_ViTriPhong.Text = "[Không rõ]";
                                    }
                                    Label_MoTaPhong.Text        = Libraries.StringHelper.ConvertRNToBR(objPhong.mota);
                                    Label_NhanVienPhuTrach.Text = objPhong.nhanvienpt != null ? objPhong.nhanvienpt.hoten : "";

                                    if (objPhong.nhanvienpt != null)
                                    {
                                        Panel_NhanVienPT.Visible = true;
                                        Label_NhanVienPT.Visible = false;
                                        Label_NhanVienPT.Text    = "";
                                        Libraries.ImageHelper.LoadImageWeb(objPhong.nhanvienpt.hinhanhs.ToList(), _ucASPxImageSlider_Mobile_NhanVienPT.ASPxImageSlider_Object);
                                        Label_MaNhanVien.Text  = objPhong.nhanvienpt.subId;
                                        Label_HoTen.Text       = objPhong.nhanvienpt.hoten;
                                        Label_SoDienThoai.Text = objPhong.nhanvienpt.sodienthoai;
                                    }
                                    else
                                    {
                                        Panel_NhanVienPT.Visible = false;
                                        Label_NhanVienPT.Visible = true;
                                        Label_NhanVienPT.Text    = "Phòng này chưa có nhân viên phụ trách";
                                        Libraries.ImageHelper.LoadImageWeb(null, _ucASPxImageSlider_Mobile_NhanVienPT.ASPxImageSlider_Object);
                                        Label_MaNhanVien.Text  = "";
                                        Label_HoTen.Text       = "";
                                        Label_SoDienThoai.Text = "";
                                    }
                                }
                                else
                                {
                                    Response.Redirect(Request.Url.AbsolutePath);
                                }
                            }
                            else
                            {
                                LoadDanhSachPhong(GUID.From(node.GetValue("id")), node.GetValue("loai").ToString());
                                Panel_DanhSachPhong.Visible = true;
                            }
                        }
                        else
                        {
                            Response.Redirect(Request.Url.AbsolutePath);
                        }
                    }
                    else
                    {
                        Panel_TreeListViTri.Visible = true;
                    }
                }
                else
                {
                    ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
                    ucThongBaoLoi.Label_ThongBaoLoi.Text    = "Chưa có phòng";
                }
            }
            else
            {
                ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
                ucThongBaoLoi.Label_ThongBaoLoi.Text    = "Chưa có phòng";
            }
        }
Esempio n. 17
0
 private int SearchPage(Guid GuidPhong, Guid GuidSuCoPhong)
 {
     int Page = -1;
     objPhong = PTB.Entities.Phong.getById(GuidPhong);
     listSuCoPhong = objPhong.sucophongs.ToList();
     int index = listSuCoPhong.IndexOf(listSuCoPhong.Where(item => Object.Equals(item.id, GuidSuCoPhong)).FirstOrDefault());
     if (index != -1)
     {
         Page = index / _ucCollectionPager_DanhSachSuCo.CollectionPager_Object.PageSize + 1;
     }
     return Page;
 }
Esempio n. 18
0
        public void LoadData()
        {
            listViTriHienThi = ViTriHienThi.getAllHavePhong();
            if (listViTriHienThi.Count > 0)
            {
                if (listViTriHienThi.Where(item => Object.Equals(item.loai, typeof(PTB.Entities.Phong).Name)).FirstOrDefault() != null)
                {
                    Panel_Chinh.Visible = true;
                    _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_DanhSachSuCo.ShowPanelPage(PanelChangePage);
                    }
                    if (Request.QueryString["key"] != null)
                    {
                        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);
                            objPhong = PTB.Entities.Phong.getById(GUID.From(node.GetValue("id")));
                            if (objPhong != null)
                            {
                                LoadDataObjPhong();
                                if (Request.QueryString["id"] != null)
                                {
                                    idSuCo = Guid.Empty;
                                    try
                                    {
                                        idSuCo = GUID.From(Request.QueryString["id"]);
                                    }
                                    catch
                                    {
                                        Response.Redirect(Request.Url.AbsolutePath);
                                    }
                                    objSuCoPhong = PTB.Entities.SuCoPhong.getById(idSuCo);
                                    if (objSuCoPhong != null)
                                    {
                                        Panel_SuCo.Visible = true;
                                        Label_SuCo.Visible = false;
                                        Label_SuCo.Text = "";
                                        Label_ThongTinSuCo.Text = "Thông tin " + objSuCoPhong.ten;
                                        Libraries.ImageHelper.LoadImageWeb(objSuCoPhong.hinhanhs.ToList(), _ucASPxImageSlider_Web.ASPxImageSlider_Object);
                                        _ucASPxImageSlider_Web.urlHinhAnh = string.Format("http://{0}/HinhAnh.aspx?id={1}&type=SUCOPHONG", HttpContext.Current.Request.Url.Authority, objSuCoPhong.id);
                                        Session["TenSuCo"] = Label_TenSuCo.Text = objSuCoPhong.ten;
                                        Label_TinhTrang.Text = objSuCoPhong.tinhtrang != null ? objSuCoPhong.tinhtrang.value : "[Tình trạng]";
                                        Label_NgayTao.Text = ((DateTime)objSuCoPhong.date_create).ToString();
                                        Label_MoTa.Text = Libraries.StringHelper.ConvertRNToBR(objSuCoPhong.mota);
                                        Button_XemLog.OnClientClick = string.Format("OnMoreInfoClick('{0}'); return false;", Libraries.StringHelper.AddParameter(new Uri("http://" + Request.Url.Authority + "/" + ResolveClientUrl("~/LogSuCo.aspx")), "id", idSuCo.ToString()));
                                    }
                                    else
                                    {
                                        Response.Redirect(Request.Url.AbsolutePath);
                                    }
                                }
                                else
                                {
                                    Panel_SuCo.Visible = false;
                                    Label_SuCo.Visible = true;
                                    Label_SuCo.Text = "Chưa chọn sự cố";
                                }
                            }
                            else
                            {
                                Response.Redirect(Request.Url.AbsolutePath);
                            }
                        }
                        else
                            Response.Redirect(Request.Url.AbsolutePath);
                    }
                    else
                    {
                        DevExpress.Web.ASPxTreeList.TreeListNode node = _ucTreeViTri.ASPxTreeList_ViTri.FindNodeByKeyValue("");
                        node.Focus();
                        Label_DanhSachSuCo.Text = "Chưa chọn phòng";
                        ClearData();
                    }
                }
                else
                {

                    ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
                    ucThongBaoLoi.Label_ThongBaoLoi.Text = "Chưa có phòng";
                }
            }
            else
            {
                ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
                ucThongBaoLoi.Label_ThongBaoLoi.Text = "Chưa có sự cố";
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Di chuyển, kết hợp đổi tình trạng,
        /// có hỗ trợ ghi LOG tự động,vd:
        /// CTThietBi obj = CTThietBi.getById(24552);
        /// Phong dich = null;// Phong.getById(1228);
        /// TinhTrang ttr = TinhTrang.getById(3);
        /// int re = obj.dichuyen(dich, ttr, -1, "đổi tình trạng toàn bộ luôn");
        /// </summary>
        /// <param name="dich">Phòng cần di chuyển đến (null nếu chỉ muốn đổi tình trạng)</param>
        /// <param name="ttmoi">Tình trạng cần chuyển sang (null nếu chỉ muốn đổi phòng)</param>
        /// <param name="soluong">Số lượng cần chuyển (mac dinh la -1 (chuyển tất cả))</param>
        /// /// <param name="mota">Mô tả cho quá trình di chuyển</param>
        /// <param name="hinhs">Hình mô tả cho quá trình di chuyển (Hình sạch)</param>
        /// <returns></returns>
        public int dichuyen(Phong dich = null, TinhTrang ttmoi = null, int soluong = -1, String mota = "", List <HinhAnh> hinhs = null, DateTime?ngay = null)
        {
            try
            {
                //pre set data
                dich = dich == null ? this.phong : dich;
                //=> dich co the van se la null (do this.phong có thể là null)
                ttmoi = ttmoi == null ? this.tinhtrang : ttmoi;//tinh trang không thể null
                ngay  = ngay == null?ServerTimeHelper.getNow() : ngay;

                //XÉT ĐIỀU KIỆN
                if
                (
                    //Nếu Không có bất kỳ sự thay đổi nào, phòng và tình trạng giống với this
                    ((dich == null && this.phong == null) || (dich != null && dich.id == this.phong.id)) &&
                    ttmoi.id == this.tinhtrang.id
                )
                {
                    return(-2);
                }
                //kiem tra rang buoc không cho thực thi
                if
                (
                    soluong == 0 || soluong > this.soluong
                )
                {
                    return(-2);
                }
                soluong = soluong < 0 ? this.soluong : soluong;

                //tao hoac cap nhat mot CTTB moi cho PHONG moi (dich)
                //kiem tra co record nao trung với record cần tạo mới (dich, tinhtrang, thietbi) ?
                CTThietBi tmp = search(dich, this.thietbi, ttmoi);

                //NO
                //TAO MOI CTTB => add
                if (tmp == null)
                {
                    tmp           = new CTThietBi();
                    tmp.phong     = dich;
                    tmp.soluong   = soluong;
                    tmp.thietbi   = this.thietbi;
                    tmp.tinhtrang = ttmoi;
                    tmp.mota      = mota;
                    tmp.hinhanhs  = hinhs;
                    tmp.ngay      = ngay;
                    tmp.add();
                }
                else
                {
                    //Đã có CTTB sẵn giống với CTTB cần tạo mới
                    //SELECT CTTB do len => update
                    if (tmp.id != this.id)
                    {
                        tmp.soluong += soluong;
                        tmp.mota     = mota;
                        tmp.hinhanhs = hinhs;
                        tmp.ngay     = ngay;
                        tmp.update();
                    }
                }

                //cap nhat lai so luong cho cái hiện đã bị chuyển
                this.mota     = mota;
                this.soluong -= soluong;
                this.soluong  = this.soluong < 0 ? 0 : this.soluong;//for sure
                this.hinhanhs = hinhs;
                //ghi log thietbi ngay sau khi cap nhat ONLY soluong
                this.update();
                return(1);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(-1);
            }
        }
 public void LoadData()
 {
     listViTriHienThi = ViTriHienThi.getAllHavePhong();
     if (listViTriHienThi.Count > 0)
     {
         if (listViTriHienThi.Where(item => Object.Equals(item.loai, typeof(PTB.Entities.Phong).Name)).FirstOrDefault() != null)
         {
             _ucTreeViTri.CreateTreeList();
             _ucTreeViTri.ASPxTreeList_ViTri.DataSource = listViTriHienThi;
             _ucTreeViTri.ASPxTreeList_ViTri.DataBind();
             if (Request.QueryString["key"] != null)
             {
                 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)
                 {
                     node.Focus();
                     objPhong = PTB.Entities.Phong.getById(GUID.From(node.GetValue("id")));
                     if (objPhong != null)
                     {
                         if (Request.QueryString["id"] != null)
                         {
                             idSuCo = Guid.Empty;
                             try
                             {
                                 idSuCo = GUID.From(Request.QueryString["id"]);
                             }
                             catch
                             {
                                 Response.Redirect(Request.Url.AbsolutePath);
                             }
                             objSuCoPhong = PTB.Entities.SuCoPhong.getById(idSuCo);
                             if (objSuCoPhong != null)
                             {
                                 Panel_SuCo.Visible      = true;
                                 Label_ThongTinSuCo.Text = "Thông tin " + objSuCoPhong.ten;
                                 Libraries.ImageHelper.LoadImageWeb(objSuCoPhong.hinhanhs.ToList(), _ucASPxImageSlider_Mobile.ASPxImageSlider_Object);
                                 Session["TenSuCo"]          = Label_TenSuCo.Text = objSuCoPhong.ten;
                                 Label_TinhTrang.Text        = objSuCoPhong.tinhtrang != null ? objSuCoPhong.tinhtrang.value : "[Tình trạng]";
                                 Label_NgayTao.Text          = ((DateTime)objSuCoPhong.date_create).ToString();
                                 Label_MoTa.Text             = Libraries.StringHelper.ConvertRNToBR(objSuCoPhong.mota);
                                 Button_XemLog.OnClientClick = string.Format("location.href='{0}'; return false;", Libraries.StringHelper.AddParameter(new Uri("http://" + Request.Url.Authority + "/" + ResolveClientUrl("~/LogSuCo.aspx")), "id", idSuCo.ToString()));
                             }
                             else
                             {
                                 Response.Redirect(Request.Url.AbsolutePath);
                             }
                         }
                         else
                         {
                             LoadDataObjPhong();
                             Panel_DanhSachSuCo.Visible = true;
                         }
                     }
                     else
                     {
                         Response.Redirect(Request.Url.AbsolutePath);
                     }
                 }
                 else
                 {
                     Response.Redirect(Request.Url.AbsolutePath);
                 }
             }
             else
             {
                 Panel_TreeViTri.Visible = true;
             }
         }
         else
         {
             ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
             ucThongBaoLoi.Label_ThongBaoLoi.Text    = "Chưa có phòng";
         }
     }
     else
     {
         ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
         ucThongBaoLoi.Label_ThongBaoLoi.Text    = "Chưa có vị trí";
     }
 }