protected string ViTriCuaPhong(TSCD.Entities.Phong objPhong)
        {
            string _strtemp = "", _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(""))
            {
                _strtemp += _strCoSo;
                if (!_strDay.Equals(""))
                {
                    _strtemp += " - " + _strDay;
                    if (!_strTang.Equals(""))
                    {
                        _strtemp += " - " + _strTang;
                    }
                }
            }
            return(_strtemp == "" ? "[Không rõ]" : _strtemp);
        }
        public void LoadData()
        {
            listPhong = TSCD.Entities.Phong.getAll();
            if (listPhong.Count > 0)
            {
                infotr.Visible = true;
                listViTriHienThi = ViTriHienThi.getAll();
                if (listViTriHienThi.Count > 0)
                {
                    _ucTreeViTri.CreateTreeList();
                    _ucTreeViTri.ASPxTreeList_ViTri.DataSource = listViTriHienThi;
                    _ucTreeViTri.ASPxTreeList_ViTri.DataBind();
                    SearchFunction();
                    if (Convert.ToString(Page.Session["ShowInfo"]) == "1")
                    {
                        PanelChangePage.Visible = false;
                        Session["ShowInfo"] = null;
                    }
                    else
                    {
                        _ucCollectionPager_DanhSachPhong.ShowPanelPage(PanelChangePage);
                    }
                    if (Request.QueryString["key"] != null)
                    {
                        infotd.Visible = true;
                        string key = "";
                        try
                        {
                            key = Request.QueryString["key"].ToString();
                        }
                        catch
                        {
                            Response.Redirect(Request.Url.AbsolutePath);
                        }

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

                            objPhong = TSCD.Entities.Phong.getById(idPhong);
                            if (objPhong != null)
                            {
                                Label_ThongTinPhong.Text = "Thông tin phòng " + objPhong.ten;
                                Label_MaPhong.Text = objPhong.subId;
                                ucPhong_BreadCrumb.Label_TenPhong.Text = Label_TenPhong.Text = objPhong.ten;
                                Label_LoaiPhong.Text = objPhong.loaiphong.ten;
                                Label_ViTriPhong.Text = ViTriCuaPhong(objPhong);
                                Label_MoTaPhong.Text = StringHelper.ConvertRNToBR(objPhong.mota);
                            }
                            else
                            {
                                Response.Redirect(Request.Url.AbsolutePath);
                            }
                        }
                        else
                        {
                            ClearData();
                        }
                    }
                    else
                    {
                        DevExpress.Web.ASPxTreeList.TreeListNode node = _ucTreeViTri.ASPxTreeList_ViTri.FindNodeByKeyValue("");
                        node.Focus();
                        ChuaChonViTri.Visible = true;
                        ucWarning_ChuaChonViTri.LabelInfo.Text = "Chưa chọn vị trí";
                        ClearData();
                    }
                }
                else
                {
                    KhongCoDuLieu.Visible = true;
                    ucDanger_KhongCoDuLieu.LabelInfo.Text = "Chưa có phòng";
                }
            }
            else
            {
                KhongCoDuLieu.Visible = true;
                ucDanger_KhongCoDuLieu.LabelInfo.Text = "Chưa có phòng";
            }
        }
 public void LoadData()
 {
     listPhong = TSCD.Entities.Phong.getAll();
     if (listPhong.Count > 0)
     {
         TreeViTri.Visible = true;
         listViTriHienThi = ViTriHienThi.getAll();
         if (listViTriHienThi.Count > 0)
         {
             ucTreeViTri.CreateTreeList();
             ucTreeViTri.ASPxTreeList_ViTri.DataSource = listViTriHienThi;
             ucTreeViTri.ASPxTreeList_ViTri.DataBind();
             SearchFunction();
             if (Request.QueryString["key"] != null)
             {
                 DanhSach.Visible = true;
                 TreeViTri.Visible = false;
                 key = "";
                 try
                 {
                     key = Request.QueryString["key"].ToString();
                 }
                 catch
                 {
                     Response.Redirect(Request.Url.AbsolutePath);
                 }
                 DevExpress.Web.ASPxTreeList.TreeListNode node = ucTreeViTri.ASPxTreeList_ViTri.FindNodeByKeyValue(key);
                 if (node != null)
                 {
                     string strViTri = "";
                     DevExpress.Web.ASPxTreeList.TreeListNode Pnode = node.ParentNode;
                     while (!Object.Equals(Pnode.Key, ""))
                     {
                         strViTri = " - " + Pnode.GetValue("ten").ToString() + strViTri;
                         Pnode = Pnode.ParentNode;
                     }
                     if (!Object.Equals(strViTri, ""))
                     {
                         strViTri = string.Format("({0})", strViTri.Substring(3));
                         ucPhong_BreadCrumb.Label_TenViTri.Text = node.GetValue("ten").ToString() + " " + strViTri;
                     }
                     else
                         ucPhong_BreadCrumb.Label_TenViTri.Text = node.GetValue("ten").ToString();
                     if (Request.QueryString["id"] != null)
                     {
                         ThongTin.Visible = true;
                         idPhong = Guid.Empty;
                         try
                         {
                             idPhong = GUID.From(Request.QueryString["id"]);
                         }
                         catch
                         {
                             Response.Redirect(Request.Url.AbsolutePath);
                         }
                         objPhong = TSCD.Entities.Phong.getById(idPhong);
                         if (objPhong != null)
                         {
                             ucPhong_BreadCrumb.Label_TenPhong.Text = objPhong.ten;
                             Label_MaPhong.Text = objPhong.subId;
                             Label_TenPhong.Text = objPhong.ten;
                             Label_LoaiPhong.Text = objPhong.loaiphong.ten;
                             Label_ViTriPhong.Text = ViTriCuaPhong(objPhong);
                             Label_MoTaPhong.Text = StringHelper.ConvertRNToBR(objPhong.mota);
                         }
                         else
                         {
                             Response.Redirect(Request.Url.AbsolutePath);
                         }
                     }
                     LoadDanhSachPhong(GUID.From(node.GetValue("id")), node.GetValue("loai").ToString());
                 }
                 else
                     Response.Redirect(Request.Url.AbsolutePath);
             }
             else
             {
                 DevExpress.Web.ASPxTreeList.TreeListNode node = ucTreeViTri.ASPxTreeList_ViTri.FindNodeByKeyValue("");
                 node.Focus();
             }
         }
         else
         {
             KhongCoDuLieu.Visible = true;
             ucDanger_KhongCoDuLieu.LabelInfo.Text = "Chưa có phòng";
         }
     }
     else
     {
         KhongCoDuLieu.Visible = true;
         ucDanger_KhongCoDuLieu.LabelInfo.Text = "Chưa có phòng";
     }
 }
Example #4
0
        /// <summary>
        /// Chuyển đổi đơn vị quản lý, nhung KHÔNG cho phép kèm tình trạng,
        /// chuyển tình trạng dùng hàm riêng
        /// </summary>
        /// <param name="quanly_moi"></param>
        /// <param name="sudung_moi"></param>
        /// <param name="vitri_moi"></param>
        /// <param name="phong_moi"></param>
        /// <param name="chungtu_ngay_moi"></param>
        /// <param name="chungtu_sohieu_moi"></param>
        /// <param name="soluong_moi"></param>
        /// <param name="ghichu_moi"></param>
        /// <param name="ngay_moi"></param>
        /// <returns></returns>
        public CTTaiSan chuyenDonVi(
            DonVi donviquanly_moi,
            DonVi donvisudung_moi,
            ViTri vitri_moi,
            Phong phong_moi,
            CTTaiSan cttaisan_parent_moi,
            ChungTu chungtu_moi,
            int soluong_moi   = -1,
            String ghichu_moi = "",
            DateTime?ngay_moi = null)
        {
            Boolean re = true;

            //Kiem tra rang buoc
            //So luong chuyen phai hop le
            if (soluong_moi > this.soluong)
            {
                return(null);
            }
            //tự chuyển đổi
            if (soluong_moi < 0)
            {
                soluong_moi = this.soluong;
            }
            CTTaiSan final = null;
            //begin business
            Boolean cungdonviquanly = donviquanly != null && donviquanly_moi != null && donviquanly.id == donviquanly_moi.id;

            #region Chuyển toàn bộ
            //Chuyen toan bo
            if (soluong_moi <= 0 || soluong_moi == this.soluong)
            {
                //cung don vi quan ly
                if (cungdonviquanly)
                {
                    //chi update lai this
                    this.chungtu     = chungtu_moi;
                    this.donvisudung = donvisudung_moi;
                    this.ghichu      = ghichu_moi;
                    this.ngay        = ngay_moi;
                    this.parent      = cttaisan_parent_moi;
                    this.phong       = phong_moi;
                    this.vitri       = vitri_moi;
                    re = re && this.update() > 0;

                    final = this;
                }
                //khac don vi quan ly
                else
                {
                    //Step 1: Tao CTTS moi -> add
                    CTTaiSan ctts = new CTTaiSan();
                    ctts.chungtu     = chungtu_moi;
                    ctts.donviquanly = donviquanly_moi;
                    ctts.donvisudung = donvisudung_moi;
                    ctts.ghichu      = ghichu_moi;
                    ctts.mota        = this.mota;
                    ctts.ngay        = ngay_moi;
                    ctts.nguongoc    = "[Hệ thống tự động tạo: chuyển từ " + (this.donviquanly == null ? "(null)" : this.donviquanly.niceName()) + " sang " + (donviquanly_moi == null ? "(null)" : donviquanly_moi.niceName()) + "]";
                    ctts.parent      = cttaisan_parent_moi;
                    ctts.phong       = phong_moi;
                    ctts.soluong     = this.soluong;
                    ctts.subId       = this.subId;
                    ctts.taisan      = this.taisan;
                    ctts.tinhtrang   = this.tinhtrang;
                    ctts.vitri       = vitri_moi;
                    re = re && ctts.add_khongGhiLogTangGiam() > 0;
                    //Step 2: ghi log tang tai san cho ctts moi them
                    LogTangGiamTaiSan log = ctts.generateLogTangGiamTaiSan();
                    log.tang_giam          = 0;
                    log.tang_giam_donvi    = 1;
                    log.chuyenden_chuyendi = 1;
                    re = re && log.add() > 0;
                    //Step 3: Update lai soluong cho this=0 -> update
                    this.chungtu  = chungtu_moi;
                    this.ghichu   = ghichu_moi;
                    this.soluong  = 0;
                    this.nguongoc = ctts.nguongoc;
                    re            = re && this.update() > 0;
                    //Step 4: ghi nhan su giam cho this
                    LogTangGiamTaiSan log2 = this.generateLogTangGiamTaiSan();
                    log2.soluong            = soluong_moi;//importance!!!không dùng this.soluong
                    log2.tang_giam          = 0;
                    log2.tang_giam_donvi    = -1;
                    log2.chuyenden_chuyendi = -1;
                    re = re && log2.add() > 0;

                    final = ctts;
                }
                //end
                return(final);// re ? 1 : -1;
            }
            #endregion
            #region Chuyển 1 phần số lượng
            else
            //Chuyen 1 phan so luong
            {
                CTTaiSan ctts = null;
                //cung don vi quan ly
                if (cungdonviquanly)
                {
                    //Tao CTTS moi
                    ctts             = new CTTaiSan();
                    ctts.chungtu     = chungtu_moi;
                    ctts.donvisudung = donvisudung_moi;
                    ctts.ghichu      = ghichu_moi;
                    ctts.mota        = this.mota;
                    ctts.ngay        = ngay_moi;
                    ctts.nguongoc    = "[Hệ thống tự động tạo: phân bổ nội " + (this.donviquanly == null ? "(null)" : this.donviquanly.niceName()) + "]";
                    ctts.parent      = cttaisan_parent_moi;
                    ctts.phong       = phong_moi;
                    ctts.soluong     = soluong_moi;//importance!!!
                    ctts.subId       = this.subId;
                    ctts.taisan      = this.taisan;
                    ctts.tinhtrang   = this.tinhtrang;
                    ctts.vitri       = vitri_moi;
                    ctts.add_khongGhiLogTangGiam();
                    //cap nhat lai soluong cho this
                    this.chungtu  = chungtu_moi;
                    this.ghichu   = ghichu_moi;
                    this.soluong -= soluong_moi;//importance!!!
                    this.nguongoc = nguongoc;
                    this.update();
                    //KHONG ghi log tang giam
                }
                //khac don vi quan ly
                else
                {
                    //Step 1: Tao CTTS moi -> add
                    ctts             = new CTTaiSan();
                    ctts.chungtu     = chungtu_moi;
                    ctts.donviquanly = donviquanly_moi;
                    ctts.donvisudung = donvisudung_moi;
                    ctts.ghichu      = ghichu_moi;
                    ctts.mota        = this.mota;
                    ctts.ngay        = ngay_moi;
                    ctts.nguongoc    = "[Hệ thống tự động tạo: chuyển từ \"" + (this.donviquanly == null ? "null" : this.donviquanly.niceName()) + "\" sang \"" + (donviquanly_moi == null ? "null" : donviquanly_moi.niceName()) + "\"]";
                    ctts.parent      = cttaisan_parent_moi;
                    ctts.phong       = phong_moi;
                    ctts.soluong     = soluong_moi;//importance!!!
                    ctts.subId       = this.subId;
                    ctts.taisan      = this.taisan;
                    ctts.tinhtrang   = this.tinhtrang;
                    ctts.vitri       = vitri_moi;
                    ctts.add_khongGhiLogTangGiam();
                    //Step 2: ghi log tang tai san cho ctts moi them
                    LogTangGiamTaiSan log = ctts.generateLogTangGiamTaiSan();
                    log.tang_giam          = 0;
                    log.tang_giam_donvi    = 1;
                    log.chuyenden_chuyendi = 1;
                    log.add();
                    //Step 3: Update lai soluong cho this -> update
                    this.chungtu  = chungtu_moi;
                    this.soluong -= soluong_moi;//importance!!!
                    this.nguongoc = ctts.nguongoc;
                    this.ghichu   = ghichu_moi;
                    this.update();
                    //Step 4: ghi nhan su giam cho this
                    LogTangGiamTaiSan log2 = this.generateLogTangGiamTaiSan();
                    log2.soluong            = soluong_moi;//importance!!!Không dùng this.soluong
                    log2.tang_giam          = 0;
                    log2.tang_giam_donvi    = -1;
                    log2.chuyenden_chuyendi = -1;
                    log2.add();
                }

                final = ctts;
            }
            #endregion
            return(final);// re ? 1 : -1;
        }
 public void LoadData()
 {
     listPhong = TSCD.Entities.Phong.getAll();
     if (listPhong.Count > 0)
     {
         TreeViTri.Visible = true;
         listViTriHienThi  = ViTriHienThi.getAll();
         if (listViTriHienThi.Count > 0)
         {
             ucTreeViTri.CreateTreeList();
             ucTreeViTri.ASPxTreeList_ViTri.DataSource = listViTriHienThi;
             ucTreeViTri.ASPxTreeList_ViTri.DataBind();
             SearchFunction();
             if (Request.QueryString["key"] != null)
             {
                 DanhSach.Visible  = true;
                 TreeViTri.Visible = false;
                 key = "";
                 try
                 {
                     key = Request.QueryString["key"].ToString();
                 }
                 catch
                 {
                     Response.Redirect(Request.Url.AbsolutePath);
                 }
                 DevExpress.Web.ASPxTreeList.TreeListNode node = ucTreeViTri.ASPxTreeList_ViTri.FindNodeByKeyValue(key);
                 if (node != null)
                 {
                     string strViTri = "";
                     DevExpress.Web.ASPxTreeList.TreeListNode Pnode = node.ParentNode;
                     while (!Object.Equals(Pnode.Key, ""))
                     {
                         strViTri = " - " + Pnode.GetValue("ten").ToString() + strViTri;
                         Pnode    = Pnode.ParentNode;
                     }
                     if (!Object.Equals(strViTri, ""))
                     {
                         strViTri = string.Format("({0})", strViTri.Substring(3));
                         ucPhong_BreadCrumb.Label_TenViTri.Text = node.GetValue("ten").ToString() + " " + strViTri;
                     }
                     else
                     {
                         ucPhong_BreadCrumb.Label_TenViTri.Text = node.GetValue("ten").ToString();
                     }
                     if (Request.QueryString["id"] != null)
                     {
                         ThongTin.Visible = true;
                         idPhong          = Guid.Empty;
                         try
                         {
                             idPhong = GUID.From(Request.QueryString["id"]);
                         }
                         catch
                         {
                             Response.Redirect(Request.Url.AbsolutePath);
                         }
                         objPhong = TSCD.Entities.Phong.getById(idPhong);
                         if (objPhong != null)
                         {
                             ucPhong_BreadCrumb.Label_TenPhong.Text = objPhong.ten;
                             Label_MaPhong.Text    = objPhong.subId;
                             Label_TenPhong.Text   = objPhong.ten;
                             Label_LoaiPhong.Text  = objPhong.loaiphong.ten;
                             Label_ViTriPhong.Text = ViTriCuaPhong(objPhong);
                             Label_MoTaPhong.Text  = StringHelper.ConvertRNToBR(objPhong.mota);
                         }
                         else
                         {
                             Response.Redirect(Request.Url.AbsolutePath);
                         }
                     }
                     LoadDanhSachPhong(GUID.From(node.GetValue("id")), node.GetValue("loai").ToString());
                 }
                 else
                 {
                     Response.Redirect(Request.Url.AbsolutePath);
                 }
             }
             else
             {
                 DevExpress.Web.ASPxTreeList.TreeListNode node = ucTreeViTri.ASPxTreeList_ViTri.FindNodeByKeyValue("");
                 node.Focus();
             }
         }
         else
         {
             KhongCoDuLieu.Visible = true;
             ucDanger_KhongCoDuLieu.LabelInfo.Text = "Chưa có phòng";
         }
     }
     else
     {
         KhongCoDuLieu.Visible = true;
         ucDanger_KhongCoDuLieu.LabelInfo.Text = "Chưa có phòng";
     }
 }
 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);
         }
         TSCD.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()
        {
            listPhong = TSCD.Entities.Phong.getAll();
            if (listPhong.Count > 0)
            {
                infotr.Visible   = true;
                listViTriHienThi = ViTriHienThi.getAll();
                if (listViTriHienThi.Count > 0)
                {
                    _ucTreeViTri.CreateTreeList();
                    _ucTreeViTri.ASPxTreeList_ViTri.DataSource = listViTriHienThi;
                    _ucTreeViTri.ASPxTreeList_ViTri.DataBind();
                    SearchFunction();
                    if (Convert.ToString(Page.Session["ShowInfo"]) == "1")
                    {
                        PanelChangePage.Visible = false;
                        Session["ShowInfo"]     = null;
                    }
                    else
                    {
                        _ucCollectionPager_DanhSachPhong.ShowPanelPage(PanelChangePage);
                    }
                    if (Request.QueryString["key"] != null)
                    {
                        infotd.Visible = true;
                        string key = "";
                        try
                        {
                            key = Request.QueryString["key"].ToString();
                        }
                        catch
                        {
                            Response.Redirect(Request.Url.AbsolutePath);
                        }

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

                            objPhong = TSCD.Entities.Phong.getById(idPhong);
                            if (objPhong != null)
                            {
                                Label_ThongTinPhong.Text = "Thông tin phòng " + objPhong.ten;
                                Label_MaPhong.Text       = objPhong.subId;
                                ucPhong_BreadCrumb.Label_TenPhong.Text = Label_TenPhong.Text = objPhong.ten;
                                Label_LoaiPhong.Text  = objPhong.loaiphong.ten;
                                Label_ViTriPhong.Text = ViTriCuaPhong(objPhong);
                                Label_MoTaPhong.Text  = StringHelper.ConvertRNToBR(objPhong.mota);
                            }
                            else
                            {
                                Response.Redirect(Request.Url.AbsolutePath);
                            }
                        }
                        else
                        {
                            ClearData();
                        }
                    }
                    else
                    {
                        DevExpress.Web.ASPxTreeList.TreeListNode node = _ucTreeViTri.ASPxTreeList_ViTri.FindNodeByKeyValue("");
                        node.Focus();
                        ChuaChonViTri.Visible = true;
                        ucWarning_ChuaChonViTri.LabelInfo.Text = "Chưa chọn vị trí";
                        ClearData();
                    }
                }
                else
                {
                    KhongCoDuLieu.Visible = true;
                    ucDanger_KhongCoDuLieu.LabelInfo.Text = "Chưa có phòng";
                }
            }
            else
            {
                KhongCoDuLieu.Visible = true;
                ucDanger_KhongCoDuLieu.LabelInfo.Text = "Chưa có phòng";
            }
        }