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

📄 frmuserkqmanage.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 PMS.PMSClass;
namespace PMS
{
    public partial class frmUserKqManage : Form
    {
        public frmUserKqManage()
        {
            InitializeComponent();
        }
        DBOperate operate = new DBOperate();
        public string Ydate;
        private void frmUserKqManage_Load(object sender, EventArgs e)
        {
            operate.BindDropdownlist("tb_employee",cbbYnum,1);
            for (int i = 1; i <= 12; i++)
            {
                toolStripComboBox1.Items.Add(i+"月");
            }
        }

        private void cbbYnum_SelectedIndexChanged(object sender, EventArgs e)
        {
            string id = cbbYnum.Text;
            string sql = "select * from tb_employee where employeeID='" + id + "'";
            DataSet ds = operate.GetTable(sql);
            ds.Dispose();
            txtYname.Text = ds.Tables[0].Rows[0][2].ToString();
            txtYsex.Text = ds.Tables[0].Rows[0][3].ToString();
            txtYdep.Text = ds.Tables[0].Rows[0][4].ToString();
            txtYzhiwu.Text = ds.Tables[0].Rows[0][8].ToString();
            txtYbasepay.Text = ds.Tables[0].Rows[0][12].ToString();
            switch (txtYzhiwu.Text)
            {
                case "总经理": txtYjintie.Text = "500"; break;
                case "副总经理": txtYjintie.Text = "400"; break;
                case "项目经理": txtYjintie.Text = "300"; break;
                case "部门经理": txtYjintie.Text = "200"; break;
                case "程序员": txtYjintie.Text = "100"; break;
                case "文员":
                case "后勤": txtYjintie.Text = "50"; break;
            }
            string sql1 = "select * from tb_prize where UserID='"+id+"'";
            DataSet ds1 = operate.GetTable(sql1);
            ds.Dispose();
            string str = "select count(*) from tb_prize where UserID='" + id + "'";
            int i = operate.HumanNum(str);
            if (i > 0)
            {
                if (ds1.Tables[0].Rows[0][8].ToString().Substring(6, 1) == Ydate)
                {
                    txtYjiangli.Text = ds1.Tables[0].Rows[0][6].ToString();
                    txtYfakuan.Text = ds1.Tables[0].Rows[0][7].ToString();
                }
                else
                {
                    txtYfakuan.Text = "0";
                    txtYjiangli.Text = "0";
                }
            }
            else
            {
                txtYfakuan.Text = "0";
                txtYjiangli.Text = "0";
            }
        }

        private void toolStripLabel1_Click(object sender, EventArgs e)
        {
            if (txtYjiaban.Text == "" || txtYquanqin.Text == "" || toolStripComboBox1.Text == "" || cbbYnum.Text == "")
            {
                MessageBox.Show("请先选择工资的月份,然后将信息填写完整", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                string str = "select count(*) from tb_pay where YID='" + cbbYnum.Text + "' and YMonth='"+Ydate+"'";
                int i = operate.HumanNum(str);
                if (i > 0)
                {
                    MessageBox.Show(Ydate + "月份" + txtYname.Text + "的工资已经做过统计", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    try
                    {
                        string id = cbbYnum.Text;//员工编号
                        string name = txtYname.Text;//员工姓名
                        string sex = txtYsex.Text;//员工性别
                        string dep = txtYdep.Text;//员工部门
                        string zhiwu = txtYzhiwu.Text;//职务
                        string basepay = txtYbasepay.Text;//基本工资
                        string zhiwujintie = txtYjintie.Text;//职务津贴
                        string jiangli = txtYjiangli.Text;//奖金
                        string fakuan = txtYfakuan.Text;//罚款
                        string quanqin = txtYquanqin.Text;//全勤奖金
                        string jiaban = txtYjiaban.Text;//加班工资
                        string Ymonth = Ydate;//月份
                        decimal yingfa = Convert.ToDecimal(basepay) + Convert.ToDecimal(zhiwujintie) + Convert.ToDecimal(jiangli) - Convert.ToDecimal(fakuan) + Convert.ToDecimal(quanqin) + Convert.ToDecimal(jiaban);//应发工资
                        decimal geren = operate.GYSD(Convert.ToInt32(yingfa));//个人所得税
                        decimal shifa = yingfa - geren;//实发工资
                        string sql = "insert into tb_pay(YID,YName,YSex,Ydep,YZhiwu,YBasePay,YJintie,Yjiangli,YFK,Yquanqin,Yjiaban,Yyingfa,Ygeren,Ypay,YMonth) values('" + id + "','" + name + "','" + sex + "','" + dep + "','" + zhiwu + "','" + basepay + "','" + zhiwujintie + "','" + jiangli + "','" + fakuan + "','" + quanqin + "','" + jiaban + "','" + yingfa + "','" + geren + "','" + shifa + "','" + Ydate + "')";
                        if (operate.OperateData(sql) > 0)
                        {
                            MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }

        private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            cbbYnum.Enabled = true;
            Ydate = toolStripComboBox1.SelectedItem.ToString().Substring(0,1);
        }

        private void txtYquanqin_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar))
            {
                MessageBox.Show("只能输入数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                e.Handled = true;
            }
        }

        private void txtYjiaban_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar))
            {
                MessageBox.Show("只能输入数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                e.Handled = true;
            }
        }

        private void toolStripLabel2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

⌨️ 快捷键说明

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