コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Guid id = GUID.From(Request.QueryString["id"]);
                switch (Request.QueryString["TYPE"])
                {
                case "SUCOPHONG":
                    PTB.Entities.SuCoPhong objSuCoPhong = PTB.Entities.SuCoPhong.getById(id);
                    Libraries.ImageHelper.LoadImageWeb(objSuCoPhong.hinhanhs != null ? objSuCoPhong.hinhanhs.ToList() : null, ASPxImageSlider);
                    break;

                case "NHANVIEN":
                    PTB.Entities.NhanVienPT objNhanVienPT = PTB.Entities.NhanVienPT.getById(id);
                    Libraries.ImageHelper.LoadImageWeb(objNhanVienPT.hinhanhs != null ? objNhanVienPT.hinhanhs.ToList() : null, ASPxImageSlider);
                    break;

                case "PHONG":
                    PTB.Entities.Phong objPhong = PTB.Entities.Phong.getById(id);
                    Libraries.ImageHelper.LoadImageWeb(objPhong.hinhanhs != null ? objPhong.hinhanhs.ToList() : null, ASPxImageSlider);
                    break;

                case "THIETBI":
                    PTB.Entities.ThietBi objThietBi = PTB.Entities.ThietBi.getById(id);
                    Libraries.ImageHelper.LoadImageWeb(objThietBi.hinhanhs != null ? objThietBi.hinhanhs.ToList() : null, ASPxImageSlider);
                    break;

                case "COSO":
                    PTB.Entities.CoSo objCoSo = PTB.Entities.CoSo.getById(id);
                    Libraries.ImageHelper.LoadImageWeb(objCoSo.hinhanhs != null ? objCoSo.hinhanhs.ToList() : null, ASPxImageSlider);
                    break;

                case "DAY":
                    PTB.Entities.Dayy objDay = PTB.Entities.Dayy.getById(id);
                    Libraries.ImageHelper.LoadImageWeb(objDay.hinhanhs != null ? objDay.hinhanhs.ToList() : null, ASPxImageSlider);
                    break;

                case "TANG":
                    PTB.Entities.Tang objTang = PTB.Entities.Tang.getById(id);
                    Libraries.ImageHelper.LoadImageWeb(objTang.hinhanhs != null ? objTang.hinhanhs.ToList() : null, ASPxImageSlider);
                    break;
                }
            }
            catch (Exception ex)
            {
                Response.Redirect("Default.aspx");
                Console.Write(ex);
            }
        }
コード例 #2
0
        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)
                    {
                        ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
                        ucThongBaoLoi.Label_ThongBaoLoi.Text    = string.Format("Thiết bị {0} không có log", objThietBi.ten);
                    }
                    else
                    {
                        if (Request.QueryString["idLog"] != null)
                        {
                            Guid idLog = Guid.Empty;
                            try
                            {
                                idLog = GUID.From(Request.QueryString["idLog"]);
                            }
                            catch
                            {
                                Response.Redirect(Request.Url.AbsolutePath);
                            }
                            objLogThietBi = listLogThietBi.Where(item => item.id == idLog).FirstOrDefault();
                            if (objLogThietBi != null)
                            {
                                Panel_ThongTinLog.Visible = true;
                                _ucLogThietBi_BreadCrumb.Label_TenThietBi.Text = objThietBi.ten;
                                _ucLogThietBi_BreadCrumb.Label_LogNgay.Text    = ((DateTime)objLogThietBi.date_create).ToString("d/M/yyyy");
                                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_Mobile.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
                            {
                                Response.Redirect("~/");
                            }
                        }
                        else
                        {
                            Panel_DanhSachLog.Visible = true;
                            _ucLogThietBi_BreadCrumb.Label_TenThietBi.Text = objThietBi.ten;
                            Label_LogThietBi.Text = string.Format("Log của {0}", objThietBi.ten);
                            //var bind = listLogThietBi.Select(a => new
                            //{
                            //    id = a.id,
                            //    tinhtrang = a.tinhtrang.value,
                            //    soluong = a.soluong,
                            //    phong = a.phong.ten,
                            //    ngay = a.date_create,
                            //    url = Libraries.StringHelper.AddParameter(new Uri(Request.Url.AbsoluteUri), "idLog", a.id.ToString())
                            //}).OrderBy(item => item.ngay).ToList();
                            //_ucCollectionPager_DanhSachLogThietBi.CollectionPager_Object.DataSource = bind;
                            //_ucCollectionPager_DanhSachLogThietBi.CollectionPager_Object.BindToControl = RepeaterDanhSachLogThietBi;
                            //RepeaterDanhSachLogThietBi.DataSource = _ucCollectionPager_DanhSachLogThietBi.CollectionPager_Object.DataSourcePaged;
                        }
                    }
                }
                else
                {
                    if (Request.UrlReferrer == null)
                    {
                        Response.Redirect("~/");
                    }
                    else
                    {
                        ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true;
                        ucThongBaoLoi.Label_ThongBaoLoi.Text    = "Không có thiết bị này";
                    }
                }
            }
            else
            {
                Response.Redirect("~/");
            }
        }