/*
         * 用户验证
         * */
        public JsonResult LoginValidate(string userName)
        {
            OleDbConnection mycn = buildConn();
            mycn.Open();
            string condition = " and username = '******'";
            OleDbCommand mycm = null;
            OleDbDataReader msdr = null;
            if (string.IsNullOrEmpty(userName)) {
                return Json(new { success = false, msg = "用户未登陆" }, JsonRequestBehavior.AllowGet);
            }
            try
            {
                string sql = "select * from sys_user where 1=1 " + condition;
                mycm = new OleDbCommand(sql, mycn);
                msdr = mycm.ExecuteReader();

                if (msdr.HasRows)
                {
                    while (msdr.Read())
                    {
                        if ((string)Session["user"] != (string)msdr["username"])
                        {
                            msdr.Close();
                            mycn.Close();
                            return Json(new { success = false, msg = "用户未登陆" }, JsonRequestBehavior.AllowGet);
                        }
                        else
                        {
                            User u = new User();
                            u.id = (int)msdr["id"];
                            u.username = (string)msdr["username"];
                            u.password = (string)msdr["password"];
                            u.cnName = (string)msdr["cn_name"];
                            u.status = (string)msdr["status"];
                            u.picUrl = (string)msdr["pic_url"];
                            u.dimensionalCodeUrl = (string)msdr["dimensional_code_url"];
                            u.type = msdr.GetString(12);
                            msdr.Close();
                            mycn.Close();
                            return Json(new { result = u, success = true, msg = "成功" }, JsonRequestBehavior.AllowGet);
                        }
                    }
                }
                else
                {
                    msdr.Close();
                    mycn.Close();
                    return Json(new { success = false, msg = "用户不存在" }, JsonRequestBehavior.AllowGet);
                }
            }
            catch
            {
                msdr.Close();
                mycn.Close();
                return Json(new { success = false, msg = "未知错误" }, JsonRequestBehavior.AllowGet);
            }
            finally
            {
                msdr.Close();
                mycn.Close();
            }

            return Json(new { success = true,msg = "未知错误"  }, JsonRequestBehavior.AllowGet);
        }
        /*
         * 用户列表*/
        public JsonResult UserListGet(string username, string cnName, string type, string email)
        {
            /*
            if (isNullSession())
            {
                return Json(new { data = "Session为空,请重新登陆", success = false }, JsonRequestBehavior.AllowGet);
            }
             * */

            OleDbConnection mycn = buildConn();
            mycn.Open();
            string condition = "";
            if (!string.IsNullOrEmpty(username))
            {
                condition += " and username = '******'";
            }
            if (!string.IsNullOrEmpty(type))
            {
                condition += " and type = '" + type + "'";
            }
            if (!string.IsNullOrEmpty(email))
            {
                condition += " and email = '" + email + "'";
            }
            if (!string.IsNullOrEmpty(cnName))
            {
                condition += " and cn_name = '" + cnName + "'";
            }
            string sql = "select * from sys_user where 1=1 " + condition;
            OleDbCommand mycm = new OleDbCommand(sql, mycn);
            OleDbDataReader msdr = mycm.ExecuteReader();
            List<User> list = new List<User>();
            while (msdr.Read())
            {
                if (msdr.HasRows)
                {
                    string[] readstring = new string[msdr.FieldCount];
                    for (int i = 0; i < msdr.FieldCount; i++)
                    {
                        if (msdr.IsDBNull(i))
                        {
                            continue;
                        }
                    }
                    User u = new User();
                    u.id = Convert.ToInt32(msdr["id"]);
                    u.username = Convert.ToString( msdr["username"]);
                    u.password = Convert.ToString(msdr["password"]);
                    u.cnName = Convert.ToString(msdr["cn_name"]);
                    u.sex = Convert.ToString(msdr["sex"]);
                    u.email = Convert.ToString(msdr["email"]);
                    u.mobilephone = Convert.ToString(msdr["mobilephone"]);

                    u.isEnabled = Convert.ToString(msdr["is_enabled"]);
                    //u.createDate = DateTime.Parse(Convert.ToString(msdr["create_date"]));
                    if (Convert.ToString(msdr["create_date"]).Length > 0) {
                            u.createDate = DateTime.ParseExact(Convert.ToString(msdr["create_date"]), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
                    }
                    u.status = Convert.ToString(msdr["status"]);
                    //u.picUrl = msdr.GetString(12);
                    //u.dimensionalCodeUrl = msdr.GetString(13);
                    u.type = Convert.ToString(msdr["type"]);
                    list.Add(u);
                }
            }
            msdr.Close();
            mycn.Close();
            return Json(new { data = list, success = true, msg = Session["user"] }, JsonRequestBehavior.AllowGet);
        }