/// <summary> /// 获取送货人model /// </summary> /// <param name="id"></param> /// <returns></returns> public MsendGoodsUser GetSendGoodsUserModelById(string id) { string sql = " SELECT id,userName,sex,phone,isDelete,isEffective,great_time,modify_time FROM sendGoodsUser where id=?id"; List <MySqlParameter> parameterList = new List <MySqlParameter>(); MySqlParameter parameter = new MySqlParameter("?id", MySqlDbType.VarChar, 25); parameter.Value = id; parameterList.Add(parameter); MsendGoodsUser model = null; using (MySqlDataReader sqlDataReader = PKMySqlHelper.ExecuteReader(sql, parameterList.ToArray())) { if (sqlDataReader != null) { if (sqlDataReader.Read()) { model = new MsendGoodsUser(); model.id = sqlDataReader["id"] != DBNull.Value ? sqlDataReader["id"].ToString() : string.Empty; model.userName = sqlDataReader["userName"] != DBNull.Value ? sqlDataReader["userName"].ToString() : string.Empty; model.userName = Base64.DecodeBase64(model.userName); model.phone = sqlDataReader["phone"] != DBNull.Value ? sqlDataReader["phone"].ToString() : string.Empty; model.sex = sqlDataReader["sex"] != DBNull.Value ? Convert.ToInt32(sqlDataReader["sex"].ToString()) : 0; model.great_time = sqlDataReader["great_time"] != DBNull.Value ? Convert.ToDateTime(sqlDataReader["great_time"].ToString()) : DateTime.MinValue; model.modify_time = sqlDataReader["modify_time"] != DBNull.Value ? Convert.ToDateTime(sqlDataReader["modify_time"].ToString()) : DateTime.MinValue; model.greatTime = model.great_time.ToString("yyyy-MM-dd HH:mm:ss"); } } } return(model); }
/// <summary> /// 检查新增用户的合法性 /// </summary> /// <param name="madminuser"></param> /// <returns></returns> private string CheckSendUser(MsendGoodsUser model) { if (model == null) { return("操作失败:送货员不能为空!"); } if (string.IsNullOrEmpty(model.userName)) { return("操作失败:姓名不能为空!"); return(string.Empty); } if (string.IsNullOrEmpty(model.phone)) { return("操作失败:手机号码不能为空!"); } if (!PublicTools.IsPhon(model.phone)) { return("操作失败:请输入正确格式的手机号码!"); } //// 验证手机号码是否已经被使用 if (new SndGoodsUserService().GetSndGoodsUserPagCount(model.phone, string.Empty) > 0) { return("操作失败:该手机号码已被使用!"); } return(string.Empty); }
/// <summary> /// 修改送货信息 /// </summary> /// <param name="model">model</param> /// <returns></returns> public bool ChangSndGoodsUserInfor(MsendGoodsUser model) { //// sql语句 string sql = "update sendGoodsUser set userName = ?userName,phone=?phone,sex=?sex where id = ?id"; List <MySqlParameter> parameterList = new List <MySqlParameter>(); MySqlParameter parameter = new MySqlParameter("?userName", MySqlDbType.VarChar, 500); parameter.Value = Base64.EncodeBase64(model.userName); parameterList.Add(parameter); parameter = new MySqlParameter("?phone", MySqlDbType.VarChar, 50); parameter.Value = model.phone; parameterList.Add(parameter); parameter = new MySqlParameter("?sex", MySqlDbType.Int16, 1); parameter.Value = model.sex; parameterList.Add(parameter); parameter = new MySqlParameter("?id", MySqlDbType.VarChar, 25); parameter.Value = model.id; parameterList.Add(parameter); //// 执行操作 return(PKMySqlHelper.ExecuteNonQuery(sql, parameterList.ToArray()) > 0); }
public string AddSndGoodsUserMeth(MsendGoodsUser model) { if (!base.CheckIsLogin()) { return("-1"); } return(new SndGoodsUserBus().AddUserMeth(model)); }
/// <summary> /// 分页获取管理严用户信息 /// </summary> /// <param name="pagIndex">页码(第一页从1 开始)</param> /// <param name="pagCount">每页数据条数</param> /// <returns></returns> public List <MsendGoodsUser> GetSendGoodsUserPagList(int pagIndex, int pagCount, string phone, string userName) { // 查询条件 StringBuilder sqlWhere = new StringBuilder(" 1=1 "); if (!string.IsNullOrEmpty(phone)) { sqlWhere.Append(" and phone like CONCAT('%',?phone,'%')"); } if (!string.IsNullOrEmpty(userName)) { sqlWhere.Append(" and userName like CONCAT('%',?userName,'%')"); } string sql = " SELECT id,userName,sex,phone,isDelete,isEffective,great_time,modify_time " + $" FROM sendGoodsUser WHERE {sqlWhere.ToString()} ORDER BY great_time desc limit {((pagIndex - 1) * pagCount)}, {pagCount}; "; //string sql = " SELECT TOP " + pagCount * pagIndex + " [id],[userName],[phone],[sex],[isDelete],[isEffective],[great_time],[modify_time] " + // " FROM( SELECT ROW_NUMBER() OVER(ORDER BY great_time DESC) AS ROWID,* FROM sendGoodsUser) AS TEMP1 WHERE ROWID> " + pagCount * (pagIndex - 1); List <MySqlParameter> parameterList = new List <MySqlParameter>(); MySqlParameter parameter = new MySqlParameter("?phone", MySqlDbType.VarChar, 50); parameter.Value = "%" + phone + "%"; parameterList.Add(parameter); parameter = new MySqlParameter("?userName", MySqlDbType.VarChar, 500); parameter.Value = "%" + Base64.EncodeBase64(userName) + "%"; parameterList.Add(parameter); List <MsendGoodsUser> listModel = null; using (MySqlDataReader sqlDataReader = PKMySqlHelper.ExecuteReader(sql, parameterList.ToArray())) { if (sqlDataReader != null) { listModel = new List <MsendGoodsUser>(); while (sqlDataReader.Read()) { MsendGoodsUser model = new MsendGoodsUser(); model.id = sqlDataReader["id"] != DBNull.Value ? sqlDataReader["id"].ToString() : string.Empty; model.userName = sqlDataReader["userName"] != DBNull.Value ? sqlDataReader["userName"].ToString() : string.Empty; model.userName = Base64.DecodeBase64(model.userName); model.phone = sqlDataReader["phone"] != DBNull.Value ? sqlDataReader["phone"].ToString() : string.Empty; model.sex = sqlDataReader["sex"] != DBNull.Value ? Convert.ToInt32(sqlDataReader["sex"].ToString()) : 0; model.great_time = sqlDataReader["great_time"] != DBNull.Value ? Convert.ToDateTime(sqlDataReader["great_time"].ToString()) : DateTime.MinValue; model.modify_time = sqlDataReader["modify_time"] != DBNull.Value ? Convert.ToDateTime(sqlDataReader["modify_time"].ToString()) : DateTime.MinValue; model.greatTime = model.great_time.ToString("yyyy-MM-dd HH:mm:ss"); listModel.Add(model); } } } return(listModel); }
/// <summary> /// 新增平台用户 /// </summary> /// <param name="madminuser"></param> /// <returns></returns> public string AddUserMeth(MsendGoodsUser model) { MwxResult mwxResult = new MwxResult() { errcode = -1 }; try { //// 数据合法性检查 string checkAdminUser = this.CheckSendUser(model); if (!string.IsNullOrEmpty(checkAdminUser)) { mwxResult.errmsg = checkAdminUser; } bool doResult = false; if (string.IsNullOrEmpty(model.id)) { //// 时间相关参数赋值 model.great_time = System.DateTime.Now; model.modify_time = model.great_time; model.id = PublicTools.GetRandomNumberByTime(); doResult = new SndGoodsUserService().AddSndGoodsUser(model); } else { doResult = new SndGoodsUserService().ChangSndGoodsUserInfor(model); } //// 数据落地入库 if (!doResult) { mwxResult.errmsg = "操作失败"; } else { mwxResult.errcode = 0; mwxResult.errmsg = "操作成功"; } } catch (Exception ex) { mwxResult.errmsg = "操作失败:系统异常!"; } return(JsonHelper.GetJson <MwxResult>(mwxResult)); }
/// <summary> /// 新增管理员 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AddSndGoodsUser(MsendGoodsUser model) { //// sql语句 string sql = "INSERT INTO sendGoodsUser (id,userName,sex,phone,isDelete,isEffective,great_time,modify_time) " + "VALUES(?id, ?userName,?sex, ?phone, ?isDelete, ?isEffective, ?great_time, ?modify_time)"; List <MySqlParameter> parameterList = new List <MySqlParameter>(); MySqlParameter parameter = new MySqlParameter("?id", MySqlDbType.VarChar, 25); parameter.Value = model.id; parameterList.Add(parameter); parameter = new MySqlParameter("?userName", MySqlDbType.VarChar, 500); parameter.Value = Base64.EncodeBase64(model.userName); parameterList.Add(parameter); parameter = new MySqlParameter("?phone", MySqlDbType.VarChar, 50); parameter.Value = model.phone; parameterList.Add(parameter); parameter = new MySqlParameter("?sex", MySqlDbType.Int16, 1); parameter.Value = model.sex; parameterList.Add(parameter); parameter = new MySqlParameter("?isDelete", MySqlDbType.Int16, 1); parameter.Value = model.isDelete; parameterList.Add(parameter); parameter = new MySqlParameter("?isEffective", MySqlDbType.Int16, 1); parameter.Value = model.isEffective; parameterList.Add(parameter); DateTime dateTime = System.DateTime.Now; parameter = new MySqlParameter("?great_time", MySqlDbType.DateTime); parameter.Value = dateTime; parameterList.Add(parameter); parameter = new MySqlParameter("?modify_time", MySqlDbType.DateTime); parameter.Value = dateTime; parameterList.Add(parameter); //// 执行操作 return(PKMySqlHelper.ExecuteNonQuery(sql, parameterList.ToArray()) > 0); }
/// <summary> /// 修改送货信息 /// </summary> /// <param name="model">model</param> /// <returns></returns> public bool ChangSndGoodsUserInfor(MsendGoodsUser model) { return(opertService.ChangSndGoodsUserInfor(model)); }
/// <summary> /// 新增管理员 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AddSndGoodsUser(MsendGoodsUser model) { return(opertService.AddSndGoodsUser(model)); }