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

📄 formmodifyemployee.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.Data.SqlClient;

namespace HumanResourceManagement
{
    public partial class FormModifyEmployee : Form
    {
        SqlConnection cnn;
        public FormModifyEmployee()
        {
            InitializeComponent();
        }

        private const int CP_NOCLOSE_BUTTON = 0x200;
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams myCp = base.CreateParams;
                myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON;
                return myCp;
            }
        } 

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Hide();
            FormListEmployee FE = new FormListEmployee();
            FE.Show();
        }

        private void BtnUpdateEmployee_Click(object sender, EventArgs e)
        {
            byte[] images = FormPhotoPath.image;
            if (textBox1.Text.Trim() == "")
            {
                DialogResult = MessageBox.Show("请输入姓名!", "提示");
                textBox1.Focus();
            }
            else if (textBox4.Text.Trim() == "")
            {
                DialogResult = MessageBox.Show("请输入电子邮件!", "提示");
                textBox4.Focus();
            }
            else
            {
                try
                {
                    SqlConnection con = DB.connection();
                    con.Open();
                    SqlCommand cmd = new SqlCommand("update tblEmployee set Name=('" + textBox1.Text.ToString().Trim() + "'),Password=('" + textBox3.Text.ToString().Trim()
                        + "'),Email=('" + textBox4.Text.ToString().Trim() + "'),DeptID=('" + cbDepartment.Text.ToString().Trim() + "'),BasicSalary=('" + textBox5.Text.ToString().Trim()
                        + "'),Title=('" + textBox7.Text.ToString().Trim()
                        + "'),Telephone=('" + textBox8.Text.ToString().Trim() + "'),PhotoImage=('" + images + "'),EmployeeLevel=('" + numLevel.Value.ToString() + "') where LoginName=('" + textBox2.Text.ToString().Trim() + "')", con);
                    int count = Convert.ToInt32(cmd.ExecuteNonQuery());
                    if (count > 0)
                    {
                        con.Close();
                        DialogResult = MessageBox.Show("修改成功!", "提示");
                        this.Hide();
                        FormListEmployee FE = new FormListEmployee();
                        FE.Show();
                    }
                    else
                    {
                        con.Close();
                        DialogResult = MessageBox.Show("操作失败!", "提示");
                    }
                }
                catch (Exception EV)
                {
                    DialogResult = MessageBox.Show(EV.ToString(), "异常提示");
                }
            }
        }

        private void buttonUploadPhoto_Click(object sender, EventArgs e)
        {
            FormPhotoPath FP = new FormPhotoPath();
            FP.Show();
        }
        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            string imageU = FormPhotoPath.txt;
            picPhoto.ImageLocation = imageU;
        }

        private void FormModifyEmployee_Load_1(object sender, EventArgs e)
        {
            cnn = new SqlConnection("data source=.;initial catalog=BlueHill_HRM;integrated security=true;");
            cnn.Open();
            SqlCommand cmd1 = new SqlCommand("select * from tblDepartment", cnn);
            SqlDataReader bm1 = cmd1.ExecuteReader();
            while (bm1.Read())
            {
                cbDepartment.Items.Add(bm1["DeptName"].ToString());
            }
            cnn.Close();
        }
    }
}

⌨️ 快捷键说明

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