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

📄 formaddaward.cs

📁 数据库开发与实例(1+1混合数据库开发实例丛书)人事管理系统的源代码
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace HRMan.HROper
{
    public partial class FormAddAward : Form
    {
        public FormAddAward()
        {
            InitializeComponent();
        }

        private void FormAddAward_Load(object sender, EventArgs e)
        {
            HRMan.HROper.FormAwardInfo.awardform.Enabled = false;  
            if (HRMan.HROper.FormAwardInfo.awardID == "insert")
            {
                this.InitDep();
                this.InitName();
                this.InitNum();
            }
            if (HRMan.HROper.FormAwardInfo.awardID == "update")
            {
                string[] ss = HRMan.HROper.FormAwardInfo.awardform.sb.ToString().Split('#'); 
                this.ID = ss[0];
                this.No_cb.Text = ss[1];
                this.No_cb.Enabled = false;
                this.No_cb.DropDownStyle = ComboBoxStyle.Simple;
                this.Name_txt.Text = ss[2];
                this.Time_dtp.Text = ss[3];
                this.Type_cb.Text = ss[4];
                this.Reson_txt.Text = ss[5];
                this.Context_txt.Text = ss[6];
                this.Section_cb.Text = ss[7];
                this.App_cb.Text = ss[8];
                this.Repealtime_dtp.Text = ss[9];
                this.Repealreson_txt.Text = ss[10];
                this.Remarks_txt.Text = ss[11];
                this.InitDep();
                this.InitName();
            }
        }
        //初始化
        private void InitDep()
        {
            string SqlText = "select * from SectionInfo";
            DataTable dt = new DataTable();
            DataAccess DA = new DataAccess(); 
            dt = DA.ExeSQLdt(SqlText);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                this.Section_cb.Items.Add(dt.Rows[i]["sName"].ToString());
            }
        }

        private void InitName()
        {
            string SqlText = "select * from EmployInfo";
            DataAccess DA = new DataAccess(); 
            this.dt = DA.ExeSQLdt(SqlText);
            for (int i = 0; i < this.dt.Rows.Count; i++)
            {
                this.App_cb.Items.Add(this.dt.Rows[i]["eName"].ToString());
            }
        }

        private void InitNum()
        {
            for (int i = 0; i < this.dt.Rows.Count; i++)
            {
                this.No_cb.Items.Add(this.dt.Rows[i]["eId"].ToString());
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            HRMan.HROper.FormAwardInfo.awardform.Enabled = true;
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (HRMan.HROper.FormAwardInfo.awardID == "insert")
            {
                string SqlText = "insert into PpInfo (pId,pDate,pType,pReason,pContext,pAppS,pApp,pRepealDate,pRepealReason,pRemarks) values (" + int.Parse(this.No_cb.Text) + ",'";
                SqlText += this.Time_dtp.Value.ToShortDateString() + "','" + this.Type_cb.Text + "','" + this.Reson_txt.Text + "','" + this.Context_txt.Text + "','";
                SqlText += this.Section_cb.Text + "','" + this.App_cb.Text + "','" + this.Repealtime_dtp.Value.ToShortDateString() + "','" + this.Repealreson_txt.Text + "','";
                SqlText += this.Remarks_txt.Text + "')";
                DataAccess DA = new DataAccess();
                DA.ExeSQL(SqlText);
                HRMan.HROper.FormAwardInfo.awardform.Enabled = true;
                HRMan.HROper.FormAwardInfo.awardform.DBDataGrid();
                this.Close();
                MessageBox.Show("添加成功!");
            }
            if (HRMan.HROper.FormAwardInfo.awardID == "update")
            {
                string SqlText = "update PpInfo set pDate='" + this.Time_dtp.Value.ToShortDateString() + "',pType='" + this.Type_cb.Text + "',pReason='";
                SqlText += this.Reson_txt.Text + "',pContext='" + this.Context_txt.Text + "',pAppS='" + this.Section_cb.Text + "',pRepealDate='" + this.Repealtime_dtp.Value.ToShortDateString();
                SqlText += "',pRepealReason='" + this.Repealreson_txt.Text + "',pRemarks='" + this.Remarks_txt.Text + "' where pppId=" + int.Parse(this.ID);
                DataAccess DA = new DataAccess();
                DA.ExeSQL(SqlText);
                HRMan.HROper.FormAwardInfo.awardform.Enabled = true;
                HRMan.HROper.FormAwardInfo.awardform.DBDataGrid();
                this.Close();
                MessageBox.Show("修改成功!");
            }
        }

        private void FormAddAward_EnabledChanged(object sender, EventArgs e)
        {
            HRMan.HROper.FormAwardInfo.awardform.DBDataGrid();
        }

        private void No_cb_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (int i = 0; i < this.dt.Rows.Count; i++)
            {
                if (this.No_cb.Text == this.dt.Rows[i]["eId"].ToString())
                {
                    this.Name_txt.Text = this.dt.Rows[i]["eName"].ToString();
                    break;
                }
            }
        }

        private void FormAddAward_FormClosing(object sender, FormClosingEventArgs e)
        {
            HRMan.HROper.FormAwardInfo.awardform.Enabled = true;
        }
    }
}

⌨️ 快捷键说明

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