/// <summary> /// 复杂查询 /// </summary> /// <param name="model">查询对象</param> /// <param name="Orders">排序字典key:排序的字段,value:asc升序/desc降序</param> /// <param name="PageSize">每页行数,默认15</param> /// <param name="PageIndex">当前页码,默认100</param> /// <returns></returns> public DataGrid <T_UserModel> Search(T_UserModel model, Dictionary <string, string> Orders = null, int PageSize = 15, int PageIndex = 100) { Expression <Func <T_User, bool> > where = null; //最终查询条件 var lambdaList = new List <Expression <Func <T_User, bool> > >(); //lambda查询条件集合 int total = 0; //总行数 if (model.StaffName != null) { lambdaList.Add(c => c.StaffName.Contains(model.StaffName)); } if (model.CompanyId != null && model.CompanyId > 0) { lambdaList.Add(c => c.CompanyId == model.CompanyId); } //将集合表达式树转换成Expression表达式树 MyVisitor <T_User, T_User> visitor = new MyVisitor <T_User, T_User>(); where = visitor.Modify(lambdaList); var list = dal.Search(out total, where, Orders, PageSize, PageIndex).DTOList().ToList(); var result = new DataGrid <T_UserModel>() { rows = list, total = total }; return(result); }
public int Add(T_UserModel t_UserModel) { var sqlparams = new SqlParameter[] { new SqlParameter("@UserName", t_UserModel.UserName), new SqlParameter("@UMail", t_UserModel.UMail), new SqlParameter("@UPhone", t_UserModel.UPhone), new SqlParameter("@UPassWord", t_UserModel.UPassWord), new SqlParameter("@Status", 1), new SqlParameter("@CreateTime", DateTime.Now), new SqlParameter("@UpdateTime", DateTime.Now) }; string sql = @" INSERT INTO [T_User] ( [UserName] ,[UMail] ,[UPhone] ,[UPassWord] ,[Status] ,[CreateTime] ,[UpdateTime]) VALUES ( @UserName ,@UMail ,@UPhone ,@UPassWord ,@Status ,@CreateTime ,@UpdateTime )"; return(SqlHelper.ExecuteNonQuery(ConnectionString.WTVDns, CommandType.Text, sql, sqlparams)); }
public static T_User ToModel(this T_UserModel node) { return(new T_User() { Id = node.Id, LoginId = node.LoginId, // Password = Encrypt.Encrypto(node.Password), Password = node.Password, StaffName = node.StaffName, Alias = node.Alias, Sex = node.Sex, RoleId = node.RoleId, Enable = node.Enable, BirthDate = node.BirthDate, Blk = node.Blk, BuildingName = node.BuildingName, CompanyId = node.CompanyId, Dateoined = node.Dateoined, DateResignation = node.DateResignation, Email = node.Email, Fax = node.Fax, GroupId = node.GroupId, Marital = node.Marital, Mobile = node.Mobile, Nationality = node.Nationality, Phone = node.Phone, Position = node.Position, PostalCode = node.PostalCode, StreetName = node.StreetName, AcctCode = node.AcctCode, Unit = node.Unit, }); }
public static T_UserModel DTO(this T_User node) { if (node == null) { return(null); } var model = new T_UserModel() { Id = node.Id, LoginId = node.LoginId, Password = Encrypt.Decrypto(node.Password), StaffName = node.StaffName, Alias = node.Alias, Sex = node.Sex, RoleId = node.RoleId, BirthDate = node.BirthDate, Blk = node.Blk, BuildingName = node.BuildingName, CompanyId = node.CompanyId, Dateoined = node.Dateoined, DateResignation = node.DateResignation, Email = node.Email, Fax = node.Fax, GroupId = node.GroupId, Marital = node.Marital, Mobile = node.Mobile, Nationality = node.Nationality, Phone = node.Phone, Position = node.Position, PostalCode = node.PostalCode, StreetName = node.StreetName, Unit = node.Unit, Enable = node.Enable, AcctCode = node.AcctCode, CompanyName = node.Company != null ? node.Company.Company : null, RoleName = node.Role != null ? node.Role.Name : null, AppointmentAllowance = node.AppointmentAllowance, BankName = node.BankName, BankNumber = node.BankNumber, Commission = node.Commission, EmployeeCpf = node.EmployeeCpf, EmployerCpf = node.EmployerCpf, FixedAllowance = node.FixedAllowance, Salary = node.Salary, }; return(model); }
public int Add(T_UserModel r_UserModel) { var sqlparams = new SqlParameter[] { new SqlParameter("@UserId", r_UserModel.UserId), new SqlParameter("@UserName", r_UserModel.UserName), }; string sql = @"INSERT INTO [T_User] ([UserId] ,[UserName]) VALUES (@UserId ,@UserName) "; return(SqlHelper.ExecuteNonQuery(ConnectionString.WTVDns, CommandType.Text, sql, sqlparams)); }
public int Add(T_UserModel t_UserModel) { return(new Data.T_UserDAL().Add(t_UserModel)); }
public int Add(T_UserModel r_UserModel) { return(new T_UserDAL().Add(r_UserModel)); }
public int DeleteData(T_UserModel model) { return(this.Delete(model.Id)); }
/// <summary> /// 修改信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public int EditData(T_UserModel model) { return(this.Edit(model.ToModel())); }
public int AddData(T_UserModel model) { return(this.Add(model.ToModel())); }