CHANGE_TEXT.cs
上传用户:zhongfine
上传日期:2022-08-01
资源大小:2860k
文件大小:3k
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace 人事管理系统
- {
- public partial class CHANGE_TEXT : Form
- {
- Datacon mydatacon = new Datacon();
- SqlConnection sqlcn = new SqlConnection();
- SqlDataAdapter myadapter = new SqlDataAdapter();
- DataSet mydataset = new DataSet();
- public CHANGE_TEXT()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- sqlcn=mydatacon.getcon();
- sqlcn.Open();
-
- string cmd = "select CODE as 记录编号, DESCRIPTION as 人事变动信息描述 from [PERSONNEL_CHANGE]";
- myadapter = new SqlDataAdapter(cmd, sqlcn);
- mydataset.Clear();
- myadapter.Fill(mydataset, "PERSONNEL_CHANGE");
- dataGridView1.DataSource = mydataset.Tables["PERSONNEL_CHANGE"];//刷新dataGridView1内人事变更记录的最新数据
- sqlcn.Close();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void CHANGE_TEXT_Load(object sender, EventArgs e)
- {
- sqlcn = mydatacon.getcon();
- sqlcn.Open();
-
- string cmd = "select CODE as 记录编号, DESCRIPTION as 人事变动信息描述 from [PERSONNEL_CHANGE]";
- myadapter = new SqlDataAdapter(cmd, sqlcn);
- mydataset.Clear();
- myadapter.Fill(mydataset, "PERSONNEL_CHANGE");
- dataGridView1.DataSource = mydataset.Tables["PERSONNEL_CHANGE"];//在窗体加载的同时填充dataGridView1内部门的最新数据
- sqlcn.Close();
- }
- private void button3_Click(object sender, EventArgs e)
- {
- if (label1.Text == "管理员")
- {
- if (DialogResult.OK == MessageBox.Show("确认清空人事变更记录表里面的记录吗?(不可恢复,慎用!)", "信息提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information))
- {
- sqlcn.Open();
- SqlCommand cmd = new SqlCommand("清空人事变动记录表", sqlcn);
- cmd.ExecuteNonQuery();
- cmd.CommandText = "update COUNTER set COUNTER_VAL='0' where CODE='2'";
- cmd.ExecuteNonQuery();
- MessageBox.Show("数据库中所有人事变更信息清空成功!");
- SqlCommand acd = new SqlCommand();
- SqlDataAdapter myadapter = new SqlDataAdapter("select CODE as 记录编号, DESCRIPTION as 人事变动信息描述 from [PERSONNEL_CHANGE]", sqlcn);
- mydataset.Clear();
- myadapter.Fill(mydataset, "PERSONNEL_CHANGE");
- dataGridView1.DataSource = mydataset.Tables["PERSONNEL_CHANGE"];//在窗体加载的同时填充dataGridView1内部门的最新数据
- sqlcn.Close();
- }
- else
- {
- return;
- }
- }
- else
- {
- MessageBox.Show("您的权限不够,无法使用该项!");
- return;
- }
-
- }
- }
- }