Exemple #1
0
        /// <summary>
        /// 查询已审核的检查数量
        /// </summary>
        /// <param name="us_id"></param>
        /// <returns></returns>
        public object MyVerifyOver(int us_id)
        {
            string sql = "select count(y_id) from yhtable " +
                         "where y_headuser = 2 and y_headtype = " + us_id + "";

            return(help.FirstRow(sql));
        }
Exemple #2
0
        /// <summary>
        /// 查询相关数据的数量
        /// </summary>
        /// <param name="data">两个值 value 搜索关键词  userInfo 登录用户的信息 {}</param>
        /// <param name="types">标识  1为只查询个人的 否则查询下属的</param>
        /// <param name="yh_send_state">隐患处理的状态</param>
        /// <returns></returns>
        public int QueryCount(dynamic data, int types, int yh_send_state)
        {
            JObject array = data.userInfo;
            string  value = data.value;

            string usersql = SQLWhere.UserSql(array);
            int    us_id   = Convert.ToInt32(array["us_id"]);


            string where = "where a.yh_id>0 ";
            if (value != "" && value != null)
            {
                where += " and a.yh_applicationName like '%" + value + "%' ";
            }
            if (types == 1)
            {//只查询我个人的信息
                where += " and a.yh_user_from=" + us_id + " ";
            }
            else  //查询我下属发布的信息
            {
                where += " and (a.yh_user_from in (" + usersql + ") or a.yh_queren_user in (" + usersql + ") ) ";
            }
            where += " and a.yh_send_state=" + yh_send_state + " ";

            string sql = "select count(a.yh_id) from yinhuan a " + where + " ";

            return(Convert.ToInt32(help.FirstRow(sql)));
        }
Exemple #3
0
        /// <summary>
        /// 查询文件列表信息
        /// </summary>
        /// <param name="value">搜索关键词</param>
        /// <param name="types">文件类型</param>
        /// <param name="page">当前页码</param>
        /// <param name="count">每页显示数量</param>
        /// <param name="filetype">文件类型 0 普通文件  1 三级教育文件</param>
        /// <param name="jibie">文件级别 0 未选择 1厂级  2 部门级 3 班组级</param>
        /// <returns></returns>
        public HttpResponseMessage Query(int head_id, string value, string types, int?filetype, int?jibie, int page, int count)
        {
            int p = (page - 1) * count + 1;
            int c = page * count;

            string where = "";
            if (value != "" && value != null)
            {
                where += " and title like '%" + value + "%' ";
            }
            if (types != "" && types != null)
            {
                where += " and types like '%" + types + "%' ";
            }
            if (filetype != null)
            {
                where += " and filetype=" + filetype + " ";
            }
            if (jibie != null)
            {
                where += " and jibie=" + jibie + " ";
            }
            string sqlc = "select count(id) from filelist where head_id=" + head_id + " " + where;

            string sql = "select * from ( " +
                         "select *,row_number() over(order by id desc) as row," +
                         "(select count(sid) from studenttime where sid = id) as lookcount, " +
                         "(select real_name from users where us_id=loaduser) as real_name " +
                         "from filelist where head_id=" + head_id + " " + where + "" +
                         ") temp " +
                         "where row between " + p + " and " + c + "";

            DataTable dt = help.Totable(sql);

            if (dt.Rows.Count > 0)
            {
                int noCount = (int)help.FirstRow(sqlc);
                obj = new
                {
                    code  = 0,
                    count = noCount,
                    data  = ConvertToEntity <Entity.studenttime> .Convert(dt)
                };
            }
            else
            {
                obj = new
                {
                    code = 1,
                    msg  = "无数据"
                };
            }
            return(Zh.Tool.Json.GetJson(obj));
        }
Exemple #4
0
        /// <summary>
        /// 添加集团信息  成功返回最新的集团ID
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public int AddHead(dynamic data)
        {
            Entity.user_detail d   = user.Value.SetData(data);
            string             sql = "insert into head_office(head_name,head_size,head_address,head_logo) values(" +
                                     "@head_name,@head_size,@head_address,@head_logo) select @@IDENTITY";

            SqlParameter[] sp =
            {
                new SqlParameter("@head_name", d.head_name)
                ,                              new SqlParameter("@head_size", d.head_size)
                ,                              new SqlParameter("@head_address", d.head_address)
                ,                              new SqlParameter("@head_logo", d.head_logo)
            };
            return(Convert.ToInt32(help.FirstRow(sql, sp)));
        }
Exemple #5
0
        /// <summary>
        /// 查询部门下所有班级的信息及班组人员数量
        /// </summary>
        /// <param name="b_id"></param>
        /// <returns></returns>
        public HttpResponseMessage QueryClasses(int b_id)
        {
            string    csql = "select count(c_id) from classes where b_id=" + b_id;
            int       i    = Convert.ToInt32(help.FirstRow(csql));
            string    sql  = "select a.*,(select count(c_id) from user_detail where b_id=a.b_id) as count from classes a where b_id=" + b_id;
            DataTable dt   = help.Totable(sql);
            List <Entity.user_detail> list = ConvertToEntity <Entity.user_detail> .Convert(dt);

            obj = new {
                code  = "A0000",
                count = i,
                data  = list
            };
            return(help.ToJson(obj));
        }
Exemple #6
0
        /// <summary>
        /// 添加或都修改用户的模块权限信息  如果用户权限存在,则修改
        /// </summary>
        /// <param name="data"></param>
        /// <param name="us_id"></param>
        /// <returns></returns>
        public HttpResponseMessage Add(dynamic data, int us_id)
        {
            //查询是否为该用户添加了页面模块信息
            string sql = "select count(id) from user_menu where us_id=" + us_id;

            if (Convert.ToInt32(help.FirstRow(sql)) > 0)
            {
                return(Update(data, us_id));
            }
            else
            {
                string menu = data.menu;
                sql = "insert into user_menu(us_id,menu) values(" + us_id + ",'" + menu + "')";
                if (help.Count(sql) > 0)
                {
                    obj = new
                    {
                        code = 0,
                        msg  = "ok"
                    };
                }
                else
                {
                    obj = new
                    {
                        code = 1,
                        msg  = "error"
                    };
                }
                return(Zh.Tool.Json.GetJson(obj));
            }
        }
Exemple #7
0
        /// <summary>
        /// 查询集团内部发部的题库总数量
        /// </summary>
        /// <param name="head_id"></param>
        /// <param name="count"></param>
        /// <returns>返回list<int>类型</returns>
        public List <int> QueryCount(int head_id, int count)
        {
            List <int> list      = new List <int>();
            string     sql       = "select count(*) from test_classify where head_id=" + head_id;
            object     objs      = help.FirstRow(sql);
            int        testCount = 0; //预定义查询到的题总数
            int        page      = 0; //预定义查询到了总页数

            if (objs != null)
            {
                testCount = Convert.ToInt32(objs);
                if (testCount % count > 0)
                {
                    page = Convert.ToInt32(testCount / count) + 1;
                }
                else
                {
                    page = testCount / count;
                }
            }
            else
            {
                testCount = 0;
                page      = 0;
            }
            list.Add(page);      //总页数据
            list.Add(testCount); //总数据量
            return(list);
        }
Exemple #8
0
        /// <summary>
        /// 用户登录方法  成功 返回用户的ID  不成功 返回0
        /// </summary>
        /// <param name="login_name"></param>
        /// <param name="login_pwd"></param>
        /// <returns></returns>
        public HttpResponseMessage userLogin(string login_name, string login_pwd, out int usid)
        {
            object obj = null;
            string sql = "select us_id from users where login_name=@login_name and login_pwd=@login_pwd";

            SqlParameter[] sp =
            {
                new SqlParameter("login_name", login_name),
                new SqlParameter("login_pwd",  login_pwd)
            };
            object userObj = help.FirstRow(sql, sp);

            if (userObj != null)
            {
                usid = Convert.ToInt32(userObj);
                List <Entity.user_detail> list = verify.Value.GetUserVal(usid);
                obj = new
                {
                    msg  = "ok",
                    code = "A0000",
                    data = list
                };
                //添加用户的登录日志
                Thread th = new Thread(new ParameterizedThreadStart(Login_Log));
                th.Start(usid);

                string s = JsonConvert.SerializeObject(obj);
                HttpResponseMessage m = new HttpResponseMessage();
                m.Content = new StringContent(s, System.Text.Encoding.GetEncoding("UTF-8"), "application/json");
                return(m);
            }
            else
            {
                obj = new
                {
                    msg  = "该用户不存在!",
                    code = "A0001"
                };
                string s = JsonConvert.SerializeObject(obj);
                HttpResponseMessage m = new HttpResponseMessage();
                m.Content = new StringContent(s, System.Text.Encoding.GetEncoding("UTF-8"), "application/json");
                usid      = 0;
                return(m);
            }
        }
Exemple #9
0
        /// <summary>
        /// 生成自动编号
        /// </summary>
        /// <param name="y_headid"></param>
        /// <returns></returns>
        public string SetNo(int y_headid)
        {
            string sql = "select top 1 y_id from yhtable where y_headid=" + y_headid + " order by y_id desc";
            int    no  = 0;

            if (sql != null)
            {
                no = Convert.ToInt32(help.FirstRow(sql)) + 1;
            }
            else
            {
                no = 1;
            }
            string hsql  = "select head_no from head_office where head_id=" + y_headid;
            string nos   = help.FirstRow(hsql).ToString();
            string newno = "";

            if (no < 10 && no > 0)
            {
                newno = "000" + no;
            }
            if (no < 100 && no > 9)
            {
                newno = "00" + no;
            }
            if (no < 1000 && no > 99)
            {
                newno = "0" + no;
            }
            if (no > 999)
            {
                newno = no.ToString();
            }
            string y_no = nos + "-" + "HSEJC-" + newno;

            return(y_no);
        }