个人理财系统.docx
《个人理财系统.docx》由会员分享,可在线阅读,更多相关《个人理财系统.docx(47页珍藏版)》请在冰豆网上搜索。
个人理财系统
privatevoidbtlogin_Click(objectsender,EventArgse)
{stringusername=null;
stringpassword=null;
if(tbusername.Text=="”)
{MessageBox。
Show("你没有输入用户名!
","错误提示”);return;
}
if(tbmima.Text=="")
{MessageBox。
Show("你没有输入密码!
",”错误提示");
return;
}
DataSetdst=newDataSet();
stringconnstr="DataSource=(local);InitialCatalog=Message;IntegratedSecurity=True";
SqlConnectioncon=newSqlConnection(connstr);
con.Open();
stringstr=”select*from登录”;
SqlDataAdaptersda=newSqlDataAdapter(str,con);
SqlCommandBuilderscd=newSqlCommand
Builder(sda);
sda.Fill(dst,"tong");
dataGridView1。
DataSource=dst.Tables
[”tong”]。
DefaultView;
username=dataGridView1.Rows[0]。
Cells[0].
Value.ToString()。
Trim();
password=dataGridView1。
Rows[0]。
Cells[1].
Value.ToString()。
Trim();
if(tbusername。
Text.Equals(username)&&tbmima。
Text。
Equals(password))
{Form2f2=newForm2();
f2.Visible=true;
this。
Visible=false;
}
else
{MessageBox.Show("你输入的用户名或密码错误",”错误提示");
tbusername.Clear();
tbmima。
Clear();
}
con.Close();
}
privatevoidbtcancel_Click(objectsender,EventArgse)
{if(MessageBox。
Show(”你是否真的想退出系统?
",”提示",MessageBoxButtons.YesNo)!
=DialogResult.No)
{this。
Close();}
}
privatevoidbutton1_Click(objectsender,EventArgse)
{stringusername=null;
stringpassword=null;
if(tbusername.Text=="")
{MessageBox.Show(”你没有输入用户名!
”,”错误提示");return;
}
if(tbmima。
Text==”")
{MessageBox。
Show("你没有输入密码!
”,"错误提示”);return;
}
DataSetdst=newDataSet();
stringconnstr=”DataSource=(local);InitialCatalog=Message;IntegratedSecurity=True";
SqlConnectioncon=newSqlConnection
(connstr);
con。
Open();
stringstr="select*from登录";
SqlDataAdaptersda=newSqlDataAdapter(str,con);
SqlCommandBuilderscd=newSqlCommand
Builder(sda);
sda。
Fill(dst,”tong”);
dataGridView1。
DataSource=dst.Tables
["tong"]。
DefaultView;
username=dataGridView1.Rows[0].Cells[0].
Value.ToString().Trim();
password=dataGridView1.Rows[0]。
Cells[1].
Value。
ToString().Trim();
if(tbusername.Text.Equals(username)&&tbmima。
Text。
Equals(password))
{if(MessageBox.Show(”你确定要修改密码吗?
","提示",MessageBoxButtons。
YesNo)==DialogResult.Yes)
{修改密码mima=new修改密码();
mima.Visible=true;
}
}
else
{MessageBox。
Show("你输入的用户名或密码错误","错误提示");
tbusername。
Clear();
tbmima。
Clear();
}
con。
Close();
}
privatevoidbutton1_Click(objectsender,EventArgse)
{stringusername=null;
stringpassword=null;
if(textBox1。
Text==””)
{MessageBox.Show("你没有输入密码!
","错误提示");
return;
}
if(textBox2。
Text==””)
{MessageBox。
Show(”你没有输入更改密码!
","错误提示”);return;
}
if(textBox3.Text==””)
{MessageBox。
Show("你没有再次输入更改密码!
”,"错误提示”);
return;
}
stringb=textBox2。
Text.ToString().Trim();
stringa=textBox3。
Text。
ToString().Trim();
if(b。
Equals(a)==false)
{MessageBox。
Show("你两次输入的密码不一样!
","错误提示”);return;
}
DataSetdst=newDataSet();
stringconnstr=”DataSource=(local);InitialCatalog=Message;IntegratedSecurity=True”;
SqlConnectioncon=newSqlConnection
(connstr);
con。
Open();
stringstr=”select*from登录";
SqlDataAdaptersda=newSqlDataAdapter(str,con);
SqlCommandBuilderscd=newSqlCommand
Builder(sda);
sda。
Fill(dst,"tong");
dataGridView1.DataSource=dst。
Tables
["tong”]。
DefaultView;
username=dataGridView1。
Rows[0].Cells[0]。
Value。
ToString().Trim();
password=dataGridView1.Rows[0]。
Cells[1].
Value。
ToString().Trim();
if(textBox1.Text。
Equals(password))
{Stringsql="update登录setmima=’"+textBox2.Text.Trim()+”’whereusername=’"+username+”’";
Try
{SqlCommandcomm=newSqlCommand(sql,con);
comm。
ExecuteNonQuery();
}
catch(Exceptiones)
{MessageBox.Show("修改密码失败!
”,”提示");
return;
}
}
else
{MessageBox。
Show("你输入的密码错误”,”错误提示");
textBox1.Clear();
return;
}
MessageBox。
Show("密码更改成功!
");
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
con。
Close();
}
privatevoidbutton2_Click(objectsender,EventArgse)
{this.Close();}
实现代码如下:
privatevoidbutton6_Click(objectsender,EventArgse)//实现备忘录的查询
{stringstr=null;
if(textBox6。
Text!
=”")
{str="select*from备忘录where备忘标题=’”+textBox6.Text+”’";
textBox6。
Clear();
}
else
if(comboBox1.Text!
=””)
{stringlei=comboBox1.Text;
if(lei.Equals(”日程表”)==false&&lei。
Equals("纪念日”)==false&&lei.Equals("记事本”)==false&&lei.Equals(”节日”)==false&&lei。
Equals("备忘录”)==false)
{MessageBox。
Show(”你输入的类别不正确,请重新输入!
”,"错误提示”);
return;
}
else
{str="select*from备忘录where备忘类别=’”+comboBox1。
Text+"'”;
comboBox1。
Text=null;
}
else
if(textBox7。
Text!
=”")
{DateTimetime=DateTime。
Now;
try
{time=DateTime.Parse(textBox7.Text);}
catch(Exceptions)
{MessageBox.Show(”你输入的日期格式不正确","错误提示");
return;
}
str=”select*from备忘录whereYEAR(创建时间)=YEAR(’”+time+"')andMONTH(创建时间)=MONTH(’”+time+”’)andDAY(创建时间)=DAY('”+time+”')";
textBox7.Clear();
}
else
{MessageBo