📄 frmjfmanage.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;
using PMS.PMSClass;
using System.Text.RegularExpressions;
namespace PMS
{
public partial class frmJFmanage : Form
{
public frmJFmanage()
{
InitializeComponent();
}
DBOperate operate = new DBOperate();
private void frmJFmanage_Load(object sender, EventArgs e)
{
SqlConnection conn = DBConnection.MyConnection();
conn.Open();
SqlCommand cmd = new SqlCommand("select * from tb_employee", conn);
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
cbbUserNum.Items.Add(sdr["employeeID"].ToString());
}
sdr.Close();
conn.Close();
}
private void cbbUserNum_SelectedIndexChanged(object sender, EventArgs e)
{
string str = "select * from tb_employee where employeeID='" + cbbUserNum.Text + "'";
DataSet ds = operate.GetTable(str);
ds.Dispose();
txtname.Text = ds.Tables[0].Rows[0][2].ToString();
txtdep.Text = ds.Tables[0].Rows[0][4].ToString();
}
private void cbbUserJFType_SelectedIndexChanged(object sender, EventArgs e)
{
if (cbbUserJFType.Text == "奖励")
{
txtFK.Enabled = false;
txtFK.Text = "0";
txtJL.Enabled = true;
}
else
{
txtJL.Enabled = false;
txtJL.Text = "0";
txtFK.Enabled = true;
}
}
private void txtJL_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar))
{
MessageBox.Show("只能输入数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
e.Handled = true;
}
}
private void txtFK_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar))
{
MessageBox.Show("只能输入数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
e.Handled = true;
}
}
private void 添加ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (cbbUserNum.Text == "" || cbbUserJFType.Text == "" || txtJFcontent.Text == "" || txtJFdate.Text == "" || txtCXDate.Text == "")
{
MessageBox.Show("请将信息填写完整!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
if (cbbUserJFType.Text == "奖励")
{
if (txtJL.Text == "")
{
MessageBox.Show("请输入奖励金额!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
string sql = "select count(*) from tb_prize where UserID='" + cbbUserNum.Text + "'";
int i = operate.HumanNum(sql);
if (i > 0)
{
MessageBox.Show("员工编号已经存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
string str = "insert into tb_prize(UserID,UserName,UserDep,UserJF,UserJFcontent,UserJLMoney,UserFKMoney,UserJFDate,UserCXDate) values('" + cbbUserNum.Text + "','" + txtname.Text + "','" + txtdep.Text + "','" + cbbUserJFType.Text + "','" + txtJFcontent.Text + "','" + txtJL.Text + "','" + txtFK.Text + "','" + txtJFdate.Text + "','" + txtCXDate.Text + "')";
operate.OperateData(str);
MessageBox.Show("添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
else
{
try
{
if (txtFK.Text == "")
{
MessageBox.Show("罚款金额不为空");
}
else
{
string sql = "select count(*) from tb_prize where UserID='" + cbbUserNum.Text + "'";
int i = operate.HumanNum(sql);
if (i > 0)
{
MessageBox.Show("员工编号已经存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
string str = "insert into tb_prize(UserID,UserName,UserDep,UserJF,UserJFcontent,UserJLMoney,UserFKMoney,UserJFDate,UserCXDate) values('" + cbbUserNum.Text + "','" + txtname.Text + "','" + txtdep.Text + "','" + cbbUserJFType.Text + "','" + txtJFcontent.Text + "','" + txtJL.Text + "','" + txtFK.Text + "','" + txtJFdate.Text + "','" + txtCXDate.Text + "')";
operate.OperateData(str);
MessageBox.Show("添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -