📄 insertop_form.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Entity;
using BusinessLayer;
namespace project_beat
{
public partial class InsertOp_Form : Form
{
Bll_OpTable bll_optable = new Bll_OpTable();
OpTable optable = new OpTable();
public InsertOp_Form()
{
InitializeComponent();
this.comboBox1.SelectedIndex = 0;
}
public InsertOp_Form(OpTable o)
{
InitializeComponent();
this.Text = "修改";
txtid.Text = o.OpId;
txtid.ReadOnly = true;
txtName.Text = o.OpName;
txtpwd1.Text = o.OpPwd;
txtpwd2.Text = o.OpPwd;
txtMoney.Text = o.MaxMoney.ToString();
comboBox1.Text = o.State;
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnSave_Click(object sender, EventArgs e)
{
if (this.Text == "修改")
{
if (txtpwd2.Text.Trim() == "" || txtid.Text.Trim() == "" || txtName.Text.Trim() == "" || txtMoney.Text.Trim() == "")
MessageBox.Show("信息不完整!", "提示信息");
else
UpdateOP();
}
else
{
if (txtpwd2.Text.Trim() == "" || txtid.Text.Trim() == "" || txtName.Text.Trim() == "" || txtMoney.Text.Trim() == "")
MessageBox.Show("信息不完整!", "提示信息");
else
InsertOP();
}
}
private void InsertOP()
{
optable.OpId = txtid.Text.Trim();
optable.OpName = txtName.Text.Trim();
optable.OpPwd = txtpwd2.Text.Trim();
optable.MaxMoney = int.Parse(txtMoney.Text.Trim());
optable.State = comboBox1.Text.Trim();
int i = bll_optable.InsertOpTable(optable);
if(i>0)
{
this.Close();
}
else
MessageBox.Show("保存失败!","提示信息");
}
private void UpdateOP()
{
optable.OpId = txtid.Text.Trim();
optable.OpName = txtName.Text.Trim();
optable.OpPwd = txtpwd2.Text.Trim();
optable.MaxMoney = int.Parse(txtMoney.Text.Trim());
optable.State = comboBox1.Text.Trim();
int i = bll_optable.UpdateOpTableById(optable);
if (i > 0)
{
this.Close();
}
else
MessageBox.Show("保存失败!", "提示信息");
}
private void txtpwd2_Leave(object sender, EventArgs e)
{
if (txtpwd1.Text.Trim() != txtpwd2.Text.Trim())
{
MessageBox.Show("两次密码输入不一致!", "提示信息");
txtpwd1.Focus();
}
}
private void txtpwd1_Leave(object sender, EventArgs e)
{
}
private void InsertOp_Form_Load(object sender, EventArgs e)
{
}
private void txtMoney_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = e.KeyChar < '0' || e.KeyChar > '9';
if (e.KeyChar == (char)8)
e.Handled = false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -