using CY.Infrastructure.Common; using CY.Infrastructure.Logging; using CY.Model.OA; using CY.SQLDAL; using System; using System.Collections.Generic; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using static CY.WebForm.MainPage; namespace CY.WebForm.Pages.business { public partial class CorporateClientsContractShow : System.Web.UI.Page { /// /// 合同附件集合 /// List fileDataList { set; get; } = new List(); protected void Page_Load(object sender, EventArgs e) { ReadList(); } private void ReadList() { Guid Keyid = Request["Keyid"].ToGuid2(); if (Keyid == null) { JavaScript.MessageBox("未找到该客户", this, false, false); return; } Database DC = new Database(); string sqlStr = string.Format(@"USE [ECTEST] select * from [dbo].[OA_CorporateClientContract] where CorporateClientsid='{0}' order by PageCode ", Keyid); int count = 0; try { SqlCommand myCmd = new SqlCommand(sqlStr, DC.Connection); //SqlDataAdapter myDa = new SqlDataAdapter(myCmd); var a = myCmd.ExecuteReader(); //myDa.Dispose(); fileDataList = new List(); OA_CorporateClientsContract Contract; while (a.Read()) { //注意如何将每次读取到的记录添加到listbox1中(因为第一次做时出错了,嘿嘿) Contract = new OA_CorporateClientsContract(); Contract.Keyid = a.GetGuid(0); Contract.CorporateClientsid = a.GetGuid(1); Contract.CorporateClientsName = a.GetString(2); Contract.FileName = a.GetString(3); Contract.PageCode = a.GetInt32(4); Contract.FilePath = a.GetString(5); Contract.Remark = a.GetString(6); fileDataList.Add(Contract); } a.Close(); //关闭sqldatareader sqlStr = string.Format("select count(*) from [dbo].[OA_CorporateClientContract] where CorporateClientsid='{0}'", Keyid); myCmd = new SqlCommand(sqlStr, DC.Connection); count = (int)myCmd.ExecuteScalar(); } catch (Exception ee) { new Log4NetAdapter().Log("查找合同出错:" + ee.Message); } finally { if (DC.Connection.State != System.Data.ConnectionState.Closed) DC.Connection.Close(); } this.RepClientList.DataSource = fileDataList;// fileDataList.AsEnumerable(); this.RepClientList.DataBind(); } } }