/// <summary> /// 修改用户密码 /// </summary> /// <param name="userID">登陆用户ID</param> /// <param name="OldPwd">旧登陆密码</param> /// <param name="NewPwd">新登陆密码</param> /// <returns></returns> public static Hashtable SetUserInfo(int userID, string OldPwd, string NewPwd) { Hashtable ht = new Hashtable(); DataTable dt = WebSiteCustomInfoDBHelper.SelectDataTable(userID); if (dt.Rows.Count < 1) { ht.Add("0", "用户不存在!"); } else { if (dt.Rows[0]["LoginPassword"].ToString() != OldPwd) { ht.Add("0", "原密码错误!"); } else { WebSiteCustomInfoModel model = new WebSiteCustomInfoModel(); model.ID = userID; model.LoginPassword = NewPwd; if (WebSiteCustomInfoDBHelper.UpdatePassWord(model)) { ht.Add("1", "修改成功!"); } else { ht.Add("0", "修改失败!"); } } } return(ht); }
/// <summary> /// 列表界面查询方法 /// </summary> /// <param name="pageIndex">当前页</param> /// <param name="pageCount">每页记录数</param> /// <param name="orderBy">排序方法</param> /// <param name="TotalCount">总记录数</param> /// <param name="model">实体类</param> /// <returns></returns> public static DataTable SelectListData(int pageIndex, int pageCount, string orderBy, ref int TotalCount , WebSiteCustomInfoModel model, string CompanyCD) { SqlCommand comm = new SqlCommand(); StringBuilder sql = new StringBuilder(@"SELECT wsci.ID,wsci.CustomID,wsci.LoginUserName,wsci.LoginPassword,wsci.Status,wsci.IsMember,ci.CustName FROM websitedba.WebSiteCustomInfo wsci INNER JOIN officedba.CustInfo ci ON wsci.CustomID=ci.ID AND ci.CompanyCD='" + CompanyCD + "'"); sql.Append(" WHERE 1=1 "); if (!String.IsNullOrEmpty(model.LoginUserName)) { sql.AppendFormat(" AND wsci.LoginUserName LIKE '%{0}%'", model.LoginUserName); } if (!String.IsNullOrEmpty(model.LoginPassword)) { sql.AppendFormat(" AND ci.CustName LIKE '%{0}%'", model.LoginPassword); } if (!String.IsNullOrEmpty(model.IsMember)) { sql.AppendFormat(" AND wsci.IsMember='{0}'", model.IsMember); } if (!String.IsNullOrEmpty(model.Status)) { sql.AppendFormat(" AND wsci.Status='{0}'", model.Status); } comm.CommandText = sql.ToString(); return(SqlHelper.PagerWithCommand(comm, pageIndex, pageCount, orderBy, ref TotalCount)); }
public bool ChangePwd(string newPwd, int id) { WebSiteCustomInfoModel item = new WebSiteCustomInfoModel(); item.ID = id; item.LoginPassword = newPwd; return(XBase.Business.CustomAPI.CustomWebSite.WebSiteCustomInfoBus.SetPassword(item)); }
/// <summary> /// 修改数据记录 /// </summary> /// <param name="model">实体类</param> /// <returns>修改操作的执行命令</returns> public static SqlCommand UpdateCommand(WebSiteCustomInfoModel model) { // SQL语句 SqlCommand comm = new SqlCommand(); comm.CommandText = C_UPDATE; // 参数设置 SqlParameter[] parameters = SetInsertAndUpdateParameters(); parameters = SetInsertAndUpdateParametersValue(parameters, model); comm.Parameters.AddRange(parameters); return(comm); }
/// <summary> /// 修改用户密码 /// </summary> /// <param name="model">实体类</param> /// <returns>修改数据是否成功:true成功,false不成功</returns> public static bool UpdatePassWord(WebSiteCustomInfoModel model) { bool returnValue = false; // 返回值 // SQL语句 string sqlStr = "UPDATE websitedba.WebSiteCustomInfo SET LoginPassword=@LoginPassword WHERE ID=@ID"; // 参数设置 SqlParameter[] parameters = SetInsertAndUpdateParameters(); parameters = SetInsertAndUpdateParametersValue(parameters, model); //执行SQL returnValue = SqlHelper.ExecuteTransSql(sqlStr, parameters) > 0; return(returnValue); }
/// <summary> /// 修改数据记录 /// </summary> /// <param name="model">实体类</param> /// <returns>修改数据是否成功:true成功,false不成功</returns> public static bool Update(WebSiteCustomInfoModel model) { bool returnValue = false; // 返回值 // SQL语句 StringBuilder sqlSentence = new StringBuilder(C_UPDATE); // 参数设置 SqlParameter[] parameters = SetInsertAndUpdateParameters(); parameters = SetInsertAndUpdateParametersValue(parameters, model); //执行SQL returnValue = SqlHelper.ExecuteTransSql(sqlSentence.ToString(), parameters) > 0; return(returnValue); }
/// <summary> /// 插入操作的执行命令 /// </summary> /// <param name="model">实体类</param> /// <returns>插入操作的执行命令</returns> public static SqlCommand InsertCommand(WebSiteCustomInfoModel model) { // SQL语句 SqlCommand comm = new SqlCommand(); comm.CommandText = C_INSERT + " SET @IndexID = @@IDENTITY "; // 参数设置 SqlParameter[] parameters = SetInsertAndUpdateParameters(); parameters = SetInsertAndUpdateParametersValue(parameters, model); comm.Parameters.AddRange(parameters); SqlParameter IndexID = new SqlParameter("@IndexID", SqlDbType.Int); IndexID.Direction = ParameterDirection.Output; comm.Parameters.Add(IndexID); return(comm); }
/// <summary> /// 插入数据记录 /// </summary> ///<param name="model">实体类</param> /// <returns>插入数据是否成功:true成功,false不成功</returns> public static bool Insert(WebSiteCustomInfoModel model) { ArrayList sqlList = new ArrayList(); SqlCommand cmd = WebSiteCustomInfoDBHelper.InsertCommand(model); sqlList.Add(cmd); if (SqlHelper.ExecuteTransWithArrayList(sqlList)) { int i = 0; if (int.TryParse(cmd.Parameters["@IndexID"].Value.ToString(), out i)) { model.ID = i; } return(true); } else { return(false); } }
/// <summary> /// 修改数据记录 /// </summary> ///<param name="model">实体类</param> /// <returns>修改数据是否成功:true成功,false不成功</returns> public static bool Update(WebSiteCustomInfoModel model) { return(WebSiteCustomInfoDBHelper.Update(model)); }
/// <summary> /// 列表界面查询方法 /// </summary> /// <param name="pageIndex">当前页</param> /// <param name="pageCount">每页记录数</param> /// <param name="orderBy">排序方法</param> /// <param name="TotalCount">总记录数</param> /// <param name="model">实体类</param> /// <returns></returns> public static DataTable SelectListData(int pageIndex, int pageCount, string orderBy, ref int TotalCount , WebSiteCustomInfoModel model, string CompanyCD) { return(WebSiteCustomInfoDBHelper.SelectListData(pageIndex, pageCount, orderBy, ref TotalCount, model, CompanyCD)); }
/// <summary> /// 修改用户密码 /// </summary> /// <param name="item"></param> /// <returns></returns> public static bool SetPassword(WebSiteCustomInfoModel item) { return(Data.CustomAPI.CustomWebSite.WebSiteCustomInfoDBHelper.UpdatePassWord(item)); }
/// <summary> /// 设置新增和修改的参数数组的值 /// </summary> /// <param name="parameters">参数数组</param> /// <param name="model">实体类</param> /// <returns>返回参数数组</returns> private static SqlParameter[] SetInsertAndUpdateParametersValue(SqlParameter[] parameters, WebSiteCustomInfoModel model) { if (!model.ID.HasValue) { parameters[m_iDCol].Value = System.DBNull.Value; } else { parameters[m_iDCol].Value = model.ID; // 主键,自动生成 } if (!model.CustomID.HasValue) { parameters[m_customIDCol].Value = System.DBNull.Value; } else { parameters[m_customIDCol].Value = model.CustomID; // 往来单位ID } parameters[m_loginUserNameCol].Value = model.LoginUserName; // 站点登陆用户名 parameters[m_loginPasswordCol].Value = model.LoginPassword; // 站点登陆密码 parameters[m_statusCol].Value = model.Status; // 状态1 启用0 禁用 parameters[m_isMemberCol].Value = model.IsMember; // 是否会员1 是0 否 return(parameters); }