/// <summary> /// 获得类型 /// </summary> /// <param name="id"></param> /// <returns></returns> protected string GetType(string id) { if (id != "") { SysParaEntity sysParaEntity = SysParaBll.Instance.GetModel(Convert.ToInt32(id)); return(sysParaEntity?.RefText); } return(""); }
/// <summary> /// 得到一个对象实体 /// </summary> private SysParaEntity DataRowToModel(DataRow row) { SysParaEntity model = new SysParaEntity(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["RefType"] != null) { model.RefType = row["RefType"].ToString(); } if (row["RefTypeDesc"] != null) { model.RefTypeDesc = row["RefTypeDesc"].ToString(); } if (row["RefValue"] != null) { model.RefValue = row["RefValue"].ToString(); } if (row["RefText"] != null) { model.RefText = row["RefText"].ToString(); } if (row["RefDesc"] != null) { model.RefDesc = row["RefDesc"].ToString(); } if (row["Status"] != null && row["Status"].ToString() != "") { model.Status = int.Parse(row["Status"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public SysParaEntity GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,RefType,RefTypeDesc,RefValue,RefText,RefDesc,Status from cos_sysPara "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; SysParaEntity model = new SysParaEntity(); DataSet ds = SqlHelper.Instance.ExecSqlDataSet(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }