/// <summary> /// 得到一个对象实体 /// </summary> public DB_Talk.Model.EmployeesProfile DataRowToModel(DataRow row) { DB_Talk.Model.EmployeesProfile model=new DB_Talk.Model.EmployeesProfile(); if (row != null) { if(row["EmployeeName"]!=null) { model.EmployeeName=row["EmployeeName"].ToString(); } if(row["Title"]!=null) { model.Title=row["Title"].ToString(); } if(row["EmployeeID"]!=null && row["EmployeeID"].ToString()!="") { model.EmployeeID=int.Parse(row["EmployeeID"].ToString()); } if(row["SiteID"]!=null && row["SiteID"].ToString()!="") { model.SiteID=int.Parse(row["SiteID"].ToString()); } if(row["DepartmentID"]!=null && row["DepartmentID"].ToString()!="") { model.DepartmentID=int.Parse(row["DepartmentID"].ToString()); } if(row["Status"]!=null && row["Status"].ToString()!="") { model.Status=int.Parse(row["Status"].ToString()); } if(row["Picture"]!=null && row["Picture"].ToString()!="") { model.Picture=(byte[])row["Picture"]; } if(row["PersonalPhoneNumber1"]!=null) { model.PersonalPhoneNumber1=row["PersonalPhoneNumber1"].ToString(); } if(row["PersonalPhoneNumber2"]!=null) { model.PersonalPhoneNumber2=row["PersonalPhoneNumber2"].ToString(); } if(row["EmailAddress"]!=null) { model.EmailAddress=row["EmailAddress"].ToString(); } if(row["ChangeTimestamp"]!=null && row["ChangeTimestamp"].ToString()!="") { model.ChangeTimestamp=DateTime.Parse(row["ChangeTimestamp"].ToString()); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public DB_Talk.Model.EmployeesProfile GetModel() { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" EmployeeName,Title,EmployeeID,SiteID,DepartmentID,Status,Picture,PersonalPhoneNumber1,PersonalPhoneNumber2,EmailAddress,ChangeTimestamp "); strSql.Append(" from EmployeesProfile "); strSql.Append(" where " ); DB_Talk.Model.EmployeesProfile model=new DB_Talk.Model.EmployeesProfile(); DataSet ds = DB_Talk.DB.OleDbHelper.GetDataSet(strSql.ToString()); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }