Пример #1
0
        /// <summary>
        /// 获取下拉框数据
        /// 作者:章建国
        /// </summary>
        /// <returns></returns>
        public static SelectList GetDropDownList(int id, string firstItem)
        {
            tb_BaseBLL            _basebll = new tb_BaseBLL();
            List <SelectListItem> list     = new List <SelectListItem>();

            try
            {
                list.Add(new SelectListItem()
                {
                    Text = firstItem, Value = "-1", Selected = true
                });
                foreach (var item in _basebll.GetModelList(" pId = " + id))
                {
                    list.Add(new SelectListItem()
                    {
                        Text = item.baseName, Value = item.id.ToString()
                    });
                }
            }
            catch
            {
            }
            return(new SelectList(list, "Value", "Text"));
        }
Пример #2
0
        /// <summary>
        /// 获取所有数据列表
        /// 作者:章建国
        /// </summary>
        /// <returns>将DataTable转换为Json数据格式通过string类型返回</returns>
        public string GetBorrwList(int pageNumber, int pageSize, string _search, string _searchtype, int _cid)
        {
            DataTable dt    = new DataTable();
            int       total = 0;

            try
            {
                string where = " 1 = 1";
                if (!string.IsNullOrEmpty(_search))
                {
                    switch (_searchtype)
                    {
                    case "bianhao":
                        where = " code like '%%" + _search + "%%'";
                        break;

                    case "mingchen":
                        where = " bookName like '%%" + _search + "%%'";
                        break;

                    case "zhongshu":
                        var zhongshujihe = _basebll.GetModelList(" where pId = 10");
                        if (zhongshujihe != null && zhongshujihe.Count > 0)
                        {
                            zhongshujihe = zhongshujihe.Where(w => w.baseName.Contains(_search)).ToList();
                            where        = " type1 = " + zhongshujihe.First().id;
                        }
                        break;

                    case "leibie":
                        var leibiejihe = _basebll.GetModelList(" where pId = 13");
                        if (leibiejihe != null && leibiejihe.Count > 0)
                        {
                            leibiejihe = leibiejihe.Where(w => w.baseName.Contains(_search)).ToList();
                            where      = " type2 = " + leibiejihe.First().id;
                        }
                        break;

                    case "zuozhe":
                        where = " author like '%%" + _search + "%%'";
                        break;

                    case "zhuangtai":
                        var zhuangtaijihe = _basebll.GetModelList(" where pId = 13");
                        if (zhuangtaijihe != null && zhuangtaijihe.Count > 0)
                        {
                            zhuangtaijihe = zhuangtaijihe.Where(w => w.baseName.Contains(_search)).ToList();
                            where         = " status = " + zhuangtaijihe.First().id;
                        }
                        break;

                    case "chubanshe":
                        where = " press like '%%" + _search + "%%'";
                        break;

                    case "jieyueren":
                        where = " name like '%%" + _search + "%%'";
                        break;

                    case "jieyueriqi":
                        where = string.Format(" and convert(char(8), borrowDate, 112) like '%%{0}%%'", _search);
                        break;

                    case "guihuanriqi":
                        where = string.Format(" and convert(char(8), backDate, 112) like '%%{0}%%'", _search);
                        break;
                    }
                }
                if (_cid > 0 && CurrentUserInfo.DataRange == 3)
                {
                    int _userid = CurrentUserInfo.PersonnelID;
                    where += string.Format(" and  CreateUser = (select PersonnelID from tb_InPersonnel where AreaID = {0} and PersonnelID = {1}) ", _cid, _userid);
                }
                else if (_cid > 0 && CurrentUserInfo.DataRange == 2)
                {
                    int _userid = CurrentUserInfo.PersonnelID;
                    where += string.Format(" and CreateUser in (select PersonnelID from tb_InPersonnel where AreaID = {0}) ", _cid);
                }
                dt    = _bookborrowbll.GetListByPage(where, "updateDate", pageNumber * pageSize - (pageSize - 1), pageNumber * pageSize).Tables[0];
                total = dt.Rows.Count;
                total = _bookborrowbll.GetModelList(where).Count;
            }
            catch { }
            return(PublicClass.ToJson(dt, total));
        }