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

📄 absentform.cs

📁 c# 人事工资管理系统平台,很好用嘎..你们看看参考
💻 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.Data.SqlClient;

namespace MyPersonnel
{
    public partial class AbsentForm : Form
    {
        public AbsentForm()
        {
            InitializeComponent();
        }

        private void 缺勤记录BindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.缺勤记录BindingSource.EndEdit();
            this.缺勤记录TableAdapter.Update(this.myPersonnelDataSet.缺勤记录);

        }

        private void AbsentForm_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“myPersonnelDataSet.缺勤记录”中。您可以根据需要移动或移除它。
            this.缺勤记录TableAdapter.Fill(this.myPersonnelDataSet.缺勤记录);

        }

        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {
            //自动计算缺勤记录自编号
            String MySQLConnectionString = global::MyPersonnel.Properties.Settings.Default.MyPersonnelConnectionString;
            SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
            MyConnection.Open();
            SqlCommand MyCommand = MyConnection.CreateCommand();
            MyCommand.CommandText = "Select max(自编号) 最大编号 From 缺勤记录";
            object MyResult = MyCommand.ExecuteScalar();
            Int64 MyID = 1;
            if (MyResult != System.DBNull.Value)
            {
                String MyMaxID = MyResult.ToString().Trim();
                MyMaxID = MyMaxID.Substring(2, MyMaxID.Length - 2);
                MyID = Convert.ToInt64(MyMaxID) + 1;
            }
            int MyLength = MyID.ToString().Length;
            string MyNewID = "";
            switch (MyLength)
            {
                case 1:
                    MyNewID = "QQ0000000" + MyID.ToString();
                    break;
                case 2:
                    MyNewID = "QQ000000" + MyID.ToString();
                    break;
                case 3:
                    MyNewID = "QQ00000" + MyID.ToString();
                    break;
                case 4:
                    MyNewID = "QQ0000" + MyID.ToString();
                    break;
                case 5:
                    MyNewID = "QQ000" + MyID.ToString();
                    break;
                case 6:
                    MyNewID = "QQ00" + MyID.ToString();
                    break;
                case 7:
                    MyNewID = "QQ0" + MyID.ToString();
                    break;
            }
            if (MyConnection.State == ConnectionState.Open)
            {
                MyConnection.Close();
            }
            this.自编号TextBox.Text = MyNewID;          
        }

        private void 查询ToolStripButton_Click(object sender, EventArgs e)
        {
            String MySQLConnectionString = global::MyPersonnel.Properties.Settings.Default.MyPersonnelConnectionString;
            SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
            MyConnection.Open();
            string MySQL = "Select * From 基本档案 Where 姓名 LIKE '" + this.员工姓名ToolStripTextBox.Text + "' AND (员工编号 NOT IN(SELECT 员工编号 FROM 离职管理))";
            DataTable MyPersonnelTable = new DataTable();
            SqlDataAdapter MyDataAdapter = new SqlDataAdapter(MySQL, MyConnection);
            MyDataAdapter.Fill(MyPersonnelTable);
            this.基本档案DataGridView.DataSource = MyPersonnelTable;
            if (MyConnection.State == ConnectionState.Open)
            {
                MyConnection.Close();
            }
        }

        private void 基本档案DataGridView_Click(object sender, EventArgs e)
        {
            this.员工编号TextBox.Text = this.基本档案DataGridView.CurrentRow.Cells[1].Value.ToString();
            this.员工姓名TextBox.Text = this.基本档案DataGridView.CurrentRow.Cells[3].Value.ToString();
        }

        private void 基本档案DataGridView_SelectionChanged(object sender, EventArgs e)
        {
            string My员工姓名 = this.基本档案DataGridView.CurrentRow.Cells[3].Value.ToString();
            try
            {
                this.缺勤记录TableAdapter.FillBy(this.myPersonnelDataSet.缺勤记录, My员工姓名);
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }

   
    }
}

⌨️ 快捷键说明

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