Esempio n. 1
0
        private void buttonBuscar_Click(object sender, EventArgs e)
        {
            List <Users> Users = new List <Users>();
            string       Datos = textBoxBuscar.Text;

            switch (comboBoxFiltrar.SelectedIndex)
            {
            case 0:
                Users = UsersBLL.GetList(i => i.Nombre == Datos);
                AddFiltrado(Users);
                break;

            case 1:
                Users = UsersBLL.GetList(i => i.NombreUsuario == Datos);
                AddFiltrado(Users);
                break;

            case 2:
                Users = UsersBLL.GetList(i => i.Tipo == Datos);
                AddFiltrado(Users);
                break;


            default:
                MessageBox.Show("Selecione un campo para filtrar");
                break;
            }

            if (textBoxBuscar.Text == string.Empty)
            {
                dataGridViewEmpleado.Rows.Clear();
                LlenaCampos();
            }
        }
Esempio n. 2
0
        public string GetUsersListData(string Where)
        {
            StringBuilder sb = new StringBuilder("");

            try
            {
                UsersBLL usersbll = new UsersBLL();
                DataSet  ds       = new DataSet();
                ds = usersbll.GetList(Where);
                if (ds != null && ds.Tables.Count > 0)
                {
                    for (int q = 0; q < ds.Tables[0].Rows.Count; q++)
                    {
                        string styleclass = "";
                        if ((q + 1) % 2 == 0)
                        {
                            styleclass = "even";
                        }
                        else
                        {
                            styleclass = "odd";
                        }

                        sb.Append("<tr role=\"row\" class=\"" + styleclass + "\">");
                        sb.Append("<td>" + Convert.ToInt32(ds.Tables[0].Rows[q]["UserID"]) + "</td>");
                        sb.Append("<td>" + ds.Tables[0].Rows[q]["LoginName"].ToString() + "</td>");
                        sb.Append("<td>" + ds.Tables[0].Rows[q]["UserName"].ToString() + "</td>");
                        sb.Append("<td>" + ds.Tables[0].Rows[q]["CardID"].ToString() + "</td>");
                        string SexData = "";
                        if (ds.Tables[0].Rows[q]["Sex"] != null && ds.Tables[0].Rows[q]["Sex"].ToString() != "")
                        {
                            SexData = Convert.ToInt32(ds.Tables[0].Rows[q]["Sex"]) == 1 ? "男" : "女";
                        }
                        else
                        {
                            SexData = "男";
                        }
                        sb.Append("<td>" + SexData + "</td>");
                        sb.Append("<td>" + ds.Tables[0].Rows[q]["Phone"].ToString() + "</td>");
                        sb.Append("<td>" + ds.Tables[0].Rows[q]["QQ"].ToString() + "</td>");
                        sb.Append("<td>" + ds.Tables[0].Rows[q]["Wechat"].ToString() + "</td>");
                        sb.Append("<td>" + ds.Tables[0].Rows[q]["Email"].ToString() + "</td>");
                        sb.Append("<td>" + (Convert.ToInt32(ds.Tables[0].Rows[q]["UserType"]) == 1 ? "管理员" : "客户") + "</td>");
                        sb.Append("<td>" + ds.Tables[0].Rows[q]["CityID"].ToString() + "</td>");
                        sb.Append("<td>" + ds.Tables[0].Rows[q]["CompanyName"].ToString() + "</td>");
                        sb.Append("<td>" + ds.Tables[0].Rows[q]["RecordUpdateTime"].ToString() + "</td>");
                        sb.Append("<td>");
                        sb.Append("<a   href=\"javascript:UpdateUsers(" + Convert.ToInt32(ds.Tables[0].Rows[q]["UserID"]) + ")\">修改</a>&nbsp;&nbsp;");
                        sb.Append("<a   href=\"javascript:DeleteUsers(" + Convert.ToInt32(ds.Tables[0].Rows[q]["UserID"]) + ")\">删除</a>&nbsp;&nbsp;");
                        sb.Append("</td>");
                        sb.Append("</tr>");
                    }
                }
            }
            catch
            {
            }
            return(sb.ToString());
        }
Esempio n. 3
0
    private void InitData(int PageIndex, string name)
    {
        this.Title = "用户列表";    // 设置标题

        DataSet ds          = new DataSet();
        int     recordcount = 0; //获取总条数

        if (!name.Equals(string.Empty) && name != null)
        {
            txtSearchName.Text = name;
            //搜索
            ds = bll.GetList(AspNetPager1.PageSize, PageIndex, name, -1, out recordcount);
        }
        else
        {
            ds = bll.GetList(AspNetPager1.PageSize, PageIndex, "", -1, out recordcount);
        }

        AspNetPager1.RecordCount = recordcount;
        this.rptBind.DataSource  = ds.Tables[0].DefaultView;
        this.rptBind.DataBind();
    }
Esempio n. 4
0
        public void VerifyRelationDepartment(HttpContext context)
        {
            var      DepartmentID = context.Request.QueryString["DepartmentID"];
            UsersBLL bll          = new UsersBLL();
            DataSet  ds           = new DataSet();
            int      b            = 0;

            if (!string.IsNullOrEmpty(DepartmentID))
            {
                ds = bll.GetList(" DepartmentID=" + DepartmentID + " and RecordIsDelete=0");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    b = ds.Tables[0].Rows[0]["DepartmentID"].ToInt();
                }
            }
            context.Response.Write(b);
        }
Esempio n. 5
0
        /// <summary>
        /// 获取用户列表
        /// </summary>
        static public Object GetUsersList()
        {
            string result = string.Empty;

            try
            {
                string sEcho         = JsonRequest.GetJsonKeyVal(jsonText, "sEcho");
                int    displayStart  = ComPage.SafeToInt(JsonRequest.GetJsonKeyVal(jsonText, "iDisplayStart"));
                int    displayLength = ComPage.SafeToInt(JsonRequest.GetJsonKeyVal(jsonText, "iDisplayLength"));
                int    pageIndex     = (displayStart / displayLength) + 1;
                int    pageSize      = displayLength;

                #region 获取列表
                StringBuilder where = new StringBuilder();
                where.Append("1=1 and u.RecordIsDelete=0 ");
                DepartmentInfo    df  = new DepartmentInfo();
                DepartmentInfoBLL bll = new DepartmentInfoBLL();
                df = bll.GetModel(ComPage.CurrentAdmin.DepartmentID);

                if (ComPage.CurrentAdmin.UserType != 1)
                {
                    if ((df == null) || (df != null && df.IsReceiveBusiness != false))
                    {
                        where.Append(" AND  u. UserID IN(select ID from [BWJSDB].dbo.[GetDepartmentChildren](" + ComPage.CurrentAdmin.UserID + "))");
                    }
                }

                #region 条件搜索
                string key = DNTRequest.GetString("searchKey");
                if (string.IsNullOrEmpty(key))
                {
                    key = JsonRequest.GetJsonKeyVal(jsonText, "searchKey");
                }
                string LoginName        = DNTRequest.GetString("LoginName");
                string UsersName        = DNTRequest.GetString("UsersName");
                string Mobiles          = DNTRequest.GetString("Mobiles");
                string DepartmentInfoID = DNTRequest.GetString("DepartmentInfoID");

                if (string.IsNullOrEmpty(LoginName))
                {
                    LoginName = JsonRequest.GetJsonKeyVal(jsonText, "LoginName");
                    LoginName = System.Web.HttpContext.Current.Server.UrlDecode(LoginName);
                }
                if (string.IsNullOrEmpty(UsersName))
                {
                    UsersName = JsonRequest.GetJsonKeyVal(jsonText, "UsersName");
                    UsersName = System.Web.HttpContext.Current.Server.UrlDecode(UsersName);
                }
                if (string.IsNullOrEmpty(Mobiles))
                {
                    Mobiles = JsonRequest.GetJsonKeyVal(jsonText, "Mobiles");
                    Mobiles = System.Web.HttpContext.Current.Server.UrlDecode(Mobiles);
                }
                if (string.IsNullOrEmpty(DepartmentInfoID))
                {
                    DepartmentInfoID = JsonRequest.GetJsonKeyVal(jsonText, "DepartmentInfoID");
                    DepartmentInfoID = System.Web.HttpContext.Current.Server.UrlDecode(DepartmentInfoID);
                }



                if (!string.IsNullOrEmpty(LoginName))
                {
                    where.AppendFormat(" and u.LoginName like'{0}%'  ", LoginName);
                }
                if (!string.IsNullOrEmpty(UsersName))
                {
                    where.AppendFormat(" and u.UserName like'{0}%'  ", UsersName);
                }
                if (!string.IsNullOrEmpty(Mobiles))
                {
                    where.AppendFormat(" and u.Phone like'{0}%'  ", Mobiles);
                }
                if (!string.IsNullOrEmpty(DepartmentInfoID) && DepartmentInfoID != "undefined" && DepartmentInfoID != "0")
                {
                    where.AppendFormat(" and u.DepartmentID ={0}  ", DepartmentInfoID);
                }
                #endregion

                string iSortCol_0   = JsonRequest.GetJsonKeyVal(jsonText, "iSortCol_0");
                string sSortDir_0   = JsonRequest.GetJsonKeyVal(jsonText, "sSortDir_0");
                int    iSortingCols = ComPage.SafeToInt(JsonRequest.GetJsonKeyVal(jsonText, "iSortingCols"));
                string orderBy      = string.Empty;
                if (!string.IsNullOrEmpty(iSortCol_0))
                {
                    string orderField = JsonRequest.GetJsonKeyVal(jsonText, string.Format("mDataProp_{0}", iSortCol_0));
                    orderBy = string.Format(" {0} {1}", orderField, sSortDir_0);
                }

                string    sql      = "";
                int       zys      = 0;
                int       sumcount = 0;
                UsersBLL  Usersbll = new UsersBLL();
                DataTable dt       = Usersbll.GetList(where.ToString(), pageIndex, pageSize, orderBy, ref sql, ref zys, ref sumcount);

                /*
                 *  iTotalRecord = sumcount,
                 *  iTotalDisplayRecords = sumcount,
                 */
                object obj = new
                {
                    result          = true,
                    code            = "",
                    msg             = "",
                    recordsTotal    = sumcount,
                    recordsFiltered = sumcount,
                    data            = ((dt == null) ? (new DataTable()) : (dt)),
                    sEcho           = sEcho,
                };
                result = Newtonsoft.Json.JsonConvert.SerializeObject(obj);

                #endregion
            }
            catch (Exception ex)
            {
                result = DNTRequest.GetResultJson(false, "操作异常,请稍候再试", null);
                ExceptionLogBLL.WriteExceptionLogToDB(ex.ToString());
            }
            return(result);
        }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                string telnumber = Request.Form["telnumber"];
                string password  = Request.Form["password"];
                string pwdAgian  = Request.Form["pwdAgian"];
                string name      = Request.Form["name"];
                string nickname  = Request.Form["nickname"];
                string idcard    = Request.Form["idcard"];
                if (password != pwdAgian)
                {
                    Response.Write("<script>alert('两次密码不一致')</script>");
                    return;
                }
                UsersBLL usersBll = new UsersBLL();

                if (usersBll.GetList("Telnumber = '" + telnumber + "'").Tables[0].Rows.Count == 0)
                {
                    if (usersBll.GetList("Idcard = '" + idcard + "'").Tables[0].Rows.Count == 0)
                    {
                    }
                    else
                    {
                        Response.Write("<script>alert('已注册的身份证号')</script>");
                        return;
                    }
                }
                else
                {
                    Response.Write("<script>alert('已注册的手机号')</script>");
                    return;
                }
                // 将密码加密后存入数据库
                var bytes = Encoding.UTF8.GetBytes(password);
                using (var md5 = System.Security.Cryptography.MD5.Create())
                {
                    var hash = md5.ComputeHash(bytes);
                    password = Convert.ToBase64String(hash);
                }
                Users user = new Users()
                {
                    TelNumber    = telnumber,
                    Pwd          = password,
                    Fname        = name,
                    Nickname     = nickname,
                    Idcard       = idcard,
                    CheckinCount = 0,
                    LoginStatus  = 0
                };
                int res = 0;
                try
                {
                    res = usersBll.Add(user);
                }
                catch (SqlException sqlex)
                {
                    Response.Write(sqlex.Message);
                }
                if (res != 0)
                {
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "PopUp", "<script>$(function () {window.pop('注册成功');});</script>");
                    //Response.Redirect("Sign in.aspx");
                }
                else
                {
                    Response.Write("<script>alert('注册失败')</script>");
                }
            }
        }