Ejemplo n.º 1
0
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  BasicMethod
        #region  ExtensionMethod
        /// <summary>
        /// 获取未选择权限的用户列表
        /// 作者:章建国
        /// </summary>
        /// <param name="_fid"></param>
        /// <returns></returns>
        public DataTable GetUNSelectList(string _fid, int _userid)
        {
            try
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("userORgroup"));
                dt.Columns.Add(new DataColumn("id"));
                dt.Columns.Add(new DataColumn("limittype"));
                dt.Columns.Add(new DataColumn("areaid"));
                var limitList = GetModelList(" fileId = " + _fid);
                if (limitList != null && limitList.Count > 0)
                {
                    string userids = "";
                    string areaids = "";
                    foreach (var item in limitList)
                    {
                        switch (item.limitType)
                        {
                        case "用户":
                            userids += item.limitId + ",";

                            break;

                        case "用户组":
                            areaids += item.limitId + ",";

                            break;
                        }
                    }
                    userids = !string.IsNullOrEmpty(userids) ? " PersonnelID not in (" + userids.Substring(0, userids.Length - 1) + "," + _userid + ")" : "PersonnelID <> " + _userid;
                    areaids = !string.IsNullOrEmpty(areaids) ? " AreaID not in (" + areaids.Substring(0, areaids.Length - 1) + ")" : "";
                    var inpersonlist = new BLL.PersonnelManage.T_tb_InPersonnel().GetModelList(userids);
                    var areaList     = new BLL.RoleManage.T_tb_Area().GetModelList(areaids);
                    dt = GetUNSelectResultDataTable(dt, inpersonlist, areaList);
                }
                else
                {
                    var inpersonlist = new BLL.PersonnelManage.T_tb_InPersonnel().GetModelList(" PersonnelID <> " + _userid);
                    var areaList     = new BLL.RoleManage.T_tb_Area().GetModelList("");
                    dt = GetUNSelectResultDataTable(dt, inpersonlist, areaList);
                }
                return(dt);
            }
            catch
            {
                return(new DataTable());
            }
        }
Ejemplo n.º 2
0
        /// <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));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 获取所有数据列表
        /// 作者:章建国
        /// </summary>
        /// <returns>将DataTable转换为Json数据格式通过string类型返回</returns>
        public string GetEasyConsumeOUTList(int pageNumber, int pageSize, int _cid, string _searchtext, string _searchtype, string _datetype, string _txtdate)
        {
            DataTable dt    = new DataTable();
            int       total = 0;

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

                case "厂家与场地":
                    if (string.IsNullOrEmpty(_searchtext))
                    {
                        break;
                    }
                    where += string.Format(" and product like '%%{0}%%' ", _searchtext);
                    break;

                case "经手人":
                    if (string.IsNullOrEmpty(_searchtext))
                    {
                        break;
                    }
                    var    listperson = new BLL.PersonnelManage.T_tb_InPersonnel().GetModelList(" PersonnelName like '%%" + _searchtext + "%%'");
                    string personids  = "";
                    foreach (var item in listperson)
                    {
                        personids += item.PersonnelID + ",";
                    }
                    if (!string.IsNullOrEmpty(personids))
                    {
                        where += string.Format(" and user1 in({0}) ", personids.Substring(0, personids.Length - 1));
                    }
                    break;
                }
                switch (_datetype)
                {
                case "年":
                    if (string.IsNullOrEmpty(_txtdate))
                    {
                        break;
                    }
                    where += string.Format(" and year(createDate) ={0} ", _txtdate);
                    break;

                case "月":
                    if (string.IsNullOrEmpty(_txtdate))
                    {
                        break;
                    }
                    DateTime _dtime = DateTime.Parse("1949-10-01"); DateTime.TryParse(_txtdate, out _dtime);
                    where += _dtime.Year > 1949 ? string.Format(" and year(createDate) = {0} and month(createDate) = {1} ", _dtime.Year, _dtime.Month) : "";
                    break;
                }
                if (CurrentUserInfo.DataRange == 3)
                {
                    int _userid = CurrentUserInfo.PersonnelID;
                    where += string.Format(" and  T.CreateUser = (select PersonnelID from tb_InPersonnel where AreaID = {0} and PersonnelID = {1}) ", CurrentUserInfo.AreaID.Value, _userid);
                }
                else if (_cid > 0 || CurrentUserInfo.DataRange == 2)
                {
                    int _userid = CurrentUserInfo.PersonnelID;
                    where += string.Format(" and T.createUser in (select PersonnelID from tb_InPersonnel where AreaID = {0}) ", _cid);
                }
                dt = _easyconsumeoutbll.GetListByPage(where, "updateDate desc", pageNumber * pageSize - (pageSize - 1), pageNumber * pageSize).Tables[0];
                //dt.Columns.Add("name");
                //dt.Columns.Add("type");
                //dt.Columns.Add("danwei");
                //dt.Columns.Add("PersonnelName");

                //for (int i = 0; i < dt.Rows.Count; i++)
                //{
                //    DataRow dr = dt.Rows[i];
                //    int eid = Convert.ToInt32(dr["eId"]);
                //    tb_EasyConsume _easyconsume = _easyconsumebll.GetModel(eid);
                //    dt.Rows[i]["name"] = _easyconsume.name;
                //    dt.Rows[i]["type"] = _easyconsume.type;
                //    dt.Rows[i]["danwei"] = new tb_BaseBLL().GetModel(_easyconsume.unit.Value).baseName;
                //    dt.Rows[i]["PersonnelName"] = new BLL.PersonnelManage.T_tb_InPersonnel().GetModel(Convert.ToInt32(dr["user1"])).PersonnelName;
                //}
                total = dt.Rows.Count;
                total = _easyconsumeoutbll.GetEasyConsumeOUTCount(where);
            }
            catch { }
            return(PublicClass.ToJson(dt, total));
        }