📄 frmuser.cs
字号:
this.txtID.Text="";
this.txtPwd.Text="";
}
sw.Close();
sr.Close();
net.Close();
}
catch
{
this.tabControl1.SelectedIndex=7;
this.lblErrorMsg.Text="登陆失败.帐户不存在!";
this.timer2.Start();
this.txtID.Text="";
this.txtPwd.Text="";
}
}
private void button1_Click(object sender, System.EventArgs e)
{
try
{
string line="";
if(this.tabControl1.SelectedIndex==2)
{
line="QUERYBALANCE|"+this.txtID.Text+"|"+this.txtPwd.Text;
}
TcpClient tcp=new TcpClient();
tcp.Connect(IPAddress.Parse("127.0.0.1"),9000);
NetworkStream net=tcp.GetStream();
StreamWriter sw=new StreamWriter(net);
StreamReader sr=new StreamReader(net);
sw.WriteLine(line);
sw.Flush();
int aa=int.Parse(sr.ReadLine().ToString());
this.tabControl1.SelectedIndex=6;
this.lblOkMsg.Text="用户帐号为"+this.txtID.Text+"的余额为: "+aa+".00元";
sw.Flush();
sw.Close();
sr.Close();
net.Close();
}
catch
{
this.tabControl1.SelectedIndex=7;
this.lblErrorMsg.Text="密码有误!";
this.timer1.Start();
}
}
private void button3_Click(object sender, System.EventArgs e)
{
try
{
mac=Convert.ToDouble(this.txtQueQian.Text);
}
catch
{
MessageBox.Show("金额应输入数字!");
this.txtQueQian.Text="";
return;
}
//判断转账金额的正确
if(int.Parse(this.txtQueQian.Text) <0)
{
MessageBox.Show("金额不能为负数");
this.txtQueQian.Text = "";
return;
}
else if(this.txtQueQian.Text.StartsWith("0"))
{
MessageBox.Show("不能以0开头");
this.txtChunQian.Text = "";
return;
}
else
{
try
{
string line="";
if(this.tabControl1.SelectedIndex==3)
{
line="GETMONEY|"+this.txtID.Text+"|"+mac;
}
TcpClient tcp=new TcpClient();
tcp.Connect(IPAddress.Parse("127.0.0.1"),9000);
NetworkStream net=tcp.GetStream();
StreamWriter sw=new StreamWriter(net);
StreamReader sr=new StreamReader(net);
sw.WriteLine(line);
sw.Flush();
this.btnPrint.Visible = true;
this.tabControl1.SelectedIndex=6;
string i=sr.ReadLine();
//MessageBox.Show(""+i);
if(i=="888")
{
this.lblOkMsg.Text="您已顺利取款!";
}
else
{
this.tabControl1.SelectedIndex=7;
this.lblErrorMsg.Text="您的余额不足!";
}
sw.Close();
sr.Close();
net.Close();
}
catch
{
this.tabControl1.SelectedIndex=7;
this.lblErrorMsg.Text="您已取款失败,请核实密码和余额!";
this.timer1.Start();
}
}
}
private void button4_Click(object sender, System.EventArgs e)
{
try
{
mac=Convert.ToDouble(this.txtChunQian.Text);
}
catch
{
MessageBox.Show("金额应输入数字!");
this.txtChunQian.Text="";
return;
}
//判断转账金额的正确
if(int.Parse(this.txtChunQian.Text) <0)
{
MessageBox.Show("金额不能为负数");
this.txtChunQian.Text = "";
return;
}
else if(this.txtChunQian.Text.StartsWith("0"))
{
MessageBox.Show("不能以0开头");
this.txtChunQian.Text = "";
return;
}
else
{
try
{
string line="";
if(this.tabControl1.SelectedIndex==4)
{
line="SETMONEY|"+this.txtID.Text+"|"+mac;
}
TcpClient tcp=new TcpClient();
tcp.Connect(IPAddress.Parse("127.0.0.1"),9000);
NetworkStream net=tcp.GetStream();
StreamWriter sw=new StreamWriter(net);
StreamReader sr=new StreamReader(net);
sw.WriteLine(line);
sw.Flush();
string i=sr.ReadLine();
//MessageBox.Show(i);
if(i=="888")
{
this.btnPrint.Visible = true;
this.tabControl1.SelectedIndex=6;
this.lblOkMsg.Text="您已顺利存款!";
}
else if(i=="444")
{
this.tabControl1.SelectedIndex=7;
this.lblErrorMsg.Text="您的余额不足!";
}
else if(i=="400")
{
this.tabControl1.SelectedIndex=7;
this.lblErrorMsg.Text="您的余额不足!";
}
sw.Flush();
sw.Close();
sr.Close();
net.Close();
}
catch
{
this.tabControl1.SelectedIndex=7;
this.lblErrorMsg.Text="您已存款失败,请核实密码!";
this.timer1.Start();
}
}
}
//用户输入的金额
double mac;
private void button5_Click(object sender, System.EventArgs e)
{
try
{
mac=Convert.ToDouble(this.txtZhuanMoney.Text);
}
catch
{
MessageBox.Show("输入错误,请重新输入!");
this.txtZhuanMoney.Text="";
return;
}
if(this.txtDuiZhang.Text==this.txtID.Text)
{
MessageBox.Show("不能给自己转账!");
this.txtDuiZhang.Text="";
this.txtADuiZhang.Text="";
this.txtZhuanMoney.Text="";
return;
}
else if(this.txtDuiZhang.Text != this.txtADuiZhang.Text)
{
MessageBox.Show("帐号不一致,请重新输入!");
this.txtADuiZhang.Text="";
this.txtDuiZhang.Text="";
this.txtZhuanMoney.Text="";
}
else if(this.txtZhuanMoney.Text.StartsWith("0"))
{
MessageBox.Show("不能以0开头");
return;
}
//判断转账金额的正确
else if(int.Parse(this.txtZhuanMoney.Text) <0)
{
MessageBox.Show("金额不能为负数");
this.txtZhuanMoney.Text = "";
return;
}
//判断每天交易金额的最大限度
else if(int.Parse(this.txtZhuanMoney.Text) >= 50000)
{
MessageBox.Show("交易金额过大,请重新填入!");
this.txtZhuanMoney.Text = "";
return;
}
else if(this.txtDuiZhang.Text.Equals("1001") || this.txtDuiZhang.Text.Equals("1002") || this.txtDuiZhang.Text.Equals("1003"))
{
try
{
string line="";
if(this.tabControl1.SelectedIndex==5)
{
line="TRANSFER|"+this.txtID.Text+"|"+this.txtDuiZhang.Text+"|"+mac;
}
TcpClient tcp=new TcpClient();
tcp.Connect(IPAddress.Parse("127.0.0.1"),9000);
NetworkStream net=tcp.GetStream();
StreamWriter sw=new StreamWriter(net);
StreamReader sr=new StreamReader(net);
sw.WriteLine(line);
sw.Flush();
this.btnPrint.Visible = true;
string i=sr.ReadLine();
if(i=="888")
{
this.tabControl1.SelectedIndex=6;
this.lblOkMsg.Text="您已顺利转帐!";
}
else if(i=="444")
{
this.tabControl1.SelectedIndex=7;
this.lblErrorMsg.Text="您的余额不足!";
}
else if(i=="400")
{
this.tabControl1.SelectedIndex=7;
this.lblErrorMsg.Text="您的余额不足!";
}
sw.Close();
sr.Close();
net.Close();
}
catch
{
this.tabControl1.SelectedIndex=7;
this.lblErrorMsg.Text="您不能成功转帐,请核实帐号";
this.timer1.Start();
}
}
else
{
this.tabControl1.SelectedIndex=7;
this.lblErrorMsg.Text="请核实帐号";
this.timer1.Start();
}
}
private void button7_Click(object sender, System.EventArgs e)
{
btn("2");
}
private void button6_Click(object sender, System.EventArgs e)
{
btn("1");
}
private void button21_Click(object sender, System.EventArgs e)
{
this.tabControl1.SelectedIndex = 3;
}
Random ran = new Random(123);
private void button18_Click(object sender, System.EventArgs e)
{
this.tabControl1.SelectedIndex = 1;
}
private void button19_Click(object sender, System.EventArgs e)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -