frmadddep.cs

来自「随着我国市场经济的快速发展」· CS 代码 · 共 55 行

CS
55
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using PMS.PMSClass;
namespace PMS
{
    public partial class frmAddDep : Form
    {
        public frmAddDep()
        {
            InitializeComponent();
        }
        DBOperate operate = new DBOperate();
        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (txtDepName.Text.Trim() == "")
            {
                MessageBox.Show("请输入部门名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                string str="select count(*) from tb_department where DepName='"+txtDepName.Text.Trim()+"'";
                int i=operate.HumanNum(str);
                if (i > 0)
                {
                    MessageBox.Show("该部门已经存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    string Addsql = "insert into tb_department(DepName) values('" + txtDepName.Text.Trim() + "')";
                    if (operate.OperateData(Addsql) > 0)
                    {
                        MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }

        private void frmAddDep_Load(object sender, EventArgs e)
        {

        }
    }
}

⌨️ 快捷键说明

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