/// <summary> /// 定义的查询方法,以供窗体间委托调用 /// </summary> /// <param name="sql"></param> /// <param name="dgvName"></param> private void ViewQuery(string sql, string dgvName) { RawDataBLL rawDataBLL = new RawDataBLL(); this.dgv_DbQuery.AutoGenerateColumns = true; DataGridViewColumnEditor dgvCE = new DataGridViewColumnEditor(); this.dgv_DbQuery.Name = dgvName; // "dgvView"; this.dgv_DbQuery.ReadOnly = true; if (dgvName == "dgvView") { this.dgv_DbQuery.ReadOnly = true; //将List数据转变成DataTable类型 dt = DataSourceToDataTable.GetListToDataTable <AverageValuesTargetEntity> (rawDataBLL.GetAvg_List(sql)); //this.dgv_DbQuery.DataSource = rawDataBLL.GetAvg_List(sql); this.dgv_DbQuery.DataSource = dt; } if (dgvName == "dgvTarget") { this.dgv_DbQuery.ReadOnly = false; dt = DataSourceToDataTable.GetListToDataTable <TargetEntity>(rawDataBLL.GetList(sql)); this.dgv_DbQuery.DataSource = dt;// rawDataBLL.GetList(sql); } dgvCE.ColumHeaderEdit(this.dgv_DbQuery, this.dgv_DbQuery.Name); }
private void ConditionalQueryFrm_Load(object sender, EventArgs e) { sql = "select * from "; RawDataBLL rawDataBLL = new RawDataBLL(); if (dgvName.Equals("dgvView")) { sql += "view_target"; sqlPlus = sql; listAvgTgtEnty = rawDataBLL.GetAvg_List(sql); foreach (string item in viewHeaderTxt) { this.cmbBox_Paras.Items.Add(item); } } else if (dgvName.Equals("dgvTarget")) { sql += "target"; sqlPlus = sql; listTgtEnty = rawDataBLL.GetList(sql); foreach (string item in tgtHeaderTxt) { this.cmbBox_Paras.Items.Add(item); } } else { MessageBox.Show(" 源数据访问错误!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } }
private void GradingFrm_Load(object sender, EventArgs e) { splitContDataZone.SplitterDistance = splitContDataZone.Height - 60; this.btnCancel.Height = 35; this.btnNext.Height = 35; splitCtnerGraFrm.SplitterDistance = 150; listAvgTgtEnty = rawDataBLL.GetAvg_List(sql); dt = DataSourceToDataTable.GetListToDataTable(listAvgTgtEnty); List <string> list_BsnName = new List <string>(); List <string> list_TgtName = new List <string>(); TreeNode tN = new TreeNode(); string otherBsn = ""; //将所有数据存在dt表内,后面的操作就是从该表中来读取数据 foreach (AverageValuesTargetEntity val in listAvgTgtEnty) { //下面的判断语句是为了避免有重复值出现,其等同于下面的Linq语句: //list_BsnName.Where((x,i) => list_BsnName.FindIndex(z => z.bsn_Att_Name == x.bsn_Att_Name) == i); //list_BsnName.Where((x,i) => list_BsnName.FindIndex(z =>z == x) == i); if (val.bsn_Att_Name.Trim() == "") { otherBsn = "其它"; } if (!list_BsnName.Contains(val.bsn_Att_Name) && !val.bsn_Att_Name.Equals("")) { list_BsnName.Add(val.bsn_Att_Name); } //list_TgtName不用去判断,因为这个值在数据库中就不会有相重的 list_TgtName.Add(val.tgt_Att_Name); } if (otherBsn.Equals("其它") && !list_BsnName.Exists(x => x == "其它")) { list_BsnName.Add("其它"); } foreach (TreeNode var in treeViewGrad.Nodes) { if (var.Name == "para_Bsn") { foreach (string str in list_BsnName) { tN = var.Nodes.Add(str); foreach (AverageValuesTargetEntity avte in listAvgTgtEnty) { if (avte.bsn_Att_Name.Equals(str)) { tN.Nodes.Add(avte.tgt_Att_Name); } if (avte.bsn_Att_Name.Equals("") && str.Equals("其它")) { tN.Nodes.Add(avte.tgt_Att_Name); } } } } } }