📄 frmchangeprize.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 frmChangePrize : Form
{
public frmChangePrize()
{
InitializeComponent();
}
public string Uid;
public string Uname;
DBOperate operate = new DBOperate();
private void frmChangePrize_Load(object sender, EventArgs e)
{
if (cbbUserJFType.Text == "奖励")
{
txtFK.Enabled = false;
txtJL.Enabled = true;
}
else
{
txtJL.Enabled = false;
txtFK.Enabled = true;
}
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();
this.Text = "[" + Uname + "]";
string sql = "select * from tb_prize where UserID='" + Uid + "'";
DataSet ds = operate.GetTable(sql);
ds.Dispose();
cbbUserNum.Text = ds.Tables[0].Rows[0][1].ToString();
cbbUserJFType.Text = ds.Tables[0].Rows[0][4].ToString();
txtname.Text = ds.Tables[0].Rows[0][2].ToString();
txtdep.Text = ds.Tables[0].Rows[0][3].ToString();
txtJFcontent.Text = ds.Tables[0].Rows[0][5].ToString();
txtJL.Text = ds.Tables[0].Rows[0][6].ToString();
txtFK.Text = ds.Tables[0].Rows[0][7].ToString();
txtJFdate.Text = ds.Tables[0].Rows[0][8].ToString();
txtCXDate.Text = ds.Tables[0].Rows[0][9].ToString();
}
private void cbbUserJFType_SelectedIndexChanged(object sender, EventArgs e)
{
if (cbbUserJFType.Text == "奖励")
{
txtFK.Enabled = false;
txtJL.Enabled = true;
}
else
{
txtJL.Enabled = false;
txtFK.Enabled = true;
}
}
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void 添加ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (cbbUserNum.Text == "" || cbbUserJFType.Text == "" || txtJFcontent.Text == "" || txtJL.Text == "" || txtFK.Text == "" || txtJFdate.Text == "" || txtCXDate.Text == "")
{
MessageBox.Show("请将信息填写完整!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
if (cbbUserJFType.Text == "奖励")
{
if (Regex.IsMatch(txtJL.Text.Trim(), @"[1-9]\d*.\d{2}"))
{
string sql = "update tb_prize set UserName='" + txtname.Text + "',UserDep='" + txtdep.Text + "',UserJF='" + cbbUserJFType.Text + "',UserJFcontent='" + txtJFcontent.Text + "',UserJLMoney='" + txtJL.Text + "',UserFKMoney='" + txtFK.Text + "',UserJFDate='" + txtJFdate.Text + "',UserCXDate='" + txtCXDate.Text + "' where UserID='" + cbbUserNum.Text + "'";
if (operate.OperateData(sql) > 0)
{
MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
MessageBox.Show("请输入正确金额格式!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
else
{
if (Regex.IsMatch(txtFK.Text.Trim(), @"[1-9]\d*.\d{2}"))
{
string sql = "update tb_prize set UserName='" + txtname.Text + "',UserDep='" + txtdep.Text + "',UserJF='" + cbbUserJFType.Text + "',UserJFcontent='" + txtJFcontent.Text + "',UserJLMoney='" + txtJL.Text + "',UserFKMoney='" + txtFK.Text + "',UserJFDate='" + txtJFdate.Text + "',UserCXDate='" + txtCXDate.Text + "' where UserID='" + cbbUserNum.Text + "'";
if (operate.OperateData(sql) > 0)
{
MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
MessageBox.Show("请输入正确金额格式!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
}
}
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;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -