/// <summary> /// 单击树节点时,DataGrid里显示相应的信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tvMain_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Button == MouseButtons.Left && e.Node.Nodes.Count < 1) { string pathNo = e.Node.Name; if (pathEmpRelationbll == null) { pathEmpRelationbll = new PathEmpRelationBll(); } string condition = "per.PathNo='" + pathNo + "'"; DataTable dt = pathEmpRelationbll.SelectPathEmpRelation(condition); SortDataGrid(dt); } }
/// <summary> /// 查找信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bcpSearch_Click(object sender, EventArgs e) { try { string condition = String.Empty; if (tbPNo.Text.Trim() != "") { condition = "per.PathNo like '%" + tbPNo.Text + "%'"; } else { condition = "1=1"; } if (tbPName.Text.Trim() != "") { condition += "and pi.PathName like '%" + tbPName.Text + "%'"; } if (tbEmpNo.Text.Trim() != "") { condition += "and per.EmpNo like '%" + tbEmpNo.Text + "%'"; } if (tbEmpName.Text.Trim() != "") { condition += "and ei.EmpName like '%" + tbEmpName.Text + "%'"; } if (pathEmpRelationbll == null) { pathEmpRelationbll = new PathEmpRelationBll(); } DataTable dt = pathEmpRelationbll.SelectPathEmpRelation(condition); SortDataGrid(dt); } catch (Exception ex) { MessageBox.Show("查询条件错误,分站或探头地址应该为整数", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// 操作 “增加” 或 “修改”时的操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddOrEdit_Click(object sender, EventArgs e) { if (CheckValue()) { if (btnAddOrEdit.CaptionTitle == "增加") { operated = 1; int result = AddPathEmpRelation(); if (result == 1) { if (pathEmpRelationbll == null) { pathEmpRelationbll = new PathEmpRelationBll(); } MessageBox.Show("增加信息成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); if (!New_DBAcess.IsDouble) { DataTable dt = pathEmpRelationbll.SelectPathEmpRelation(""); SortDataGrid(dt); } else { timer1.Start(); } } else { MessageBox.Show("增加操作失败,记录可能已存在,不能增加重复记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else if (btnAddOrEdit.CaptionTitle == "修改") { operated = 3; int result = UpdatePathEmpRelation(); if (result == 1) { if (pathEmpRelationbll == null) { pathEmpRelationbll = new PathEmpRelationBll(); } MessageBox.Show("修改信息成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); if (!New_DBAcess.IsDouble) { DataTable dt = pathEmpRelationbll.SelectPathEmpRelation(""); SortDataGrid(dt); } else { timer1.Start(); } } else { MessageBox.Show("修改操作失败,记录可能已存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } }