using System; using System.Text; using System.Data; using System.Data.Common; using System.Linq; using System.Data.SqlClient; using System.Collections.Generic; using NetLibrary; using NetLibrary.Data; using NetLibrary.ReportPrint; using TradeModel; namespace TradeData { public class JC_UserInfoService { #region 保存 public static int Save(JC_UserInfo Model) { string tsql= @" if @UserId>0 begin Update [JC_UserInfo] set [Name]=@Name,[SpellName]=@SpellName,[EnglishName]=@EnglishName,[Sex]=@Sex,[UserName]=@UserName,[Password]=@Password,[UserType]=@UserType,[State]=@State,[CompanyId]=@CompanyId,[UserCode]=@UserCode,[Photo]=@Photo,[UpdateDate]=@UpdateDate,[Duty]=@Duty,[Mobile1]=@Mobile1,[Mobile2]=@Mobile2,[Mobile3]=@Mobile3,[UserCard]=@UserCard,DeptName=@DeptName where UserId=@UserId delete from JC_DepartUser where UserId=@UserId end else begin INSERT INTO [JC_UserInfo]([Name],[SpellName],[EnglishName],[Sex],[UserName],[Password],[UserType],[State],[CompanyId],[UserCode],[Photo],[UpdateDate],[Duty],[Mobile1],[Mobile2],[Mobile3],[UserCard],DeptName,[InDate],LoginCount)values(@Name,@SpellName,@EnglishName,@Sex,@UserName,@Password,@UserType,@State,@CompanyId,@UserCode,@Photo,@UpdateDate,@Duty,@Mobile1,@Mobile2,@Mobile3,@UserCard,@DeptName,@UpdateDate,0) set @UserId=SCOPE_IDENTITY() end select @UserId"; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(tsql); db.AddInParameter(cmd,"@UserId", DbType.Int32,Model.UserId); db.AddInParameter(cmd,"@Name", DbType.String,Model.Name); db.AddInParameter(cmd,"@SpellName", DbType.String,Model.SpellName); db.AddInParameter(cmd,"@EnglishName", DbType.String,Model.EnglishName); db.AddInParameter(cmd,"@Sex", DbType.String,Model.Sex); db.AddInParameter(cmd,"@UserName", DbType.String,Model.UserName); db.AddInParameter(cmd,"@Password", DbType.String,Model.Password); db.AddInParameter(cmd,"@UserType", DbType.String,Model.UserType); db.AddInParameter(cmd,"@State", DbType.Int32,Model.State); db.AddInParameter(cmd,"@CompanyId", DbType.Int32,Model.CompanyId); db.AddInParameter(cmd,"@UserCode", DbType.String,Model.UserCode); db.AddInParameter(cmd,"@Photo", DbType.String,Model.Photo); db.AddInParameter(cmd,"@UpdateDate", DbType.DateTime,DateTime.Now); db.AddInParameter(cmd,"@Duty", DbType.String,Model.Duty); db.AddInParameter(cmd,"@Mobile1", DbType.String,Model.Mobile1); db.AddInParameter(cmd,"@Mobile2", DbType.String,Model.Mobile2); db.AddInParameter(cmd,"@Mobile3", DbType.String,Model.Mobile3); db.AddInParameter(cmd,"@UserCard", DbType.String,Model.UserCard); db.AddInParameter(cmd, "@DeptName", DbType.String, Model.DeptName); Model.UserId = Convert.ToInt32(db.ExecuteScalar(cmd)); tsql = @" if(select count(0) from JC_DepartUser where DeptId=@DeptId and UserId=@UserId)=0 begin insert JC_DepartUser(DeptId,UserId,Duty)values(@DeptId,@UserId,@Duty) end "; cmd = db.GetSqlStringCommand(tsql); if (Model.ListModel != null) { foreach (var item in Model.ListModel) { cmd.Parameters.Clear(); db.AddInParameter(cmd, "@DeptId", DbType.Int32, item.DeptID); db.AddInParameter(cmd, "@UserId", DbType.Int32, Model.UserId); db.AddInParameter(cmd, "@Duty", DbType.String, item.Duty); db.ExecuteNonQuery(cmd); } } return Model.UserId.Value; } #endregion #region 保存 public static int Save2(JC_UserInfo2 Model) { string tsql = @" select top 1 @UserId=UserId from JC_UserInfo where CompanyId=@CompanyId and state=1 order by UserId if @UserId>0 begin Update [JC_UserInfo] set [Name]=@Name,[SpellName]=@SpellName,[EnglishName]=@EnglishName,[Sex]=@Sex,[UserName]=@UserName,[Password]=@Password,[UserType]=@UserType,[State]=@State,[CompanyId]=@CompanyId,[UserCode]=@UserCode,[LoginCount]=@LoginCount,[LastLoginTime]=@LastLoginTime,[LastLoginIp]=@LastLoginIp,[Photo]=@Photo,[UpdateDate]=@UpdateDate,[Duty]=@Duty,[Mobile1]=@Mobile1,[Mobile2]=@Mobile2,[Mobile3]=@Mobile3,[UserCard]=@UserCard,[InDate]=@InDate,[DeptName]=@DeptName,[IDCard]=@IDCard,[SchoolLevel]=@SchoolLevel,[School]=@School,[BornDate]=@BornDate,[BornAddr]=@BornAddr,[ContractDate]=@ContractDate,[JoinDate]=@JoinDate,[FormalDate]=@FormalDate,[IsMarry]=@IsMarry,[IsBaby]=@IsBaby,[HuKou]=@HuKou,[HuKouAddr]=@HuKouAddr,[NowAddr]=@NowAddr,[IsRoom]=@IsRoom,[RoomAddr]=@RoomAddr,[Political]=@Political,[DeptId]=@DeptId,[Traffic]=@Traffic,[QQ]=@QQ,[Email]=@Email,[EmployeeType]=@EmployeeType,[Holidays]=@Holidays,[IsLogin]=@IsLogin,[WorkDesc]=@WorkDesc,[AnnualDay]=@AnnualDay,[MoodDay]=@MoodDay where UserId=@UserId end else begin INSERT INTO [JC_UserInfo]([Name],[SpellName],[EnglishName],[Sex],[UserName],[Password],[UserType],[State],[CompanyId],[UserCode],[LoginCount],[LastLoginTime],[LastLoginIp],[Photo],[UpdateDate],[Duty],[Mobile1],[Mobile2],[Mobile3],[UserCard],[InDate],[DeptName],[IDCard],[SchoolLevel],[School],[BornDate],[BornAddr],[ContractDate],[JoinDate],[FormalDate],[IsMarry],[IsBaby],[HuKou],[HuKouAddr],[NowAddr],[IsRoom],[RoomAddr],[Political],[DeptId],[Traffic],[QQ],[Email],[EmployeeType],[Holidays],[IsLogin],[WorkDesc],[AnnualDay],[MoodDay])values(@Name,@SpellName,@EnglishName,@Sex,@UserName,@Password,@UserType,@State,@CompanyId,@UserCode,@LoginCount,@LastLoginTime,@LastLoginIp,@Photo,@UpdateDate,@Duty,@Mobile1,@Mobile2,@Mobile3,@UserCard,@InDate,@DeptName,@IDCard,@SchoolLevel,@School,@BornDate,@BornAddr,@ContractDate,@JoinDate,@FormalDate,@IsMarry,@IsBaby,@HuKou,@HuKouAddr,@NowAddr,@IsRoom,@RoomAddr,@Political,@DeptId,@Traffic,@QQ,@Email,@EmployeeType,@Holidays,@IsLogin,@WorkDesc,@AnnualDay,@MoodDay) set @UserId=SCOPE_IDENTITY() end select @UserId"; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(tsql); db.AddInParameter(cmd, "@UserId", DbType.Int32, Model.UserId); db.AddInParameter(cmd, "@Name", DbType.String, Model.Name); db.AddInParameter(cmd, "@SpellName", DbType.String, Model.SpellName); db.AddInParameter(cmd, "@EnglishName", DbType.String, Model.EnglishName); db.AddInParameter(cmd, "@Sex", DbType.String, Model.Sex); db.AddInParameter(cmd, "@UserName", DbType.String, Model.UserName); db.AddInParameter(cmd, "@Password", DbType.String, Model.Password); db.AddInParameter(cmd, "@UserType", DbType.String, Model.UserType); db.AddInParameter(cmd, "@State", DbType.Int32, Model.State); db.AddInParameter(cmd, "@CompanyId", DbType.Int32, Model.CompanyId); db.AddInParameter(cmd, "@UserCode", DbType.String, Model.UserCode); db.AddInParameter(cmd, "@LoginCount", DbType.Int32, Model.LoginCount); db.AddInParameter(cmd, "@LastLoginTime", DbType.DateTime, Model.LastLoginTime); db.AddInParameter(cmd, "@LastLoginIp", DbType.String, Model.LastLoginIp); db.AddInParameter(cmd, "@Photo", DbType.String, Model.Photo); db.AddInParameter(cmd, "@UpdateDate", DbType.DateTime, Model.UpdateDate); db.AddInParameter(cmd, "@Duty", DbType.String, Model.Duty); db.AddInParameter(cmd, "@Mobile1", DbType.String, Model.Mobile1); db.AddInParameter(cmd, "@Mobile2", DbType.String, Model.Mobile2); db.AddInParameter(cmd, "@Mobile3", DbType.String, Model.Mobile3); db.AddInParameter(cmd, "@UserCard", DbType.String, Model.UserCard); db.AddInParameter(cmd, "@InDate", DbType.DateTime, Model.InDate); db.AddInParameter(cmd, "@DeptName", DbType.String, Model.DeptName); db.AddInParameter(cmd, "@IDCard", DbType.String, Model.IDCard); db.AddInParameter(cmd, "@SchoolLevel", DbType.String, Model.SchoolLevel); db.AddInParameter(cmd, "@School", DbType.String, Model.School); db.AddInParameter(cmd, "@BornDate", DbType.DateTime, Model.BornDate); db.AddInParameter(cmd, "@BornAddr", DbType.String, Model.BornAddr); db.AddInParameter(cmd, "@ContractDate", DbType.DateTime, Model.ContractDate); db.AddInParameter(cmd, "@JoinDate", DbType.DateTime, Model.JoinDate); db.AddInParameter(cmd, "@FormalDate", DbType.DateTime, Model.FormalDate); db.AddInParameter(cmd, "@IsMarry", DbType.String, Model.IsMarry); db.AddInParameter(cmd, "@IsBaby", DbType.String, Model.IsBaby); db.AddInParameter(cmd, "@HuKou", DbType.String, Model.HuKou); db.AddInParameter(cmd, "@HuKouAddr", DbType.String, Model.HuKouAddr); db.AddInParameter(cmd, "@NowAddr", DbType.String, Model.NowAddr); db.AddInParameter(cmd, "@IsRoom", DbType.Int32, Model.IsRoom); db.AddInParameter(cmd, "@RoomAddr", DbType.String, Model.RoomAddr); db.AddInParameter(cmd, "@Political", DbType.String, Model.Political); db.AddInParameter(cmd, "@DeptId", DbType.Int32, Model.DeptId); db.AddInParameter(cmd, "@Traffic", DbType.String, Model.Traffic); db.AddInParameter(cmd, "@QQ", DbType.String, Model.QQ); db.AddInParameter(cmd, "@Email", DbType.String, Model.Email); db.AddInParameter(cmd, "@EmployeeType", DbType.String, Model.EmployeeType); db.AddInParameter(cmd, "@Holidays", DbType.Int32, Model.Holidays); db.AddInParameter(cmd, "@IsLogin", DbType.Int32, Model.IsLogin); db.AddInParameter(cmd, "@WorkDesc", DbType.String, Model.WorkDesc); db.AddInParameter(cmd, "@AnnualDay", DbType.Int32, Model.AnnualDay); db.AddInParameter(cmd, "@MoodDay", DbType.Int32, Model.MoodDay); int a = Convert.ToInt32(db.ExecuteScalar(cmd)); return a; } #endregion #region 删除 public static void Delete(int UserId) { string tsql=@" update JC_UserInfo set state=0 where UserId=@UserId "; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(tsql); db.AddInParameter(cmd,"@UserId", DbType.Int32,UserId); db.ExecuteNonQuery(cmd); } #endregion #region 返回 public static OA_Leave GetUserLeave(int UserId) { OA_Leave model = null; string tsql = @"select top 1 * from OA_Leave where SDate<=GETDATE() and EDate>=GETDATE() and InUserId=@UserId"; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(tsql); db.AddInParameter(cmd, "@UserId", DbType.Int32, UserId); DataTable tb = db.ExecuteDataTable(cmd); if (tb.Rows.Count > 0) model = tb.Rows[0].ToModel(); return model; } #endregion #region 离职 public static void UpdateDelete(string UserIds) { string tsql = @" update JC_UserInfo set state=2 where UserId in ("+UserIds+")"; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(tsql); db.ExecuteNonQuery(cmd); } #endregion #region 返回Model public static JC_UserInfo GetModel(int UserId) { JC_UserInfo model = null; string tsql= @" select * from JC_UserInfo where UserId=@UserId select a.UserId,a.DeptId,a.Duty,b.DeptName from JC_DepartUser a inner join JC_DepartMent b on a.DeptId=b.DeptId where a.UserId=@UserId "; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(tsql); db.AddInParameter(cmd,"@UserId", DbType.Int32,UserId); DataSet ds=db.ExecuteDataSet(cmd); if (ds.Tables[0].Rows.Count > 0) { model = ds.Tables[0].Rows[0].ToModel(); if (model.State == 0) model.StateName = "删除"; if (model.State == 1) model.StateName = "正常"; if (model.State == 2) model.StateName = "限制登录"; if (model.State == 3) model.StateName = "离职"; model.ListModel = ds.Tables[1].ToList(); } return model; } #endregion #region 分页查询 public static List GetListJC_UserInfo(int DeptID,RefParameterCollection where, int PageIndex, int PageSize, string Sort, out int RowCount) { if (where == null) where = new RefParameterCollection(); QueryService ser = new QueryService(); ser.Fields = @"UserId=cast(a.UserId as int),a.Name,a.SpellName,a.EnglishName,a.Sex,a.UserName,a.Password,a.UserType,a.State,a.CompanyId,a.UserCode,a.LoginCount,a.LastLoginTime,a.LastLoginIp,a.Photo,a.UpdateDate,a.Duty,a.Mobile1,a.Mobile2,a.Mobile3,a.UserCard,a.InDate,a.DeptName"; ser.Tables = @"JC_UserInfo a"; ser.Filter = where.GetWhere(System.Data.CommandType.Text); if (DeptID > 0) ser.Filter += " and UserId in (select UserId from JC_DepartUser where DeptID=@DeptID)"; ser.PageIndex = PageIndex; ser.PageSize = PageSize; ser.Sort = Sort; ser.KeyName = "UserId"; string tsql=ser.GetText(); where.AddOutParameter("RowCount",System.Data.DbType.Int32);; List ListModel = null; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(tsql); db.AddInParameter(cmd, where); if (DeptID > 0) db.AddInParameter(cmd, "@DeptID", DbType.Int32, DeptID); DataTable tb=db.ExecuteDataTable(cmd); RowCount = Convert.ToInt32(cmd.Parameters["@RowCount"].Value); ListModel=tb.ToList(); foreach (var model in ListModel) { if (model.State == 0) model.StateName = "删除"; if (model.State == 1) model.StateName = "正常"; if (model.State == 2) model.StateName = "限制登录"; if (model.State == 3) model.StateName = "离职"; } return ListModel; } #endregion #region 分页查询 public static List GetListJC_UserInfoForTM(RefParameterCollection where, int PageIndex, int PageSize, string Sort, out int RowCount) { if (where == null) where = new RefParameterCollection(); QueryService ser = new QueryService(); ser.Fields = @"UserId=cast(a.UserId as int),a.Name,a.SpellName,a.EnglishName,a.Sex,a.UserName,a.Password,a.UserType,a.State,a.CompanyId,a.UserCode,a.LoginCount,a.LastLoginTime,a.LastLoginIp,a.Photo,a.UpdateDate,a.Duty,a.Mobile1,a.Mobile2,a.Mobile3,a.UserCard,a.InDate,a.DeptName,a.SchoolLevel,a.School,a.BornDate,a.BornAddr,a.ContractDate,a.IsMarry,a.IsBaby,a.HuKou,a.HuKouAddr,a.NowAddr,a.JoinDate,a.FormalDate,a.IsRoom,a.RoomAddr,a.Political,a.DeptId,a.Traffic,a.QQ,a.Email,a.EmployeeType,StateName=case when a.state=1 then '在职' when a.state=2 then '离职' else '其它' end,a.IDCard,a.Holidays,a.IsLogin,a.WorkDesc,a.GroupName,a.guserid"; ser.Tables = @"JC_UserInfo a"; ser.Filter = where.GetWhere(System.Data.CommandType.Text); ser.PageIndex = PageIndex; ser.PageSize = PageSize; ser.Sort = Sort; ser.KeyName = "UserId"; string tsql = ser.GetText(); where.AddOutParameter("RowCount", System.Data.DbType.Int32); ; List ListModel = null; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(tsql); db.AddInParameter(cmd, where); DataTable tb = db.ExecuteDataTable(cmd); RowCount = Convert.ToInt32(cmd.Parameters["@RowCount"].Value); ListModel = tb.ToList(); return ListModel; } #endregion #region 分页查询 public List GetUserInfoList(RefParameterCollection where) { if (where == null) where = new RefParameterCollection(); QueryOrdService ser = new QueryOrdService(); ser.Fields = @"UserId=cast(a.UserId as int),a.Name,a.SpellName,a.EnglishName,a.Sex,a.UserName,a.Password,a.UserType,a.State,a.CompanyId,a.UserCode,a.LoginCount,a.LastLoginTime,a.LastLoginIp,a.Photo,a.UpdateDate,a.Duty,a.Mobile1,a.Mobile2,a.Mobile3,a.UserCard,a.InDate"; ser.Tables = @"JC_UserInfo a"; ser.Filter = where.GetWhere(System.Data.CommandType.Text); ser.Sort = "UserId"; string tsql = ser.GetText(); List ListModel = null; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(tsql); db.AddInParameter(cmd, where); DataTable tb = db.ExecuteDataTable(cmd); ListModel = tb.ToList(); return ListModel; } #endregion #region 判断姓名是否重复 public static bool CheckName(int UserID, string Name) { string tsql = @"select count(0) from JC_UserInfo where UserID<>@UserID and Name=@Name and State>0"; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(tsql); db.AddInParameter(cmd, "@UserID", DbType.Int32, UserID); db.AddInParameter(cmd, "@Name", DbType.String, Name); int a = Convert.ToInt32(db.ExecuteScalar(cmd)); if (a == 0) return true; return false; } #endregion #region 判断工号是否重复 public static bool CheckUserCode(int UserID, string UserCode) { string tsql = @"select count(0) from JC_UserInfo where UserID<>@UserID and UserCode=@UserCode and State>0"; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(tsql); db.AddInParameter(cmd, "@UserID", DbType.Int32, UserID); db.AddInParameter(cmd, "@UserCode", DbType.String, UserCode); int a = Convert.ToInt32(db.ExecuteScalar(cmd)); if (a == 0) return true; return false; } #endregion #region 判断用户名是否重复 public static bool CheckUserName(int UserID, string UserName) { string tsql = @"select count(0) from JC_UserInfo where UserID<>@UserID and UserName=@UserName and State>0"; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(tsql); db.AddInParameter(cmd, "@UserID", DbType.Int32, UserID); db.AddInParameter(cmd, "@UserName", DbType.String, UserName); int a = Convert.ToInt32(db.ExecuteScalar(cmd)); if (a == 0) return true; return false; } #endregion #region 保存用户信息 public static int SaveUserInfoForTM(JC_UserInfoNew Model) { string tsql = @" if @UserId>0 begin Update [JC_UserInfo] set [Name]=@Name,[SpellName]=@SpellName,[EnglishName]=@EnglishName,[Sex]=@Sex,[UserName]=@UserName,[Password]=@Password,[State]=@State,[CompanyId]=@CompanyId,[UserCode]=@UserCode,[LoginCount]=@LoginCount,[LastLoginTime]=@LastLoginTime,[LastLoginIp]=@LastLoginIp,[Photo]=@Photo,[UpdateDate]=@UpdateDate,[Duty]=@Duty,[Mobile1]=@Mobile1,[Mobile2]=@Mobile2,[Mobile3]=@Mobile3,[UserCard]=@UserCard,[InDate]=@InDate,[DeptName]=@DeptName,[SchoolLevel]=@SchoolLevel,[School]=@School,[BornDate]=@BornDate,[BornAddr]=@BornAddr,[ContractDate]=@ContractDate,[IsMarry]=@IsMarry,[IsBaby]=@IsBaby,[HuKou]=@HuKou,[HuKouAddr]=@HuKouAddr,[NowAddr]=@NowAddr,[JoinDate]=@JoinDate,[FormalDate]=@FormalDate,[IsRoom]=@IsRoom,[RoomAddr]=@RoomAddr,[Political]=@Political,[DeptId]=@DeptId,[Traffic]=@Traffic,[QQ]=@QQ,[Email]=@Email,[EmployeeType]=@EmployeeType,[IDCard]=@IDCard,[Holidays]=@Holidays,[IsLogin]=@IsLogin where UserId=@UserId end else begin INSERT INTO [JC_UserInfo]([Name],[SpellName],[EnglishName],[Sex],[UserName],[Password],[UserType],[State],[CompanyId],[UserCode],[LoginCount],[LastLoginTime],[LastLoginIp],[Photo],[UpdateDate],[Duty],[Mobile1],[Mobile2],[Mobile3],[UserCard],[InDate],[DeptName],[SchoolLevel],[School],[BornDate],[BornAddr],[ContractDate],[IsMarry],[IsBaby],[HuKou],[HuKouAddr],[NowAddr],[JoinDate],[FormalDate],[IsRoom],[RoomAddr],[Political],[DeptId],[Traffic],[QQ],[Email],[EmployeeType],[IDCard],[Holidays],[IsLogin])values(@Name,@SpellName,@EnglishName,@Sex,@UserName,@Password,@UserType,@State,@CompanyId,@UserCode,@LoginCount,@LastLoginTime,@LastLoginIp,@Photo,@UpdateDate,@Duty,@Mobile1,@Mobile2,@Mobile3,@UserCard,@InDate,@DeptName,@SchoolLevel,@School,@BornDate,@BornAddr,@ContractDate,@IsMarry,@IsBaby,@HuKou,@HuKouAddr,@NowAddr,@JoinDate,@FormalDate,@IsRoom,@RoomAddr,@Political,@DeptId,@Traffic,@QQ,@Email,@EmployeeType,@IDCard,@Holidays,@IsLogin) set @UserId=SCOPE_IDENTITY() if @UserCode is null or @UserCode='' begin update JC_UserInfo set UserCode=@UserId where UserId=@UserId end end select @UserId"; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(tsql); db.AddInParameter(cmd, "@UserId", DbType.Int32, Model.UserId); db.AddInParameter(cmd, "@Name", DbType.String, Model.Name); db.AddInParameter(cmd, "@SpellName", DbType.String, Model.SpellName); db.AddInParameter(cmd, "@EnglishName", DbType.String, Model.EnglishName); db.AddInParameter(cmd, "@Sex", DbType.String, Model.Sex); db.AddInParameter(cmd, "@UserName", DbType.String, Model.UserName); db.AddInParameter(cmd, "@Password", DbType.String, Model.Password); db.AddInParameter(cmd, "@UserType", DbType.String, Model.UserType); db.AddInParameter(cmd, "@State", DbType.Int32, Model.State); db.AddInParameter(cmd, "@CompanyId", DbType.Int32, Model.CompanyId); db.AddInParameter(cmd, "@UserCode", DbType.String, Model.UserCode); db.AddInParameter(cmd, "@LoginCount", DbType.Int32, Model.LoginCount); db.AddInParameter(cmd, "@LastLoginTime", DbType.DateTime, Model.LastLoginTime); db.AddInParameter(cmd, "@LastLoginIp", DbType.String, Model.LastLoginIp); db.AddInParameter(cmd, "@Photo", DbType.String, Model.Photo); db.AddInParameter(cmd, "@UpdateDate", DbType.DateTime, Model.UpdateDate); db.AddInParameter(cmd, "@Duty", DbType.String, Model.Duty); db.AddInParameter(cmd, "@Mobile1", DbType.String, Model.Mobile1); db.AddInParameter(cmd, "@Mobile2", DbType.String, Model.Mobile2); db.AddInParameter(cmd, "@Mobile3", DbType.String, Model.Mobile3); db.AddInParameter(cmd, "@UserCard", DbType.String, Model.UserCard); db.AddInParameter(cmd, "@InDate", DbType.DateTime, Model.InDate); db.AddInParameter(cmd, "@DeptName", DbType.String, Model.DeptName); db.AddInParameter(cmd, "@SchoolLevel", DbType.String, Model.SchoolLevel); db.AddInParameter(cmd, "@School", DbType.String, Model.School); db.AddInParameter(cmd, "@BornDate", DbType.DateTime, Model.BornDate); db.AddInParameter(cmd, "@BornAddr", DbType.String, Model.BornAddr); db.AddInParameter(cmd, "@ContractDate", DbType.DateTime, Model.ContractDate); db.AddInParameter(cmd, "@IsMarry", DbType.String, Model.IsMarry); db.AddInParameter(cmd, "@IsBaby", DbType.String, Model.IsBaby); db.AddInParameter(cmd, "@HuKou", DbType.String, Model.HuKou); db.AddInParameter(cmd, "@HuKouAddr", DbType.String, Model.HuKouAddr); db.AddInParameter(cmd, "@NowAddr", DbType.String, Model.NowAddr); db.AddInParameter(cmd, "@JoinDate", DbType.DateTime, Model.JoinDate); db.AddInParameter(cmd, "@FormalDate", DbType.DateTime, Model.FormalDate); db.AddInParameter(cmd, "@IsRoom", DbType.Int32, Model.IsRoom); db.AddInParameter(cmd, "@RoomAddr", DbType.String, Model.RoomAddr); db.AddInParameter(cmd, "@Political", DbType.String, Model.Political); db.AddInParameter(cmd, "@DeptId", DbType.Int32, Model.DeptId); db.AddInParameter(cmd, "@Traffic", DbType.String, Model.Traffic); db.AddInParameter(cmd, "@QQ", DbType.String, Model.QQ); db.AddInParameter(cmd, "@Email", DbType.String, Model.Email); db.AddInParameter(cmd, "@EmployeeType", DbType.String, Model.EmployeeType); db.AddInParameter(cmd, "@IDCard", DbType.String, Model.IDCard); db.AddInParameter(cmd, "@Holidays", DbType.Int32, Model.Holidays); db.AddInParameter(cmd, "@IsLogin", DbType.Int32, Model.IsLogin); int a = Convert.ToInt32(db.ExecuteScalar(cmd)); return a; } #endregion #region 保存员工工作内容 public static void SaveUserWork(JC_UserInfoNew Model) { string tsql = @" Update [JC_UserInfo] set [WorkDesc]=@WorkDesc where UserId=@UserId "; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(tsql); db.AddInParameter(cmd, "@UserId", DbType.Int32, Model.UserId); db.AddInParameter(cmd, "@WorkDesc", DbType.String, Model.WorkDesc); db.ExecuteNonQuery(cmd); } #endregion #region 读取部门员工 public static List GetDeptUser(int UserId) { string tsql = @" if @UserId>0 begin declare @DeptId int set @DeptId=0 select @DeptId=DeptId from JC_UserInfo where UserId=@UserId select UserId,Name,WorkDesc from JC_UserInfo where deptid=@DeptId and State=1 end else begin select UserId,Name,WorkDesc from JC_UserInfo where deptid=@DeptId and State=1 end "; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(tsql); db.AddInParameter(cmd, "@UserId", DbType.Int32, UserId); DataTable tb = db.ExecuteDataTable(cmd); return tb.ToList(); } #endregion #region 读取部门员工 public static JC_UserInfoNew GetUserModel(string UserCode) { JC_UserInfoNew model = null; string tsql = @" select top 1 UserId,Name from JC_UserInfo where UserCode=@UserCode and State=1 "; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(tsql); db.AddInParameter(cmd, "@UserCode", DbType.String, UserCode); DataTable tb = db.ExecuteDataTable(cmd); if (tb.Rows.Count > 0) model = tb.Rows[0].ToModel(); return model; } #endregion } }