/// <summary> /// 得到一个对象实体 /// </summary> public SmartLaw.Model.Drugs DataRowToModel(DataRow row) { SmartLaw.Model.Drugs model = new SmartLaw.Model.Drugs(); if (row != null) { if (row["AutoID"] != null && row["AutoID"].ToString() != "") { model.AutoID = long.Parse(row["AutoID"].ToString()); } if (row["PZWH"] != null) { model.PZWH = row["PZWH"].ToString(); } if (row["CPMC"] != null) { model.CPMC = row["CPMC"].ToString(); } if (row["YWMC"] != null) { model.YWMC = row["YWMC"].ToString(); } if (row["SPM"] != null) { model.SPM = row["SPM"].ToString(); } if (row["JX"] != null) { model.JX = row["JX"].ToString(); } if (row["GG"] != null) { model.GG = row["GG"].ToString(); } if (row["SCDW"] != null) { model.SCDW =row["SCDW"].ToString(); } if (row["SCDZ"] != null) { model.SCDZ = row["SCDZ"].ToString(); } if (row["CPLB"] != null) { model.CPLB = row["CPLB"].ToString(); } if (row["YPZWH"] != null) { model.YPZWH = row["YPZWH"].ToString(); } if (row["PZRQ"] != null && row["PZRQ"].ToString() != "") { model.PZRQ = DateTime.Parse(row["PZRQ"].ToString()); } if (row["BWM"] != null) { model.BWM = row["BWM"].ToString(); } if (row["BWMBZ"] != null) { model.BWMBZ = row["BWMBZ"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public SmartLaw.Model.Drugs GetModel(long AutoID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select AutoID,PZWH,CPMC,YWMC,SPM,JX,GG,SCDW,SCDZ,CPLB,YPZWH,PZRQ,BWM,BWMBZ from Drugs"); strSql.Append(" where AutoID=@AutoID limit 1"); MySqlParameter[] parameters = { new MySqlParameter("@AutoID", MySqlDbType.Int64) }; parameters[0].Value = AutoID; SmartLaw.Model.Drugs model = new SmartLaw.Model.Drugs(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }