📄 formdepinfo.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace HRMan.SysOper
{
public partial class FormDepInfo : Form
{
public FormDepInfo()
{
InitializeComponent();
HRMan.SysOper.FormDepInfo.departinfo = this;
}
public void FormDepInfo_Load(object sender, EventArgs e)
{
this.treeView1.Nodes.Clear();
TreeNode newNode = new TreeNode("部门");
this.treeView1.Nodes.Add(newNode);
this.InitTree(newNode, "select * from SectionInfo");
this.treeView1.ExpandAll();
}
private void InitTree(TreeNode parentNode, string SqlText)
{
DataAccess DA = new DataAccess();
DataTable dt = new DataTable();
dt = DA.ExeSQLdt(SqlText);
for (int i = 0; i < dt.Rows.Count; i++)
{
parentNode.Nodes.Add(dt.Rows[i][1].ToString());
}
}
private void toolStripRefresh_Click(object sender, EventArgs e)
{
this.treeView1.ExpandAll();
}
private void toolStripAdd_Click(object sender, EventArgs e)
{
if (FormMain.FM.CheckForm("FormTreeNode") == true)
{
return;
}
else
{
HRMan.SysOper.FormTreeNode treenode = new FormTreeNode();
treenode.MdiParent = FormMain.FM;
treenode.Show();
HRMan.SysOper.FormTreeNode.treenode.label1.Text = "请输入部门名称";
}
}
private void toolStripUpdate_Click(object sender, EventArgs e)
{
if (this.treeView1.SelectedNode.Text == "部门")
{
MessageBox.Show("请选择具体的部门!");
}
else
{
if (FormMain.FM.CheckForm("FormTreeNode") == true)
{
return;
}
else
{
string SqlText = "select * from SectionInfo where sName='" + this.treeView1.SelectedNode.Text + "'";
DataTable dt = new DataTable();
DataAccess DA = new DataAccess();
dt = DA.ExeSQLdt(SqlText);
this.departID = dt.Rows[0]["sId"].ToString();
HRMan.SysOper.FormTreeNode treenodeform = new FormTreeNode();
treenodeform.MdiParent = FormMain.FM;
treenodeform.Show();
HRMan.SysOper.FormTreeNode.treenode.label1.Text = "请输入新部门名称";
HRMan.SysOper.FormTreeNode.treenode.textBox1.Text = this.treeView1.SelectedNode.Text;
}
}
}
private void toolStripExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void toolStripDelete_Click(object sender, EventArgs e)
{
if (this.treeView1.SelectedNode.Text == "部门")
{
DialogResult result = MessageBox.Show("是否真的删除全部部门?", "提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
string SqlText = "delete from SectionInfo";
DataAccess DA = new DataAccess();
DA.ExeSQL(SqlText);
this.treeView1.SelectedNode.Remove();
}
else if (result == DialogResult.No)
{
return;
}
}
else
{
DialogResult result = MessageBox.Show("是否真的删除? " + this.treeView1.SelectedNode.Text, "提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
string SqlText = "select * from SectionInfo where sName='" + this.treeView1.SelectedNode.Text + "'";
DataTable dt = new DataTable();
DataAccess DA = new DataAccess();
dt = DA.ExeSQLdt(SqlText);
string id = dt.Rows[0]["sId"].ToString();
string str = "delete from SectionInfo where sId=" + int.Parse(id);
DataAccess DB = new DataAccess();
DB.ExeSQL(str);
this.treeView1.SelectedNode.Remove();
}
else if (result == DialogResult.No)
{
return;
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -