?? job.cs
字號:
?using System;
using System.Data;
using System.Collections;
using HRManager.DataAccessLayer;
using HRManager.DataAccessHelper;
using HRManager.CommonComponent;
namespace HRManager.BusinessLogicLayer
{
/// <summary>
/// Job 的摘要說明。
/// </summary>
public class Job
{
#region 私有成員
private int _jobId; //職位Id
private string _jobName; //職位
private int _jobCityId; //職位所在城市Id
private string _jobCityName; //職位所在城市
private int _jobTypeId; //職位種類Id
private string _jobTypeName; //職位種類
private string _responsibility; //職位職責
private string _requirement; //職位要求
private bool _isUrgent; //是否緊急
private bool _exist; //是否存在標志
#endregion 私有成員
#region 屬性
//職位Id
public int JobId
{
set
{
this._jobId = value;
}
get
{
return this._jobId;
}
}
//職位
public string JobName
{
set
{
this._jobName = value;
}
get
{
return this._jobName;
}
}
//職位所在城市Id
public int JobCityId
{
set
{
this._jobCityId = value;
}
get
{
return this._jobCityId;
}
}
//職位所在城市
public string JobCityName
{
set
{
this._jobCityName = value;
}
get
{
return this._jobCityName;
}
}
//職位種類Id
public int JobTypeId
{
set
{
this._jobTypeId = value;
}
get
{
return this._jobTypeId;
}
}
//職位種類
public string JobTypeName
{
set
{
this._jobTypeName = value;
}
get
{
return this._jobTypeName;
}
}
//職位職責
public string Responsibility
{
set
{
this._responsibility = value;
}
get
{
return this._responsibility;
}
}
//職位要求
public string Requirement
{
set
{
this._requirement = value;
}
get
{
return this._requirement;
}
}
//是否緊急
public bool IsUrgent
{
set
{
this._isUrgent = value;
}
get
{
return this._isUrgent;
}
}
//存在標志
public bool Exist
{
get
{
return this._exist;
}
}
#endregion 屬性
#region 方法
/// <summary>
/// 根據參數JobId,獲取職位詳細信息
/// </summary>
/// <param name="JobId">職位ID</param>
public void LoadData(int JobId)
{
Database db = new Database(); //實例化一個Database類
string sql = "";
sql = "Select * from [Job],[City],[JobType] where JobId = " + JobId
+ " And [Job].JobCityId=[City].CityId"
+ " And [Job].JobTypeId=[JobType].TypeId";
DataRow dr = db.GetDataRow(sql); //利用Database類的GetDataRow方法查詢職位數據
//根據查詢得到的數據,對成員賦值
if (dr != null)
{
this._jobId = GetSafeData.ValidateDataRow_N(dr, "JobID");
this._jobName = GetSafeData.ValidateDataRow_S(dr, "JobName");
this._jobCityId = GetSafeData.ValidateDataRow_N(dr, "CityId");
this._jobCityName = GetSafeData.ValidateDataRow_S(dr, "CityName");
this._jobTypeId = GetSafeData.ValidateDataRow_N(dr, "JobTypeId");
this._jobTypeName = GetSafeData.ValidateDataRow_S(dr, "TypeName");
this._responsibility = GetSafeData.ValidateDataRow_S(dr, "Responsibility");
this._requirement = GetSafeData.ValidateDataRow_S(dr, "Requirement");
this._isUrgent =Convert.ToBoolean( GetSafeData.ValidateDataRow_N(dr, "IsUrgent"));
this._exist = true;
}
else
{
this._exist = false;
}
}
/// <summary>
/// 向數據庫添加一個職位
/// </summary>
/// <param name="htUserInfo">職位信息哈希表</param>
public static void Add(Hashtable JobInfo)
{
Database db = new Database(); //實例化一個Database類
db.Insert("[Job]", JobInfo); //利用Database類的Insert方法添加職位數據
}
/// <summary>
/// 查詢職位
/// </summary>
/// <param name="queryItems">“AND”子句查詢條件哈希表</param>
/// <returns>以DataTable形式返回查詢結果數據</returns>
public static DataTable Query(Hashtable queryItems)
{
string where = SqlStringConstructor.GetConditionClause(queryItems);
string sql = "Select * From [Job],[City],[JobType]";
if (where == "")
{
where = " Where [Job].JobCityId=[City].CityId"
+ " And [Job].JobTypeId=[JobType].TypeId";
}
else
{
where += " And [Job].JobCityId=[City].CityId"
+ " And [Job].JobTypeId=[JobType].TypeId";
}
sql += where;
Database db = new Database();
return db.GetDataTable(sql);
}
/// <summary>
/// 全文搜索,即在:職位名稱、職責、要求、城市、類別中查找關鍵字
/// </summary>
/// <param name="keyWords">關鍵字集合</param>
public static DataTable KeyWordsSearch(ArrayList keyWords)
{
string sql = "Select * From [Job],[City],[JobType]";
string where = " Where ";
foreach (string key in keyWords)
{
where += "( [Job].JobName Like '%"+key+"%' ";
where += "Or [Job].Responsibility Like '%" + key + "%' ";
where += "Or [Job].Requirement Like '%" + key + "%' ";
where += "Or [JobType].TypeName Like '%" + key + "%' ";
where += "Or [City].CityName Like '%" + key + "%') ";
where += " And ";
}
where += " [Job].JobCityId=[City].CityId"
+ " And [Job].JobTypeId=[JobType].TypeId";
sql += where;
Database db = new Database();
return db.GetDataTable(sql);
}
#endregion 方法
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -