public int Add(Model.CrmUserModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Crm_User(UName,UPwd,Codes,PId,CId,States,Types,Notes,CTime,LTime) values("); strSql.Append("@UName,@UPwd,@Codes,@PId,@CId,@States,@Types,@Notes,@CTime,@LTime);select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@UName", model.UName), new SqlParameter("@UPwd", model.UPwd), new SqlParameter("@Codes", model.Codes), new SqlParameter("@PId", model.PId), new SqlParameter("@CId", model.CId), new SqlParameter("@States", model.States), new SqlParameter("@Types", model.Types), new SqlParameter("@Notes", model.Notes), new SqlParameter("@CTime", model.CTime), new SqlParameter("@LTime", model.LTime) }; try { return(Convert.ToInt16(SqlHelper.ExecuteScalar(conn, CommandType.Text, strSql.ToString(), parameters))); } catch (Exception) { return(0); } }
public int UpdatePwd(Model.CrmUserModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append(" update Crm_User set UPwd=@UPwd where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@UPwd", model.UPwd), new SqlParameter("@Id", model.Id) }; return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters)); }
public int UpdateCity(Model.CrmUserModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append(" update Crm_User set PId=@PId, CId=@CId where UName=@UName "); SqlParameter[] parameters = { new SqlParameter("@PId", model.PId), new SqlParameter("@CId", model.CId), new SqlParameter("@UName", model.UName) }; return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters)); }
public int Update(Model.CrmUserModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append(" update Crm_User set UName=@UName,UPwd=@UPwd,Codes=@Codes,PId=@PId,CId=@CId,States=@States,Types=@Types,Notes=@Notes where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@UName", model.UName), new SqlParameter("@UPwd", model.UPwd), new SqlParameter("@Codes", model.Codes), new SqlParameter("@PId", model.PId), new SqlParameter("@CId", model.CId), new SqlParameter("@States", model.States), new SqlParameter("@Types", model.Types), new SqlParameter("@Notes", model.Notes), new SqlParameter("@Id", model.Id) }; return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters)); }
public Model.CrmUserModel GetUName(string UName, string sqlstr) { StringBuilder sql = new StringBuilder("select * from Crm_User where UName='" + UName + "' " + sqlstr); SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.Text, sql.ToString()); Model.CrmUserModel model = new Model.CrmUserModel(); model.Id = 0; if (dr.Read()) { model.Id = Convert.ToInt32(dr["Id"].ToString()); model.UName = dr["UName"].ToString(); model.UPwd = dr["UPwd"].ToString(); model.Codes = dr["Codes"].ToString(); model.PId = Convert.ToInt32(dr["PId"].ToString()); model.CId = Convert.ToInt32(dr["CId"].ToString()); model.States = Convert.ToInt32(dr["States"].ToString()); model.Types = Convert.ToInt32(dr["Types"].ToString()); model.Notes = dr["Notes"].ToString(); model.CTime = DateTime.Parse(dr["CTime"].ToString()); model.LTime = DateTime.Parse(dr["LTime"].ToString()); } return(model); }