⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmjopedit.cs

📁 简单的人事管理系统,通过不断改进可以成为一个通用的管理系统
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace HumanManage.HumanManage
{
    public partial class FrmJopEdit : Form
    {
        private static XmlDocument Edit = new XmlDocument();
        private static XmlDocument EmpEdit = new XmlDocument();
        public FrmJopEdit()
        {
            InitializeComponent();
        }

        private void FrmJopEdit_Load(object sender, EventArgs e)
        {
            txtEditJop.Text = FrmAddJop.Checkdept;
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            int n = 0;
            Edit.Load("..\\..\\xmlJop.xml");
            EmpEdit.Load("..\\..\\xmlAddEmp.xml");
            XmlNode Check = Edit.SelectSingleNode("//职位");
            for (int i = 0; i < Check.ChildNodes.Count; i++)
            {
                if (Check.ChildNodes[i].InnerText == txtEditJop.Text)
                {
                    n = 1;
                }
            }

            if (n == 1)
            {
                lblTip.Text = "该职位已经存在!";
            }
            else
            {

                XmlNodeList jopList = EmpEdit.SelectNodes("//新员工");
                foreach (XmlNode jop in jopList)
                {
                    if (jop.ChildNodes[18].InnerText == FrmAddJop.Checkdept)
                    {
                        jop.ChildNodes[18].InnerText = txtEditJop.Text;
                    }

                }

                XmlNode delete = Edit.SelectSingleNode("//" + FrmAddJop.Checkdept);
                delete.ParentNode.RemoveChild(delete);

                XmlDocumentFragment Jops = Edit.CreateDocumentFragment();
                XmlElement Head = Edit.CreateElement(txtEditJop.Text);
                Head.InnerText = txtEditJop.Text;
                Jops.AppendChild(Head);
                XmlNode Node = Edit.SelectSingleNode("//职位");
                Node.AppendChild(Jops);
                lblTip.Text = "修改成功!";
                Edit.Save("..\\..\\xmlJop.xml");
                EmpEdit.Save("..\\..\\xmlAddEmp.xml");
            }
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -