/// <summary> /// 得到一个对象实体 /// </summary> public static T_YH GetModel(int F_ID) { dbbase.odbcdb aa = new odbcdb("DSN=pathnet;UID=pathnet;PWD=4s3c2a1p", "", ""); StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 F_ID,F_YHM,F_YHMC,F_YHBH,F_YHQX,F_YHMM,F_DLSJ,F_SFZX,F_ZXWZ,F_ZXSC,F_DXYS,F_SFZH,F_DHHM,F_FJH,F_CXTS,F_DXFPYS,F_YH_BY1,F_YH_BY2 from T_YH "); strSql.Append($" where F_ID='{F_ID}'"); DataTable dt = aa.GetDataTable(strSql.ToString(), "dt1"); if (dt.Rows.Count > 0) { return(T_YH.DataRowToModel(dt.Rows[0])); } return(null); }
/// <summary> /// 获得前几行数据 /// </summary> public static List <T_YH> GetList(string strWhere) { dbbase.odbcdb aa = new odbcdb("DSN=pathnet;UID=pathnet;PWD=4s3c2a1p", "", ""); StringBuilder strSql = new StringBuilder(); strSql.Append("select "); strSql.Append(" F_ID,F_YHM,F_YHMC,F_YHBH,F_YHQX,F_YHMM,F_DLSJ,F_SFZX,F_ZXWZ,F_ZXSC,F_DXYS,F_SFZH,F_DHHM,F_FJH,F_CXTS,F_DXFPYS,F_YH_BY1,F_YH_BY2 "); strSql.Append(" FROM T_YH "); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } var dt = aa.GetDataTable(strSql.ToString(), "dt"); var listYh = new List <T_YH>(); foreach (DataRow dtRow in dt.Rows) { listYh.Add(T_YH.DataRowToModel(dtRow)); } return(listYh); }
/// <summary> /// 得到一个对象实体 /// </summary> public static T_YH DataRowToModel(DataRow row) { T_YH model = new T_YH(); if (row != null) { if (row["F_ID"] != null && row["F_ID"].ToString() != "") { model.F_ID = int.Parse(row["F_ID"].ToString()); } if (row["F_YHM"] != null) { model.F_YHM = row["F_YHM"].ToString(); } if (row["F_YHMC"] != null) { model.F_YHMC = row["F_YHMC"].ToString(); } if (row["F_YHBH"] != null) { model.F_YHBH = row["F_YHBH"].ToString(); } if (row["F_YHQX"] != null && row["F_YHQX"].ToString() != "") { model.F_YHQX = int.Parse(row["F_YHQX"].ToString()); } if (row["F_YHMM"] != null) { model.F_YHMM = row["F_YHMM"].ToString(); } if (row["F_DLSJ"] != null) { model.F_DLSJ = row["F_DLSJ"].ToString(); } if (row["F_SFZX"] != null) { model.F_SFZX = row["F_SFZX"].ToString(); } if (row["F_ZXWZ"] != null) { model.F_ZXWZ = row["F_ZXWZ"].ToString(); } if (row["F_ZXSC"] != null && row["F_ZXSC"].ToString() != "") { model.F_ZXSC = int.Parse(row["F_ZXSC"].ToString()); } if (row["F_DXYS"] != null) { model.F_DXYS = row["F_DXYS"].ToString(); } if (row["F_SFZH"] != null) { model.F_SFZH = row["F_SFZH"].ToString(); } if (row["F_DHHM"] != null) { model.F_DHHM = row["F_DHHM"].ToString(); } if (row["F_FJH"] != null) { model.F_FJH = row["F_FJH"].ToString(); } if (row["F_CXTS"] != null) { model.F_CXTS = row["F_CXTS"].ToString(); } if (row["F_DXFPYS"] != null && row["F_DXFPYS"].ToString() != "") { model.F_DXFPYS = int.Parse(row["F_DXFPYS"].ToString()); } if (row["F_YH_BY1"] != null) { model.F_YH_BY1 = row["F_YH_BY1"].ToString(); } if (row["F_YH_BY2"] != null) { model.F_YH_BY2 = row["F_YH_BY2"].ToString(); } } return(model); }