📄 frmcomnpty.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using property.control.SystemInfo;
using property.model.SystemInfo;
namespace property.view.SystemInfo
{
public partial class frmComnpty : Form
{
public frmComnpty()
{
InitializeComponent();
}
public frmComnpty(string Name)
{
InitializeComponent();
strName = Name;
}
public string strName;
private void toolStripButton1_Click(object sender, EventArgs e)
{
DialogResult a = MessageBox.Show("是否要退出?", "退出", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (Convert.ToString(a) == "Yes")
{
this.Close();
}// end block if
}// 退出
private void Comnpty_Load(object sender, EventArgs e)
{
GetUserJob job = new GetUserJob();
SqlDataReader dr = job.getselect();
while (dr.Read())
{
this.txtUserName.Text = dr[1].ToString();
txtusermonofile.Text = dr[2].ToString();
txtuseraddress.Text = dr[3].ToString();
txtuseracridine.Text = dr[4].ToString();
txtuserphone.Text = dr[5].ToString();
}
dr.Close();
this.toolQiuxiao.Enabled = false;
this.toolsave.Enabled = false;
this.TxtEnabled(false);//文本不可用
}
// 保存
private void toolsave_Click(object sender, EventArgs e)
{
if (this.txtUserName.Text == "")
{
MessageBox.Show("用户姓名不能为空", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Hand);
this.txtUserName.Focus();
}//end block menthod if
else if (txtusermonofile.Text == "")
{
MessageBox.Show("单位名称不能为空", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Hand);
this.txtusermonofile.Focus();
}//end block menthod else if
else if (this.txtuseraddress.Text == "")
{
MessageBox.Show("单位地址不能为空", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Hand);
this.txtuseraddress.Focus();
}//end block menthod else if
else if (this.txtuseracridine.Text == "")
{
MessageBox.Show("邮编不能为空", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Hand);
this.txtuseracridine.Focus();
}//end block menthod else if
else if (this.txtuserphone.Text == "")
{
MessageBox.Show("联系电话不能为空", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Hand);
this.txtuserphone.Focus();
}//end block menthod else if
else
{
GetUserJob job = new GetUserJob();
UserJob user = new UserJob();
user.setUsername(this.txtUserName.Text.Trim());
user.setUsermonofile(this.txtusermonofile.Text.Trim());
user.setUseraddress(this.txtuseraddress.Text.Trim());
user.setUserphone(this.txtuserphone.Text.Trim());
user.setUseracridine(this.txtuseracridine.Text.Trim());
string P_Str_insert = job.InsetJob(user);
if (P_Str_insert == "OK")
{
MessageBox.Show("添加成功", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.toolQiuxiao.Enabled = false;
toolsave.Enabled = false;
toolAdd.Enabled = true;
this.TxtEnabled(false);//文本不可用
}// end block
if (P_Str_insert == "NO")
{
MessageBox.Show("注册失败\n"+"请重新注册", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.txtUserName.Text = "";
this.txtUserName.Focus();
this.txtusermonofile.Text="";
this.txtuseraddress.Text="";
this.txtuserphone.Text="";
this.txtuseracridine.Text = "";
}//end block if
}//end block menthod else保存
}// 保存
//增加
private void toolAdd_Click(object sender, EventArgs e)
{
this.toolQiuxiao.Enabled = true;
this.toolsave.Enabled = true;
this.toolAdd.Enabled = false;
this.TxtEnabled(true);//文本可用
}//增加
//撤消
private void toolQiuxiao_Click(object sender, EventArgs e)
{
this.toolAdd.Enabled = true;
this.toolsave.Enabled = false;
this.toolQiuxiao.Enabled = false;
this.TxtEnabled(false);//文本不可用
}///撤消
/////控制文本框可用
public void TxtEnabled(bool blText)
{
this.txtUserName.Enabled=blText;
txtusermonofile.Enabled=blText;
txtuseraddress.Enabled=blText;
txtuseracridine.Enabled = blText;
txtuserphone.Enabled=blText;
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
}//end block menthod
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -