/// <summary> /// 参数选择按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPreParaSelect_Click(object sender, EventArgs e) { List <SelectedPramas> SelectedPramasInfoList = new List <SelectedPramas>(); foreach (DataGridViewRow row in dgvPreParamSelection.Rows) { DataGridViewCheckBoxCell checkbox = (DataGridViewCheckBoxCell)row.Cells[0]; if (checkbox.Value == null) { checkbox.Value = 0; } if ((int)checkbox.Value == 1) { SelectedPramas SelectedPramasInfo = new SelectedPramas(); SelectedPramasInfo.PramasId = Convert.ToInt32(row.Cells["PramasID"].Value); SelectedPramasInfo.PramasText = row.Cells["ParamNameSelection"].Value.ToString(); SelectedPramasInfo.ProName = HAZOP分析系统.ProName; SelectedPramasInfoList.Add(SelectedPramasInfo); } } if (SelectedPramasInfoList.Count > 0) { if (spbll.Add_SelectedPramasinfo(SelectedPramasInfoList)) { PreParamSledDataBind(); PreParamSelectionDataBind(); } } else { MessageBox.Show("请选择参数!"); } }
/// <summary> /// 根据项目名获取已选择项目参数列表 /// </summary> /// <param name="ProName">项目名</param> /// <param name="SelectedPramas">HOZAPModel命名空间中的SelectedPramas类,已选择参数类</param> /// <returns>已选择项目参数列表</returns> public List <SelectedPramas> Get_SelectedPramasList(string ProName) { string sql = "select * from tb_SelectedPramas where ProName=@ProName"; List <SelectedPramas> SelectedPramasList = null; using (SqlDataReader sdr = SqlHelper.ExecuteReader(sql, new SqlParameter("@ProName", ProName))) { if (sdr.HasRows) { SelectedPramasList = new List <SelectedPramas>(); while (sdr.Read()) //追条读取已选参数数据表中的数据 { SelectedPramas selectedpramas = new SelectedPramas(); selectedpramas.PramasId = sdr.GetInt32(0); selectedpramas.PramasText = sdr.GetString(1); selectedpramas.ProName = sdr.GetString(2); SelectedPramasList.Add(selectedpramas); } } } return(SelectedPramasList); }