📄 form3.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;
namespace Store
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
DateTime date1= DateTime.Now;
String b = date1.Year.ToString() +'-'+ date1.Month.ToString() + '-'+date1.Day.ToString();
textBox9.Text = b;
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
if (e.Node.Text.Equals("活期取款")&&e.Node.Parent.Text.Equals("取款"))
{
comboBox1.Text = "活期取款";
this.panel1.Visible = true;
this.panel2.Visible = false;
this.panel3.Visible = false;
this.panel4.Visible = false;
}
else if (e.Node.Text.Equals("定期取款") && e.Node.Parent.Text.Equals("取款"))
{
comboBox1.Text = "定期取款";
this.panel1.Visible = true;
this.panel2.Visible = false;
this.panel3.Visible = false;
this.panel4.Visible = false;
}
else if (e.Node.Text.Equals("活期存款") && e.Node.Parent.Text.Equals("存款"))
{
textBox14.Text = "活期存款";
this.panel2.Visible = true;
this.panel1.Visible = false;
this.panel3.Visible = false;
this.panel4.Visible = false;
}
else if (e.Node.Text.Equals("定期存款") && e.Node.Parent.Text.Equals("存款"))
{
textBox14.Text = "定期存款";
this.panel2.Visible = true;
this.panel1.Visible = false;
this.panel3.Visible = false;
this.panel4.Visible = false;
}
else if (e.Node.Text.Equals("开户") && e.Node.Parent.Text.Equals("存款"))
{
this.panel3.Visible = true;
this.panel1.Visible = false;
this.panel2.Visible = false;
this.panel4.Visible = false;
}
else if (e.Node.Text.Equals("Edit"))
{
this.panel2.Visible = true;
this.panel1.Visible = false;
}
else if (e.Node.Text.Equals("查询"))
{
this.panel4.Visible = true;
this.panel2.Visible = false;
this.panel3.Visible = false;
this.panel1.Visible = false;
}
else if (e.Node.Text.Equals("修改密码")&&e.Node.Parent.Text.Equals("系统维护"))
{
Form4 f = new Form4();
f.Focus();
f.Show();
}
else if (e.Node.Text.Equals("在线帮助") && e.Node.Parent.Text.Equals("系统维护"))
{
Form5 s = new Form5();
s.Focus();
s.Show();
}
}
private void button7_Click(object sender, EventArgs e)
{
this.panel1.Visible = false;
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
this.panel1.Visible = true;
this.panel2.Visible = false;
}
private void button5_Click(object sender, EventArgs e)
{
取款信息打印 frm = new 取款信息打印();
frm.Show();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text != "")
{
SqlConnection connection = new SqlConnection("Data Source=localhost;Initial Catalog=银行储蓄系统;Integrated Security=SSPI");
try
{
connection.Open();
SqlCommand command = new SqlCommand("select * from 储户信息 where 储户编号='" + textBox1.Text + "'", connection);
SqlDataReader reader = command.ExecuteReader();
//reader.Read();
if (reader.Read())
{
textBox2.Text = reader["储户编号"].ToString();
textBox3.Text = reader["利息"].ToString();
textBox6.Text = reader["利率"].ToString();
textBox5.Text = reader["金额"].ToString();
}
else
MessageBox.Show("储户不存在!");
}
catch (SqlException b)
{
Console.WriteLine(b.Message);
}
finally
{
connection.Close();
}
}
else
MessageBox.Show("请输入储户编号!");
}
private void button2_Click(object sender, EventArgs e)
{
if (textBox10.Text != "")
{
SqlConnection connection = new SqlConnection("Data Source=localhost;Initial Catalog=银行储蓄系统;Integrated Security=SSPI");
try
{
connection.Open();
SqlCommand command = new SqlCommand("select * from 储户信息 where 储户编号='" + textBox10.Text + "'", connection);
SqlDataReader reader = command.ExecuteReader();
string c_mm=reader["密码"].ToString();
if (Convert.ToInt32(textBox2.Text)==Convert.ToInt32(c_mm))
{
textBox4.Enabled = true;
}
else
MessageBox.Show("密码不正确!");
}
catch (SqlException b)
{
Console.WriteLine(b.Message);
}
finally
{
connection.Close();
}
}
else
MessageBox.Show("请输入储户密码!");
}
private void button3_Click(object sender, EventArgs e)
{
SqlConnection connection = new SqlConnection("Data Source=localhost;Initial Catalog=银行储蓄系统;Integrated Security=SSPI");
if (textBox4.Text != "")
{
try
{
connection.Open();
string sqlstr = " Insert into 取款信息(取款编号,取款人,取款日期,取款金额,用户帐号,业务员编号) Values('" + textBox12.Text + "','" + textBox7.Text + "','" + textBox9.Text + "','" + textBox4.Text + "','" + textBox12.Text + "','" + textBox11.Text + "',)";
SqlCommand command1 = new SqlCommand(sqlstr, connection);
// 插入
//command1.CommandText = sqlstr;
//command1.Connection = connection;
SqlCommand command2 = new SqlCommand("update set 金额='" + textBox8.Text + "', from 储户信息 where 储户编号='" + textBox1.Text + "'", connection);
//string sqlstr = " Insert into card(取款编号,取款人,取款日期,取款金额) Values('" + textBox12.Text + "','" + textBox7.Text + "','" + textBox9.Text + "','" + textBox4.Text + "')";// 插入
//command1.CommandText = sqlstr;
//command1.Connection = connection;
command1.ExecuteNonQuery();
MessageBox.Show("操作成功!");
}
catch (SqlException b)
{
Console.WriteLine(b.Message);
}
finally
{
connection.Close();
}
}
else
MessageBox.Show("输入取款金额!");
}
private void button11_Click(object sender, EventArgs e)
{
SqlConnection connection = new SqlConnection("Data Source=localhost;Initial Catalog=银行储蓄系统;Integrated Security=SSPI");
if (textBox27.Text != "")
{
int num = 1;
try
{
connection.Open();
string sqlstr = " Insert into 储户信息(储户编号,卡号,密码,储户姓名,身份证号,地址,联系电话,业务员编号,开户日期,备注) Values("+"'"+num+"',"+"'" + textBox27.Text + "',"+"'" + textBox26.Text + "',"+"'" + textBox25.Text + "',"+"'" + textBox24.Text + "',"+"'" + textBox23.Text + "',"+"'" + textBox17.Text + "',"+"'" + textBox15.Text + "',"+"'" + textBox28.Text + "',"+"'" +richTextBox1.Text + "')";// 插入
SqlCommand command1 = new SqlCommand(sqlstr, connection);
//SqlCommand command2 = new SqlCommand("update set 金额='" + textBox8.Text + "', from 储户信息 where 储户编号='" + textBox1.Text + "'", connection);
string sqlstr1 = " Insert into 帐户信息(储户编号,用户帐号,密码,,开户日期,类型,金额,利率,期限) Values(" + "'" + num + "'," + "'" + textBox27.Text + "'," + "'" + textBox26.Text + "'," + "'" + textBox28.Text + "',"+"'0',"+"'0',"+"'0',"+"'0')";// 插入
SqlCommand command2 = new SqlCommand(sqlstr1, connection);
//command1.CommandText = sqlstr;
//command1.Connection = connection;
int i,j;
i = command1.ExecuteNonQuery();
j = command2.ExecuteNonQuery();
if ((i < 1)||(j < 1))
{
MessageBox.Show("操作失败!");
connection.Close();
}
else
{
MessageBox.Show("操作成功!");
num++;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -