private void UpdateDynamicJSUserInfo(HttpContext context)
        {
            BLL.UserInfo             bll  = new BLL.UserInfo();
            DataSet                  ds   = bll.GetList("");
            List <Model.UserForJson> list = new List <Model.UserForJson>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                list.Add(new Model.UserForJson()
                {
                    U_ID       = Convert.ToInt32(dr["U_ID"]),
                    U_nickname = dr["U_nickname"].ToString()
                });
            }
            JavaScriptSerializer jss = new JavaScriptSerializer();
            //string strJson = string.Format("{{\"rows\":{0}}}", jss.Serialize(list));
            string strJson = jss.Serialize(list);

            try
            {
                //File.WriteAllText(WMSys.Common.PathHelper.ServerPath+"\\jsonData\\UserInfo.json", strJson);
                string   DynamicJSPath    = WMSys.Common.PathHelper.ServerPath + "\\DynamicJS\\TagsInputUserData.js";
                string[] DynamicJSContent = File.ReadAllLines(DynamicJSPath);
                DynamicJSContent[0] = string.Format("var JsonData = '{0}'", strJson);
                File.WriteAllLines(DynamicJSPath, DynamicJSContent);
                context.Response.Write(strJson);
            }
            catch (Exception)
            {
                context.Response.Write("fail");
            }
        }
예제 #2
0
        void DataBind()//定义一个函数用于绑定数据到DataGridView
        {
            BLL.UserInfo bll = new BLL.UserInfo();
            DataSet      ds  = new DataSet();

            ds = bll.GetList();
            dataGridView2.DataSource = ds.Tables[0];
        }
        private void QueryUserList(HttpContext context)
        {
            string strKeyWord = context.Request["KeyWord"];

            BLL.UserInfo          bll  = new BLL.UserInfo();
            List <Model.UserInfo> list = new List <Model.UserInfo>();
            DataSet ds = new DataSet();

            if (!string.IsNullOrEmpty(strKeyWord))
            {
                ds = bll.GetList(string.Format("U_nickname like '%{0}%'", strKeyWord));
            }
            else
            {
                ds = bll.GetList("");
            }
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                list.Add(new Model.UserInfo()
                {
                    U_ID       = Convert.ToInt32(dr["U_ID"]),
                    U_username = dr["U_username"].ToString(),
                    //U_power = dr["U_power"].ToString(),
                    U_PowerDisplay = ChangePowerToDisplay(dr["U_power"].ToString()),
                    //U_power = dr["U_Power"].ToString(),
                    U_nickname = dr["U_nickname"].ToString(),
                    U_mailbox  = dr["U_mailbox"].ToString(),
                    U_Role     = dr["U_Role"].ToString(),
                });
            }
            JavaScriptSerializer jss = new JavaScriptSerializer();
            //string strJson = string.Format("{{\"rows\":{0}}}", jss.Serialize(list));
            string strJson = jss.Serialize(list);

            context.Response.Write(strJson);
        }
        //private void LoginReturnUserInfo(HttpContext context)
        //{

        //}

        private void GetUserInfoSingle(HttpContext context)
        {
            BLL.UserInfo          bll  = new BLL.UserInfo();
            DataSet               ds   = bll.GetList(" U_ID=" + context.Request["U_ID"]);
            DataRow               dr   = ds.Tables[0].Rows[0];
            List <Model.UserInfo> list = new List <Model.UserInfo>();

            list.Add(new Model.UserInfo()
            {
                U_username     = dr["U_username"].ToString(),
                U_PowerDisplay = ChangePowerToDisplay(dr["U_power"].ToString()),
                U_power        = dr["U_power"].ToString(),
                U_nickname     = dr["U_nickname"].ToString(),
                U_mailbox      = dr["U_mailbox"].ToString(),
                U_Role         = dr["U_Role"].ToString(),
                U_Comments     = dr["U_Comments"].ToString()
            });
            JavaScriptSerializer jss = new JavaScriptSerializer();
            string strJson           = jss.Serialize(list).TrimStart('[').TrimEnd(']');

            context.Response.Write(strJson);
        }
예제 #5
0
        private void btnLogin_Click_1(object sender, EventArgs e)
        {
            Model.UserInfo model = new Model.UserInfo();//实例化Model层
            model.UserName     = txtUserName.Text.Trim();
            model.UserPassword = txtPassword.Text.Trim();
            BLL.UserInfo bll = new BLL.UserInfo(); //实例化BLL层
            model = bll.ToMD5(model);
            DataSet ds = new DataSet();            //定义DataSet对象

            ds = bll.GetList(model);               //调用BLL层中的GetList方法,返还DataSet对象
            if (ds.Tables[0].Rows.Count > 0)
            {
                Main main = new Main();
                main.Type = ds.Tables[0].Rows[0]["用户类别"].ToString();
                main.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("用户名或者密码输入错误!");
            }
        }
예제 #6
0
        private void txtOK_Click(object sender, EventArgs e)
        {
            string strSelect = this.cbxCondition.Text.Trim();

            if (strSelect == "")
            {
                MessageBox.Show("请选择查询条件!");
                return;
            }
            if (this.txtKeyWord.Text == "")
            {
                MessageBox.Show("输入查询条件!");
                return;
            }
            string strWhere = "1=1";
            string userName = txtKeyWord.Text;
            string userType = txtKeyWord.Text;

            switch (strSelect)
            {
            case "用户账号":
            {
                strWhere = strWhere + " and UserName like '%" + userName + "%' ";
            }
            break;

            case "用户类型":
            {
                strWhere = strWhere + " and UserType =  '" + userType + "'";
            }
            break;
            }
            BLL.UserInfo bll = new BLL.UserInfo(); //实例化BLL层
            DataSet      ds  = new DataSet();

            ds = bll.GetList(strWhere);              //执行带参数SQL语句,将结果存在ds中
            dataGridView2.DataSource = ds.Tables[0]; //将ds中的表作为DataGridView的数据源
        }