/// <summary> /// cmbRangeFraction下拉菜单的变化显示 ///范围查询馏分段的Combox的选择事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public override void cmbRangeFraction_SelectedIndexChanged(object sender, EventArgs e) { /*根据cmbRangeFraction从数据库中提取对应的下拉菜单数据*/ OilDataSearchRowAccess oilDataRowAccess = new OilDataSearchRowAccess(); List <OilDataSearchRowEntity> oilDataRowEntityList = oilDataRowAccess.Get("1=1"); var selectedItem = (OilDataSearchColEntity)this.cmbRangeFraction.SelectedItem;//确定当前菜单中的数据 List <OilDataSearchRowEntity> cmb_OilDataRowList = oilDataRowEntityList.Where(o => o.OilDataColID == selectedItem.ID && o.BelongsToB == true).ToList(); if ("原油信息".Equals(cmbRangeFraction.Text)) { OilinfItemList oilinfItemList = new OilinfItemList(); //数据源 OilinfItemList newOilinfItemList = new OilinfItemList(); //处理过的数据源 newOilinfItemList.oilinfItems.Clear(); if (cmb_OilDataRowList != null) //存在返回的数据不为空 { if (0 != cmb_OilDataRowList.Count) //返回的数据不为空 { for (int i = 0; i < cmb_OilDataRowList.Count; i++) { for (int j = 0; j < oilinfItemList.oilinfItems.Count; j++) { if (cmb_OilDataRowList[i].OilTableRow.itemCode == oilinfItemList.oilinfItems[j].itemCode) { newOilinfItemList.oilinfItems.Add(oilinfItemList.oilinfItems[j]); } } } } } this.label4.Visible = false; this.rangEnd.Visible = false; if (null != this.cmbRangeItem.Items) { this.cmbRangeItem.Items.Clear();//将上一次所选择的内容清零 this.cmbRangeItem.DisplayMember = "itemName"; this.cmbRangeItem.ValueMember = "fieldName"; } for (int i = 0; i < newOilinfItemList.oilinfItems.Count; i++) { this.cmbRangeItem.Items.Add(newOilinfItemList.oilinfItems[i]); } this.cmbRangeItem.SelectedIndex = 0; } else { if (null != this.cmbRangeItem.Items) { this.cmbRangeItem.Items.Clear(); //将上一次所选择的内容清零 this.cmbRangeItem.DisplayMember = "ItemName"; //设置显示名称 this.cmbRangeItem.ValueMember = "ItemCode"; //设置保存代码 } this.label4.Visible = true; this.rangEnd.Visible = true; //int ColID = ((OilDataColEntity)this.cmbOilInfoselect.SelectedItem).OilTableColID; if (cmb_OilDataRowList != null) //存在返回的数据不为空 { if (0 != cmb_OilDataRowList.Count) //返回的数据不为空 { for (int i = 0; i < cmb_OilDataRowList.Count; i++) { this.cmbRangeItem.Items.Add(cmb_OilDataRowList[i].OilTableRow); } this.cmbRangeItem.SelectedIndex = 0; //选择第一个选项 this.rangStart.Text = ""; //将范围空间置零 this.rangEnd.Text = ""; } } } }
/// <summary> /// cmbRangeFraction下拉菜单的变化显示 ///范围查询馏分段的Combox的选择事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public override void cmbRangeFraction_SelectedIndexChanged(object sender, EventArgs e) { /*根据cmbRangeFraction从数据库中提取对应的下拉菜单数据*/ //if (this.cmbRangeFraction.Created) //{ OilDataSearchRowAccess oilDataRowAccess = new OilDataSearchRowAccess(); List <OilDataSearchRowEntity> oilDataRowEntityList = oilDataRowAccess.Get("1=1"); var selectedItem = (OilDataSearchColEntity)this.cmbRangeFraction.SelectedItem; //确定馏分段的菜单中的数据 List <OilDataSearchRowEntity> cmbRangeItemList = oilDataRowEntityList.Where(o => o.OilDataColID == selectedItem.ID && o.BelongsToA == true).OrderBy(o => o.OilTableRow.itemOrder).ToList(); //InitCol(selectedItem, cmb_OilDataRowList); if ("原油信息".Equals(cmbRangeFraction.Text)) { #region "原油信息的性质空间的绑定" OilinfItemList oilinfItemList = new OilinfItemList(); //数据源 OilinfItemList newOilinfItemList = new OilinfItemList(); //处理过的数据源 newOilinfItemList.oilinfItems.Clear(); if (cmbRangeItemList != null && 0 != cmbRangeItemList.Count) //存在返回的数据不为空 { foreach (OilDataSearchRowEntity row in cmbRangeItemList) { OilinfItem tempOilinfItem = oilinfItemList.oilinfItems.Where(o => o.itemCode == row.OilTableRow.itemCode).FirstOrDefault(); if (tempOilinfItem == null) { continue; } newOilinfItemList.oilinfItems.Add(tempOilinfItem); } } this.label4.Visible = false; this.rangEnd.Visible = false; #region "范围查询物性数据绑定" if (null != this.cmbRangeItem.Items) { this.cmbRangeItem.Items.Clear(); //将上一次所选择的内容清零 } this.cmbRangeItem.DisplayMember = "itemName"; this.cmbRangeItem.ValueMember = "fieldName"; foreach (OilinfItem item in newOilinfItemList.oilinfItems) { this.cmbRangeItem.Items.Add(item); } this.cmbRangeItem.SelectedIndex = 0; this.rangEnd.Clear(); this.rangStart.Clear(); #endregion #endregion } else if (!"原油信息".Equals(cmbRangeFraction.Text)) { #region "性质控件的绑定" if (null != this.cmbRangeItem.Items) { this.cmbRangeItem.Items.Clear(); //将上一次所选择的内容清零 } this.cmbRangeItem.DisplayMember = "ItemName"; //设置显示名称 this.cmbRangeItem.ValueMember = "ItemCode"; //设置保存代码 this.label4.Visible = true; this.rangEnd.Visible = true; if (cmbRangeItemList != null && 0 != cmbRangeItemList.Count) //存在返回的数据不为空 { foreach (OilDataSearchRowEntity row in cmbRangeItemList) { this.cmbRangeItem.Items.Add(row.OilTableRow); } this.cmbRangeItem.SelectedIndex = 0; //选择第一个选项 this.rangStart.Text = ""; //将范围空间置空 this.rangEnd.Text = ""; //将范围空间置空 } #endregion } // } }