/// <summary> /// 得到一个对象实体 /// </summary> public BWJS.Model.Users GetModel(int UserID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from Users "); strSql.Append(" where UserID=@UserID"); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.Int, 4) }; parameters[0].Value = UserID; BWJS.Model.Users model = new BWJS.Model.Users(); DataSet ds = BWJSHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool UpdateDepartmentID(BWJS.Model.Users model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Users set "); strSql.Append(" DepartmentID = @DepartmentID , "); strSql.Append(" RecordUpdateUserID = @RecordUpdateUserID , "); strSql.Append(" RecordIsDelete = @RecordIsDelete , "); strSql.Append(" RecordUpdateTime = @RecordUpdateTime "); strSql.Append(" where UserID=@UserID;"); strSql.Append(@" UPDATE MofangDB.dbo.OrderApply SET DepartmentID = @DepartmentID WHERE ((DepartmentID = NULL) or (DepartmentID=0)) AND UserID = @UserID AND RecordIsDelete = 0 ; "); SqlParameter[] parameters = { new SqlParameter("@UserID", model.UserID), new SqlParameter("@DepartmentID", model.DepartmentID), new SqlParameter("@RecordUpdateUserID", model.RecordUpdateUserID), new SqlParameter("@RecordIsDelete", model.RecordIsDelete), new SqlParameter("@RecordUpdateTime", model.RecordUpdateTime) }; int rows = BWJSHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BWJS.Model.Users model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Users("); strSql.Append("UserType,GravatarResourceID,LastAccessIP,CompanyName,CreatUserID,RecordUpdateUserID,RecordIsDelete,RecordUpdateTime,RecordCreateTime,CardID,LoginName,ReginId,IsLocked,IsLogined,LoginTimes,ProvinceID,CityID,CountyID,Address,Password,UserName,Sex,Phone,QQ,Wechat,Email,DepartmentID,SId"); strSql.Append(") values ("); strSql.Append("@UserType,@GravatarResourceID,@LastAccessIP,@CompanyName,@CreatUserID,@RecordUpdateUserID,@RecordIsDelete,@RecordUpdateTime,@RecordCreateTime,@CardID,@LoginName,@ReginId,@IsLocked,@IsLogined,@LoginTimes,@ProvinceID,@CityID,@CountyID,@Address,@Password,@UserName,@Sex,@Phone,@QQ,@Wechat,@Email,@DepartmentID,@SId"); strSql.Append(") "); strSql.Append(";select SCOPE_IDENTITY()"); SqlParameter[] parameters = { new SqlParameter("@UserType", model.UserType), new SqlParameter("@GravatarResourceID", model.GravatarResourceID), new SqlParameter("@LastAccessIP", model.LastAccessIP), new SqlParameter("@CompanyName", model.CompanyName), new SqlParameter("@CreatUserID", model.CreatUserID), new SqlParameter("@RecordUpdateUserID", model.RecordUpdateUserID), new SqlParameter("@RecordIsDelete", model.RecordIsDelete), new SqlParameter("@RecordUpdateTime", model.RecordUpdateTime), new SqlParameter("@RecordCreateTime", model.RecordCreateTime), new SqlParameter("@CardID", model.CardID), new SqlParameter("@LoginName", model.LoginName), new SqlParameter("@ReginId", model.ReginId), new SqlParameter("@IsLocked", model.IsLocked), new SqlParameter("@IsLogined", model.IsLogined), new SqlParameter("@LoginTimes", model.LoginTimes), new SqlParameter("@ProvinceID", model.ProvinceID), new SqlParameter("@CityID", model.CityID), new SqlParameter("@CountyID", model.CountyID), new SqlParameter("@Address", model.Address), new SqlParameter("@Password", model.Password), new SqlParameter("@UserName", model.UserName), new SqlParameter("@Sex", model.Sex), new SqlParameter("@Phone", model.Phone), new SqlParameter("@QQ", model.QQ), new SqlParameter("@Wechat", model.Wechat), new SqlParameter("@Email", model.Email), new SqlParameter("@DepartmentID", model.DepartmentID), new SqlParameter("@SId", model.SId) }; object obj = BWJSHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
public Users GetModelBySId(int sId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from Users "); strSql.Append(" where SId=@sId and RecordIsDelete=0"); SqlParameter[] parameters = { new SqlParameter("@sId", SqlDbType.Int, 4) }; parameters[0].Value = sId; BWJS.Model.Users model = new BWJS.Model.Users(); DataSet ds = BWJSHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BWJS.Model.Users model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Users set "); strSql.Append(" UserType = @UserType , "); strSql.Append(" GravatarResourceID = @GravatarResourceID , "); strSql.Append(" LastAccessIP = @LastAccessIP , "); strSql.Append(" CompanyName = @CompanyName , "); strSql.Append(" CreatUserID = @CreatUserID , "); strSql.Append(" RecordUpdateUserID = @RecordUpdateUserID , "); strSql.Append(" RecordIsDelete = @RecordIsDelete , "); strSql.Append(" RecordUpdateTime = @RecordUpdateTime , "); strSql.Append(" RecordCreateTime = @RecordCreateTime , "); strSql.Append(" CardID = @CardID , "); strSql.Append(" LoginName = @LoginName , "); strSql.Append(" ReginId = @ReginId , "); strSql.Append(" IsLocked = @IsLocked , "); strSql.Append(" IsLogined = @IsLogined , "); strSql.Append(" LoginTimes = @LoginTimes , "); strSql.Append(" ProvinceID = @ProvinceID , "); strSql.Append(" CityID = @CityID , "); strSql.Append(" CountyID = @CountyID , "); strSql.Append(" Address = @Address , "); strSql.Append(" UserName = @UserName , "); strSql.Append(" Sex = @Sex , "); strSql.Append(" Phone = @Phone , "); strSql.Append(" QQ = @QQ , "); strSql.Append(" Wechat = @Wechat , "); strSql.Append(" Email = @Email, "); strSql.Append(" DepartmentID = @DepartmentID ,"); strSql.Append(" SId = @SId "); strSql.Append(" where UserID=@UserID "); SqlParameter[] parameters = { new SqlParameter("@UserID", model.UserID), new SqlParameter("@UserType", model.UserType), new SqlParameter("@GravatarResourceID", model.GravatarResourceID), new SqlParameter("@LastAccessIP", model.LastAccessIP), new SqlParameter("@CompanyName", model.CompanyName), new SqlParameter("@CreatUserID", model.CreatUserID), new SqlParameter("@RecordUpdateUserID", model.RecordUpdateUserID), new SqlParameter("@RecordIsDelete", model.RecordIsDelete), new SqlParameter("@RecordUpdateTime", model.RecordUpdateTime), new SqlParameter("@RecordCreateTime", model.RecordCreateTime), new SqlParameter("@CardID", model.CardID), new SqlParameter("@LoginName", model.LoginName), new SqlParameter("@ReginId", model.ReginId), new SqlParameter("@IsLocked", model.IsLocked), new SqlParameter("@IsLogined", model.IsLogined), new SqlParameter("@LoginTimes", model.LoginTimes), new SqlParameter("@ProvinceID", model.ProvinceID), new SqlParameter("@CityID", model.CityID), new SqlParameter("@CountyID", model.CountyID), new SqlParameter("@Address", model.Address), new SqlParameter("@UserName", model.UserName), new SqlParameter("@Sex", model.Sex), new SqlParameter("@Phone", model.Phone), new SqlParameter("@QQ", model.QQ), new SqlParameter("@Wechat", model.Wechat), new SqlParameter("@Email", model.Email), new SqlParameter("@DepartmentID", model.DepartmentID), new SqlParameter("@SId", model.SId) }; int rows = BWJSHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// datarow转成对象实体 /// </summary> public BWJS.Model.Users DataRowToModel(DataRow row) { BWJS.Model.Users model = new BWJS.Model.Users(); if (row != null) { if (row["UserID"].ToString() != "") { model.UserID = int.Parse(row["UserID"].ToString()); } if (row["UserType"].ToString() != "") { model.UserType = int.Parse(row["UserType"].ToString()); } model.GravatarResourceID = row["GravatarResourceID"].ToString(); model.LastAccessIP = row["LastAccessIP"].ToString(); model.CompanyName = row["CompanyName"].ToString(); if (row["CreatUserID"].ToString() != "") { model.CreatUserID = int.Parse(row["CreatUserID"].ToString()); } if (row["RecordUpdateUserID"].ToString() != "") { model.RecordUpdateUserID = int.Parse(row["RecordUpdateUserID"].ToString()); } if (row["RecordIsDelete"].ToString() != "") { if ((row["RecordIsDelete"].ToString() == "1") || (row["RecordIsDelete"].ToString().ToLower() == "true")) { model.RecordIsDelete = true; } else { model.RecordIsDelete = false; } } if (row["RecordUpdateTime"].ToString() != "") { model.RecordUpdateTime = DateTime.Parse(row["RecordUpdateTime"].ToString()); } if (row["RecordCreateTime"].ToString() != "") { model.RecordCreateTime = DateTime.Parse(row["RecordCreateTime"].ToString()); } model.CardID = row["CardID"].ToString(); model.LoginName = row["LoginName"].ToString(); if (row["ReginId"].ToString() != "") { model.ReginId = int.Parse(row["ReginId"].ToString()); } if (row["IsLocked"].ToString() != "") { model.IsLocked = int.Parse(row["IsLocked"].ToString()); } if (row["IsLogined"].ToString() != "") { model.IsLogined = int.Parse(row["IsLogined"].ToString()); } if (row["LoginTimes"].ToString() != "") { model.LoginTimes = int.Parse(row["LoginTimes"].ToString()); } if (row["ProvinceID"].ToString() != "") { model.ProvinceID = int.Parse(row["ProvinceID"].ToString()); } if (row["CityID"].ToString() != "") { model.CityID = int.Parse(row["CityID"].ToString()); } if (row["CountyID"].ToString() != "") { model.CountyID = int.Parse(row["CountyID"].ToString()); } model.Address = row["Address"].ToString(); model.Password = row["Password"].ToString(); model.UserName = row["UserName"].ToString(); model.Sex = row["Sex"].ToString(); model.Phone = row["Phone"].ToString(); model.QQ = row["QQ"].ToString(); model.Wechat = row["Wechat"].ToString(); model.Email = row["Email"].ToString(); if (row["DepartmentID"].ToString() != "") { model.DepartmentID = int.Parse(row["DepartmentID"].ToString()); } if (row["SId"].ToString() != "") { model.SId = row["SId"].ToString(); } MachineDAL dalMachine = new MachineDAL(); Machine modelMachine = dalMachine.GetModelByUserId(model.UserID); model.EquipmentNo = ((modelMachine == null) ? (string.Empty) : (modelMachine.MachineID.ToString())); return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BWJS.Model.Users model) { return(dal.Update(model)); }
/// <summary> /// 更新一条数据 /// </summary> public bool UpdateDepartmentID(BWJS.Model.Users model) { return(dal.UpdateDepartmentID(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BWJS.Model.Users model) { return(dal.Add(model)); }