public List<ExtendModule.ResponsibilityAndOther> GetResponsList(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select r.id, r.Resp_Name, r.Resp_Content, r.Resp_Lab,r.Intro,r.Summary, l.ID as Lab_ID,l.Lab_Name from responsibility r left join lab l on r.Resp_Lab=l.[id] "); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } DataSet ds = DbHelperSQL.Query(strSql.ToString()); List<ExtendModule.ResponsibilityAndOther> modelList = new List<ExtendModule.ResponsibilityAndOther>(); int rowsCount = ds.Tables[0].Rows.Count; if (rowsCount > 0) { ExtendModule.ResponsibilityAndOther model; for (int n = 0; n < rowsCount; n++) { model = new ExtendModule.ResponsibilityAndOther(); if (ds.Tables[0].Rows[n]["ID"].ToString() != "") { model.ID = int.Parse(ds.Tables[0].Rows[n]["ID"].ToString()); } if (ds.Tables[0].Rows[n]["Resp_Lab"].ToString() != "") { model.Resp_Lab = int.Parse(ds.Tables[0].Rows[n]["Resp_Lab"].ToString()); } model.Resp_Name = ds.Tables[0].Rows[n]["Resp_Name"].ToString(); model.Resp_Content = ds.Tables[0].Rows[n]["Resp_Content"].ToString(); model.Intro = ds.Tables[0].Rows[n]["Intro"].ToString(); model.Summary = ds.Tables[0].Rows[n]["Summary"].ToString(); if (ds.Tables[0].Rows[n]["Lab_ID"].ToString() != "") { model.Lab_ID = int.Parse(ds.Tables[0].Rows[n]["Lab_ID"].ToString()); } model.Lab_Name = ds.Tables[0].Rows[n]["Lab_Name"].ToString(); modelList.Add(model); } } return modelList; }
/// <summary> /// 得到一个对象实体 /// </summary> public ExtendModule.ResponsibilityAndOther GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select r.id, r.Resp_Name, r.Resp_Content, r.Resp_Lab,r.Intro,r.Summary, l.ID as Lab_ID,l.Lab_Name from responsibility r left join lab l on r.Resp_Lab=l.[id] "); strSql.Append(" where r.ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4)}; parameters[0].Value = ID; ExtendModule.ResponsibilityAndOther model = new ExtendModule.ResponsibilityAndOther(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if (ds.Tables[0].Rows[0]["Resp_Lab"].ToString() != "") { model.Resp_Lab = int.Parse(ds.Tables[0].Rows[0]["Resp_Lab"].ToString()); } model.Resp_Name = ds.Tables[0].Rows[0]["Resp_Name"].ToString(); model.Resp_Content = ds.Tables[0].Rows[0]["Resp_Content"].ToString(); model.Intro = ds.Tables[0].Rows[0]["Intro"].ToString(); model.Summary = ds.Tables[0].Rows[0]["Summary"].ToString(); if (ds.Tables[0].Rows[0]["Lab_ID"].ToString() != "") { model.Lab_ID = int.Parse(ds.Tables[0].Rows[0]["Lab_ID"].ToString()); } model.Lab_Name = ds.Tables[0].Rows[0]["Lab_Name"].ToString(); return model; } else { return null; } }
private void BindData(int ID) { ExtendBLL.Responsibility responsibility = new ExtendBLL.Responsibility(); ExtendModule.ResponsibilityAndOther responsibilityInfo = new ExtendModule.ResponsibilityAndOther(); responsibilityInfo = responsibility.GetModel(ID); RespLabDDL.SelectedValue = responsibilityInfo.Lab_ID.ToString(); RespName.Text = responsibilityInfo.Resp_Name; RespContent.Text = responsibilityInfo.Resp_Content; }