/// <summary> /// 得到一个对象实体 /// </summary> public KSOA.Model.Bank_Opus DataRowToModel(DataRow row) { KSOA.Model.Bank_Opus model=new KSOA.Model.Bank_Opus(); if (row != null) { if(row["ID"]!=null && row["ID"].ToString()!="") { model.ID=int.Parse(row["ID"].ToString()); } if(row["OpType"]!=null) { model.OpType=row["OpType"].ToString(); } if(row["OpTitle"]!=null) { model.OpTitle=row["OpTitle"].ToString(); } if(row["OpAuthor"]!=null) { model.OpAuthor=row["OpAuthor"].ToString(); } if(row["OpBeginTime"]!=null && row["OpBeginTime"].ToString()!="") { model.OpBeginTime=DateTime.Parse(row["OpBeginTime"].ToString()); } if(row["AddTime"]!=null && row["AddTime"].ToString()!="") { model.AddTime=DateTime.Parse(row["AddTime"].ToString()); } if(row["IsDelete"]!=null && row["IsDelete"].ToString()!="") { if((row["IsDelete"].ToString()=="1")||(row["IsDelete"].ToString().ToLower()=="true")) { model.IsDelete=true; } else { model.IsDelete=false; } } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public KSOA.Model.Bank_Opus GetModel(int ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ID,OpType,OpTitle,OpAuthor,OpBeginTime,AddTime,IsDelete from Bank_Opus "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4) }; parameters[0].Value = ID; KSOA.Model.Bank_Opus model=new KSOA.Model.Bank_Opus(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }