protected void save() { bool Result = false; string dotype = Utils.GetQueryStringValue("dotype"); string RoleId = Utils.GetQueryStringValue("id"); EyouSoft.Model.SSOStructure.MGuanLiYuanInfo model = new EyouSoft.Model.SSOStructure.MGuanLiYuanInfo(); Eyousoft_yhq.BLL.User BComRoleBll = new Eyousoft_yhq.BLL.User(); int length = Utils.GetFormValues("chk_id").Length; for (int i = 0; i < length; i++) { model.Privs += Utils.GetFormValues("chk_id")[i] + ","; } if (!string.IsNullOrEmpty(model.Privs)) { model.Privs = model.Privs.Trim(','); } model.UserId = RoleId; Result = BComRoleBll.UpdatePrivs(model); if (Result) { Response.Write(UtilsCommons.AjaxReturnJson("1", "授权成功!")); } else { Response.Write(UtilsCommons.AjaxReturnJson("0", "授权失败!")); } Response.End(); }
/// <summary> /// 注册用户/添加用户 /// </summary> /// <param name="model">用户实体/管理员实体</param> /// <returns></returns> public bool Add(EyouSoft.Model.SSOStructure.MGuanLiYuanInfo model) { StringBuilder strSql = new StringBuilder(); if (model.IsAdmin) { strSql.Append(" INSERT INTO tbl_User([UserID],[UserName],[UserPwd],[ContactName],[ContactSex],[Remark],[IssueTime],[ContactTel] ,[IsAdmin],[UserState],[Privs],SealImg,LeiXing)VALUES (@UserID,@UserName,@UserPwd,@ContactName,@ContactSex,@Remark,@IssueTime,@ContactTel,@IsAdmin,1,@Privs,@SealImg,@LeiXing) "); } else { strSql.Append(" INSERT INTO tbl_User([UserID],[UserName],[UserPwd],[ContactName],[Remark],[IssueTime],[ContactTel] ,[IsAdmin],[UserState],[LeiXing]) VALUES (@UserID,@UserName,@UserPwd,@ContactName,@Remark,@IssueTime,@ContactTel,@IsAdmin,1,@LeiXing) "); } DbCommand cmd = this._db.GetSqlStringCommand(strSql.ToString()); this._db.AddInParameter(cmd, "UserID", System.Data.DbType.AnsiStringFixedLength, model.UserId); this._db.AddInParameter(cmd, "UserName", System.Data.DbType.String, model.Username); this._db.AddInParameter(cmd, "UserPwd", System.Data.DbType.String, model.MiMa); this._db.AddInParameter(cmd, "ContactName", System.Data.DbType.String, model.XingMing); this._db.AddInParameter(cmd, "ContactSex", System.Data.DbType.Byte, (int)0); this._db.AddInParameter(cmd, "Remark", System.Data.DbType.String, model.BeiZhu); this._db.AddInParameter(cmd, "IssueTime", System.Data.DbType.DateTime, model.CreateTime); this._db.AddInParameter(cmd, "ContactTel", System.Data.DbType.String, model.Telephone); this._db.AddInParameter(cmd, "IsAdmin", System.Data.DbType.String, model.IsAdmin ? "1" : "0"); this._db.AddInParameter(cmd, "Privs", System.Data.DbType.String, ""); this._db.AddInParameter(cmd, "SealImg", System.Data.DbType.String, model.GongZhangFilepath); _db.AddInParameter(cmd, "LeiXing", System.Data.DbType.Int32, model.LeiXing); return(DbHelper.ExecuteSql(cmd, this._db) > 0 ? true : false); }
/// <summary> /// 修改用户信息 /// </summary> /// <param name="model">用户实体</param> /// <returns></returns> public bool Update(EyouSoft.Model.SSOStructure.MGuanLiYuanInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("UPDATE tbl_User SET UserPwd = @UserPwd ,ContactName =@ContactName ,Remark =@Remark,SealImg=@SealImg "); strSql.Append(" ,ContactTel = @ContactTel "); strSql.Append(" ,LeiXing=@LeiXing "); strSql.Append(" WHERE UserID = @UserID"); DbCommand cmd = this._db.GetSqlStringCommand(strSql.ToString()); this._db.AddInParameter(cmd, "UserID", System.Data.DbType.AnsiStringFixedLength, model.UserId); this._db.AddInParameter(cmd, "UserPwd", System.Data.DbType.String, model.MiMa); this._db.AddInParameter(cmd, "ContactName", System.Data.DbType.String, model.XingMing); this._db.AddInParameter(cmd, "ContactSex", System.Data.DbType.Byte, (int)0); this._db.AddInParameter(cmd, "Remark", System.Data.DbType.String, model.BeiZhu); this._db.AddInParameter(cmd, "ContactTel", System.Data.DbType.String, model.Telephone); this._db.AddInParameter(cmd, "UserState", System.Data.DbType.Byte, model.Status); this._db.AddInParameter(cmd, "SealImg", System.Data.DbType.String, model.GongZhangFilepath); _db.AddInParameter(cmd, "LeiXing", System.Data.DbType.Int32, model.LeiXing); return(DbHelper.ExecuteSql(cmd, this._db) > 0 ? true : false); }
protected void pageSave(string doType) { string id = Utils.GetQueryStringValue("id"); var model = new EyouSoft.Model.SSOStructure.MGuanLiYuanInfo(); #region 表单取值 string getusername = Utils.GetFormValue(userName.UniqueID); string getuserpwd = Utils.GetFormValue(userPwd.UniqueID); string getcontactname = Utils.GetFormValue(ContactName.UniqueID); string gettel = Utils.GetFormValue(tel.UniqueID); string getremark = Utils.GetFormValue(remark.UniqueID); #endregion #region 实体赋值 model.Username = getusername; model.MiMa = getuserpwd; model.XingMing = getcontactname; model.Telephone = gettel; model.BeiZhu = getremark; model.CreateTime = DateTime.Now; model.IsAdmin = false; string stroldupload = Utils.GetFormValue("hideFileInfo"); string newupload = Utils.GetFormValue(this.UploadSeal.ClientHideID); if (!string.IsNullOrEmpty(newupload)) { if (!string.IsNullOrEmpty(newupload)) { model.GongZhangFilepath = newupload.Split('|')[1]; } } else { model.GongZhangFilepath = stroldupload; } #endregion #region 提交保存 bool result = false; string msg = ""; Response.Clear(); model.LeiXing = Utils.GetEnumValue<Eyousoft_yhq.Model.WebmasterLeiXing>(Utils.GetFormValue("txtLeiXing"), Eyousoft_yhq.Model.WebmasterLeiXing.系统); Eyousoft_yhq.BLL.User BLL = new Eyousoft_yhq.BLL.User(); if (doType == "add") { result = BLL.Add(model); msg = result ? "添加成功!" : "添加失败!"; Response.Write(UtilsCommons.AjaxReturnJson(result ? "1" : "0", msg)); } else { model.UserId = id; result = BLL.Update(model); msg = result ? "修改成功!" : "修改失败!"; Response.Write(UtilsCommons.AjaxReturnJson(result ? "1" : "0", msg)); } Response.End(); #endregion }
protected void pageSave(string doType) { string id = Utils.GetQueryStringValue("id"); var model = new EyouSoft.Model.SSOStructure.MGuanLiYuanInfo(); #region 表单取值 string getusername = Utils.GetFormValue(userName.UniqueID); string getuserpwd = Utils.GetFormValue(userPwd.UniqueID); string getcontactname = Utils.GetFormValue(ContactName.UniqueID); string gettel = Utils.GetFormValue(tel.UniqueID); string getremark = Utils.GetFormValue(remark.UniqueID); #endregion #region 实体赋值 model.Username = getusername; model.MiMa = getuserpwd; model.XingMing = getcontactname; model.Telephone = gettel; model.BeiZhu = getremark; model.CreateTime = DateTime.Now; model.IsAdmin = false; string stroldupload = Utils.GetFormValue("hideFileInfo"); string newupload = Utils.GetFormValue(this.UploadSeal.ClientHideID); if (!string.IsNullOrEmpty(newupload)) { if (!string.IsNullOrEmpty(newupload)) { model.GongZhangFilepath = newupload.Split('|')[1]; } } else { model.GongZhangFilepath = stroldupload; } #endregion #region 提交保存 bool result = false; string msg = ""; Response.Clear(); model.LeiXing = Utils.GetEnumValue <Eyousoft_yhq.Model.WebmasterLeiXing>(Utils.GetFormValue("txtLeiXing"), Eyousoft_yhq.Model.WebmasterLeiXing.系统); Eyousoft_yhq.BLL.User BLL = new Eyousoft_yhq.BLL.User(); if (doType == "add") { result = BLL.Add(model); msg = result ? "添加成功!" : "添加失败!"; Response.Write(UtilsCommons.AjaxReturnJson(result ? "1" : "0", msg)); } else { model.UserId = id; result = BLL.Update(model); msg = result ? "修改成功!" : "修改失败!"; Response.Write(UtilsCommons.AjaxReturnJson(result ? "1" : "0", msg)); } Response.End(); #endregion }
/// <summary> /// 设置权限 /// </summary> public bool UpdatePrivs(EyouSoft.Model.SSOStructure.MGuanLiYuanInfo model) { if (string.IsNullOrEmpty(model.UserId)) { return(false); } return(dal.UpdatePrivs(model)); }
public IList <EyouSoft.Model.SSOStructure.MGuanLiYuanInfo> GetList(int PageSize, int PageIndex, ref int RecordCount, EyouSoft.Model.SSOStructure.MGuanLiYuanChaXunInfo serModel) { IList <EyouSoft.Model.SSOStructure.MGuanLiYuanInfo> list = new List <EyouSoft.Model.SSOStructure.MGuanLiYuanInfo>(); string tableName = "tbl_User"; string fileds = " * "; string orderByString = "IssueTime desc"; StringBuilder query = new StringBuilder(); query.AppendFormat(" 1=1 "); if (serModel != null) { if (!string.IsNullOrEmpty(serModel.Username)) { query.AppendFormat(" and UserName like '%{0}%' ", serModel.Username); } if (!string.IsNullOrEmpty(serModel.XingMing)) { query.AppendFormat(" and ContactName like '%{0}%' ", serModel.XingMing); } } using (IDataReader dr = DbHelper.ExecuteReader1(this._db, PageSize, PageIndex, ref RecordCount, tableName, fileds, query.ToString(), orderByString, null)) { while (dr.Read()) { var model = new EyouSoft.Model.SSOStructure.MGuanLiYuanInfo(); model.UserId = dr["UserID"].ToString(); model.Username = dr["UserName"].ToString(); model.MiMa = dr["UserPwd"].ToString(); model.XingMing = dr["ContactName"].ToString(); if (!dr.IsDBNull(dr.GetOrdinal("ContactSex"))) { model.XingBie = (sexType)dr.GetByte(dr.GetOrdinal("ContactSex")); } model.BeiZhu = dr["Remark"].ToString(); model.Telephone = dr["ContactTel"].ToString(); model.IsAdmin = dr["IsAdmin"].ToString() == "1"; model.Status = dr.GetByte(dr.GetOrdinal("UserState")); model.Privs = dr["Privs"].ToString(); model.GongZhangFilepath = dr["SealImg"].ToString(); model.CreateTime = dr.GetDateTime(dr.GetOrdinal("IssueTime")); model.LeiXing = (Eyousoft_yhq.Model.WebmasterLeiXing)dr.GetInt32(dr.GetOrdinal("LeiXing")); list.Add(model); } } return(list); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(EyouSoft.Model.SSOStructure.MGuanLiYuanInfo model) { model.UserId = Guid.NewGuid().ToString(); bool result = dal.Add(model); if (result) { new Eyousoft_yhq.BLL.Login().isLogin(model.Username, model.MiMa); } return(result); }
public IList <EyouSoft.Model.SSOStructure.MGuanLiYuanInfo> GetList(EyouSoft.Model.SSOStructure.MGuanLiYuanChaXunInfo serModel) { IList <EyouSoft.Model.SSOStructure.MGuanLiYuanInfo> list = new List <EyouSoft.Model.SSOStructure.MGuanLiYuanInfo>(); StringBuilder query = new StringBuilder(); query.Append("select * from tbl_User where 1=1"); if (serModel != null) { if (!string.IsNullOrEmpty(serModel.Username)) { query.AppendFormat(" and UserName like '%{0}%' ", serModel.Username); } if (!string.IsNullOrEmpty(serModel.XingMing)) { query.AppendFormat(" and ContactName like '%{0}%' ", serModel.XingMing); } } query.Append(" order by UserID DESC "); DbCommand cmd = this._db.GetSqlStringCommand(query.ToString()); using (IDataReader dr = DbHelper.ExecuteReader(cmd, this._db)) { while (dr.Read()) { var model = new EyouSoft.Model.SSOStructure.MGuanLiYuanInfo(); model.UserId = dr["UserID"].ToString(); model.Username = dr["UserName"].ToString(); model.MiMa = dr["UserPwd"].ToString(); model.XingMing = dr["ContactName"].ToString(); if (!dr.IsDBNull(dr.GetOrdinal("ContactSex"))) { model.XingBie = (sexType)dr.GetByte(dr.GetOrdinal("ContactSex")); } model.BeiZhu = dr["Remark"].ToString(); model.Telephone = dr["ContactTel"].ToString(); model.IsAdmin = dr["IsAdmin"].ToString() == "1"; model.Status = dr.GetByte(dr.GetOrdinal("UserState")); model.Privs = dr["Privs"].ToString(); model.GongZhangFilepath = dr["SealImg"].ToString(); model.CreateTime = dr.GetDateTime(dr.GetOrdinal("IssueTime")); model.LeiXing = (Eyousoft_yhq.Model.WebmasterLeiXing)dr.GetInt32(dr.GetOrdinal("LeiXing")); list.Add(model); } } return(list); }
/// <summary> /// 设置权限 /// </summary> /// <param name="model">用户实体</param> /// <returns></returns> public bool UpdatePrivs(EyouSoft.Model.SSOStructure.MGuanLiYuanInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("UPDATE tbl_User SET Privs = @Privs "); strSql.Append(" WHERE UserID = @UserID"); DbCommand cmd = this._db.GetSqlStringCommand(strSql.ToString()); this._db.AddInParameter(cmd, "UserID", System.Data.DbType.AnsiStringFixedLength, model.UserId); this._db.AddInParameter(cmd, "Privs", System.Data.DbType.String, model.Privs); return(DbHelper.ExecuteSql(cmd, this._db) > 0 ? true : false); }
/// <summary> /// 获取实体 /// </summary> /// <param name="UserID">用户编号</param> /// <returns></returns> public EyouSoft.Model.SSOStructure.MGuanLiYuanInfo GetModel(string UserID) { EyouSoft.Model.SSOStructure.MGuanLiYuanInfo model = null; StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT * "); strSql.Append(" FROM tbl_User "); strSql.Append(" where UserID=@UserID "); DbCommand cmd = this._db.GetSqlStringCommand(strSql.ToString()); this._db.AddInParameter(cmd, "UserID", System.Data.DbType.AnsiStringFixedLength, UserID); using (IDataReader dr = DbHelper.ExecuteReader(cmd, this._db)) { while (dr.Read()) { model = new EyouSoft.Model.SSOStructure.MGuanLiYuanInfo(); model.UserId = dr["UserID"].ToString(); model.Username = dr["UserName"].ToString(); model.MiMa = dr["UserPwd"].ToString(); model.XingMing = dr["ContactName"].ToString(); if (!dr.IsDBNull(dr.GetOrdinal("ContactSex"))) { model.XingBie = (sexType)dr.GetByte(dr.GetOrdinal("ContactSex")); } model.BeiZhu = dr["Remark"].ToString(); model.Telephone = dr["ContactTel"].ToString(); model.IsAdmin = dr["IsAdmin"].ToString() == "1"; model.Status = dr.GetByte(dr.GetOrdinal("UserState")); model.Privs = dr["Privs"].ToString(); model.GongZhangFilepath = dr["SealImg"].ToString(); model.CreateTime = dr.GetDateTime(dr.GetOrdinal("IssueTime")); model.LeiXing = (Eyousoft_yhq.Model.WebmasterLeiXing)dr.GetInt32(dr.GetOrdinal("LeiXing")); } } return(model); }