private void btnSub_Click(object sender, EventArgs e) { PramasBLL pbll = new PramasBLL(); IntroducerBLL ibll = new IntroducerBLL(); List <HOZAPModel.Introducer> IntroducerList = null; string PramasName = txtPramasName.Text.Trim(); if (!string.IsNullOrEmpty(PramasName)) { pbll.Add_Pramas(PramasName); int pramasid = pbll.Get_PramasId(PramasName); if (dgvIntroducer.Rows.Count > 0) { IntroducerList = new List <HOZAPModel.Introducer>(); foreach (DataGridViewRow row in dgvIntroducer.Rows) { HOZAPModel.Introducer IntroducerInfo = new HOZAPModel.Introducer(); IntroducerInfo.IntroducerText = row.Cells[1].Value.ToString(); IntroducerInfo.PramasId = pramasid; IntroducerList.Add(IntroducerInfo); } } if (ibll.Add_Introducerinfo(IntroducerList)) { if (MyPreParamSelectionDataBindEvents != null) { MyPreParamSelectionDataBindEvents(); } MessageBox.Show("添加成功!"); this.Close(); } } }
public void SetInfo(List <int> PramasIDlist) { PramasBLL pbll = new PramasBLL(); IntroducerBLL ibll = new IntroducerBLL(); PramasIDList = PramasIDlist; Pramas PramasInfo = pbll.Get_PramasInfo(PramasIDlist[0]); txtPramasName.Text = PramasInfo.Name; List <Introducer> Introducerlist = ibll.Get_IntroducerList(PramasIDlist[0]); if (Introducerlist != null) { dgvIntroducer.Columns.Clear(); DataGridViewTextBoxColumn a = new DataGridViewTextBoxColumn(); a.HeaderText = "序号"; dgvIntroducer.Columns.Add(a); DataGridViewTextBoxColumn b = new DataGridViewTextBoxColumn(); b.HeaderText = "引导词"; dgvIntroducer.Columns.Add(b); DataGridViewTextBoxColumn c = new DataGridViewTextBoxColumn(); c.HeaderText = "偏离描述"; dgvIntroducer.Columns.Add(c); for (int i = 0; i < Introducerlist.Count; i++) { int index = this.dgvIntroducer.Rows.Add(); this.dgvIntroducer.Rows[index].Cells[0].Value = index + 1; this.dgvIntroducer.Rows[index].Cells[1].Value = Introducerlist[i].IntroducerText; this.dgvIntroducer.Rows[index].Cells[2].Value = ""; } } }
/// <summary> /// 删除参数及相关信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tspPreParamSelDel_Click(object sender, EventArgs e) { List <int> PramasIdList = new List <int>(); foreach (DataGridViewRow row in dgvPreParamSelection.Rows) { DataGridViewCheckBoxCell checkbox = (DataGridViewCheckBoxCell)row.Cells[0]; if (checkbox.Value == null) { checkbox.Value = 0; } if ((int)checkbox.Value == 1) { if ((int)row.Cells["Type"].Value == 0) { MessageBox.Show("选项中有系统参数,无法删除!"); return; } else { PramasIdList.Add(Convert.ToInt32(row.Cells["PramasID"].Value)); } } } if (PramasIdList.Count > 0) { PramasBLL pbll = new PramasBLL(); IntroducerBLL ibll = new IntroducerBLL(); if (pbll.Del_PramasById(PramasIdList)) { ibll.Del_IntroducerByPramasID(PramasIdList); MessageBox.Show("删除成功!"); PreParamSelectionDataBind(); } } else { MessageBox.Show("请选择要删除的参数信息!"); } }
/// <summary> /// 为选择的参数展示表的数据绑定 /// </summary> private void PreParamSelectionDataBind() { PramasBLL pbll = new PramasBLL(); IntroducerBLL ibll = new IntroducerBLL(); string ProName = HAZOP分析系统.ProName; List <Pramas> plist = pbll.Get_PramasList(ProName); List <DisplayPramasAndIntroducer> displaylist = null; if (plist != null) { List <Introducer> introducerlist = new List <Introducer>(); displaylist = new List <DisplayPramasAndIntroducer>(); for (int i = 0; i < plist.Count; i++) { DisplayPramasAndIntroducer displayinfo = new DisplayPramasAndIntroducer(); displayinfo.PramasID = plist[i].PramasID; displayinfo.Name = plist[i].Name; displayinfo.Type = plist[i].Type; introducerlist = ibll.Get_IntroducerList(plist[i].PramasID); if (introducerlist != null) { for (int j = 0; j < introducerlist.Count; j++) { if (j == introducerlist.Count - 1) { displayinfo.AllIntroducer += introducerlist[j].IntroducerText; } else { displayinfo.AllIntroducer += introducerlist[j].IntroducerText + "、"; } } } displaylist.Add(displayinfo); } } dgvPreParamSelection.AutoGenerateColumns = false; dgvPreParamSelection.DataSource = displaylist; }
private void btnSub_Click(object sender, EventArgs e) { PramasBLL pbll = new PramasBLL(); IntroducerBLL ibll = new IntroducerBLL(); List <HOZAPModel.Introducer> IntroducerList = null; string PramasName = txtPramasName.Text.Trim(); if (!string.IsNullOrEmpty(PramasName)) { Pramas PramasInfo = new Pramas(); PramasInfo.PramasID = PramasIDList[0]; PramasInfo.Name = PramasName; PramasInfo.Type = 1; if (pbll.Update_Pramas(PramasInfo)) { if (dgvIntroducer.Rows.Count > 0) { IntroducerList = new List <HOZAPModel.Introducer>(); foreach (DataGridViewRow row in dgvIntroducer.Rows) { HOZAPModel.Introducer IntroducerInfo = new HOZAPModel.Introducer(); IntroducerInfo.IntroducerText = row.Cells[1].Value.ToString(); IntroducerInfo.PramasId = PramasIDList[0]; IntroducerList.Add(IntroducerInfo); } } if (IntroducerList != null) { if (ibll.Check_IntroducerByPramasID(PramasIDList[0])) { if (ibll.Del_IntroducerByPramasID(PramasIDList)) { if (ibll.Add_Introducerinfo(IntroducerList)) { if (MyPreParamSelectionDataBindEvents != null) { MyPreParamSelectionDataBindEvents(); } MessageBox.Show("更新成功!"); this.Close(); } } } else { if (ibll.Add_Introducerinfo(IntroducerList)) { if (MyPreParamSelectionDataBindEvents != null) { MyPreParamSelectionDataBindEvents(); } MessageBox.Show("更新成功!"); this.Close(); } } } else { if (ibll.Del_IntroducerByPramasID(PramasIDList)) { if (MyPreParamSelectionDataBindEvents != null) { MyPreParamSelectionDataBindEvents(); } MessageBox.Show("更新成功!"); this.Close(); } } } } }