/// <summary>
        /// 获取已加入权限的用户和用户组
        /// 作者:章建国
        /// </summary>
        /// <param name="_fid">文件ID</param>
        /// <returns></returns>
        public JsonResult GetSelectedList(string _fid)
        {
            var limitlist = new tb_LimitBLL().GetModelList(" fileId = " + _fid);

            if (limitlist != null && limitlist.Count > 0)
            {
                BLL.PersonnelManage.T_tb_InPersonnel inpersonnelDAL = new BLL.PersonnelManage.T_tb_InPersonnel();
                BLL.Laboratory.T_tb_Laboratory       laboratoryDAL  = new BLL.Laboratory.T_tb_Laboratory();
                for (int i = 0; i < limitlist.Count; i++)
                {
                    if (limitlist[i].limitType.Equals("用户"))
                    {
                        limitlist[i].limitType = inpersonnelDAL.GetModel(Convert.ToInt32(limitlist[i].limitId)).PersonnelName;
                    }
                    else if (limitlist[i].limitType.Equals("用户组"))
                    {
                        limitlist[i].limitType = laboratoryDAL.GetModel(Convert.ToInt32(limitlist[i].limitId)).LaboratoryName;
                    }
                    continue;
                }
            }
            return(Json(limitlist, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        /// <summary>
        /// 导出药品入库
        /// 作者:章建国
        /// </summary>
        /// <returns></returns>
        public FileResult Export_Sample(string _search, string _searchtype, int _companyid)
        {
            DataTable dt = new DataTable();

            System.IO.MemoryStream stream = new MemoryStream();
            try
            {
                string where = " 1=1 ";
                switch (_searchtype)
                {
                case "样品名称":
                    where += string.Format(" and name like '%%{0}%%' ", _search);
                    break;

                case "样品人":
                    where += string.Format(" and detectionUser like '%%{0}%%' ", _search);
                    break;

                case "抽样日期":
                    var times = _search.Split(',');
                    where += string.Format(" and detectionDate >= '{0}' and  detectionDate <= '{1}' ", times[0], times[1]);
                    break;
                }

                if (_companyid > 0)
                {
                    where += string.Format(" and createUser in (select PersonnelID from tb_InPersonnel where AreaID = {0}) ", _companyid);
                }
                else
                {
                    if (CurrentUserInfo.AreaID > 0 && CurrentUserInfo.DataRange == 3)
                    {
                        int _userid = CurrentUserInfo.PersonnelID;
                        where += string.Format(" and  CreateUser = (select PersonnelID from tb_InPersonnel where AreaID = {0} and PersonnelID = {1}) ", CurrentUserInfo.AreaID, _userid);
                    }
                    else if (CurrentUserInfo.AreaID > 0 && CurrentUserInfo.DataRange == 2)
                    {
                        int _userid = CurrentUserInfo.PersonnelID;
                        where += string.Format(" and createUser in (select PersonnelID from tb_InPersonnel where AreaID = {0}) ", CurrentUserInfo.AreaID);
                    }
                }

                dt = _samplebll.GetList(where).Tables[0];
                BLL.PersonnelManage.T_tb_InPersonnel inpersonnel  = new BLL.PersonnelManage.T_tb_InPersonnel();
                BLL.ClientManage.T_tb_ClientManage   clientManage = new BLL.ClientManage.T_tb_ClientManage();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    try
                    {
                        int userid = Convert.ToInt32(dt.Rows[i]["handleUser"]);
                        dt.Rows[i]["handleUser"] = inpersonnel.GetModel(userid).PersonnelName;
                    }
                    catch
                    {
                    }
                    try
                    {
                        int InspectCompany = Convert.ToInt32(dt.Rows[i]["InspectCompany"]);
                        dt.Rows[i]["InspectCompany"] = clientManage.GetModel(InspectCompany).ClientName;
                    }
                    catch
                    {
                    }
                }
                stream = PublicClass.ExportSampleToExcel(dt);
            }
            catch { }
            string filename = "样品列表" + DateTime.Now.ToFileTime() + ".xls";

            return(File(stream, "application/vnd.ms-excel", filename));
        }
Exemple #3
0
        /// <summary>
        /// 获取所有数据列表
        /// 作者:章建国
        /// </summary>
        /// <returns>将DataTable转换为Json数据格式通过string类型返回</returns>
        public string GetSampleList(int pageNumber, int pageSize, string _searchtext, string _searchtype, int _cid)
        {
            DataTable dt    = new DataTable();
            int       total = 0;

            try
            {
                string where = " 1=1 ";
                switch (_searchtype)
                {
                case "样品名称":
                    where += string.Format(" and name like '%%{0}%%' ", _searchtext);
                    break;

                case "样品人":
                    where += string.Format(" and detectionUser like '%%{0}%%' ", _searchtext);
                    break;

                case "抽样日期":
                    var times = _searchtext.Split(',');
                    where += string.Format(" and detectionDate >= '{0}' and  detectionDate <= '{1}' ", times[0], times[1]);
                    break;
                }

                if (_cid > 0)
                {
                    where += string.Format(" and createUser in (select PersonnelID from tb_InPersonnel where AreaID = {0}) ", _cid);
                }
                else
                {
                    if (CurrentUserInfo.AreaID > 0 && CurrentUserInfo.DataRange == 3)
                    {
                        int _userid = CurrentUserInfo.PersonnelID;
                        where += string.Format(" and  CreateUser = (select PersonnelID from tb_InPersonnel where AreaID = {0} and PersonnelID = {1}) ", CurrentUserInfo.AreaID, _userid);
                    }
                    else if (CurrentUserInfo.AreaID > 0 && CurrentUserInfo.DataRange == 2)
                    {
                        int _userid = CurrentUserInfo.PersonnelID;
                        where += string.Format(" and createUser in (select PersonnelID from tb_InPersonnel where AreaID = {0}) ", CurrentUserInfo.AreaID);
                    }
                }

                dt = _samplebll.GetListByPage(where, "createDate desc", pageNumber * pageSize - (pageSize - 1), pageNumber * pageSize).Tables[0];
                BLL.PersonnelManage.T_tb_InPersonnel inpersonnel  = new BLL.PersonnelManage.T_tb_InPersonnel();
                BLL.ClientManage.T_tb_ClientManage   clientManage = new BLL.ClientManage.T_tb_ClientManage();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    try
                    {
                        int userid = Convert.ToInt32(dt.Rows[i]["handleUser"]);
                        dt.Rows[i]["handleUser"] = inpersonnel.GetModel(userid).PersonnelName;
                    }
                    catch
                    {
                    }
                    try
                    {
                        int InspectCompany = Convert.ToInt32(dt.Rows[i]["InspectCompany"]);
                        dt.Rows[i]["InspectCompany"] = clientManage.GetModel(InspectCompany).ClientName;
                    }
                    catch
                    {
                    }
                }
                total = dt.Rows.Count;
                total = _samplebll.GetModelList(where).Count;
            }
            catch { }
            return(PublicClass.ToJson(dt, total));
        }