try
str = \from 备忘录 where 备忘类别='\ +
{time = DateTime.Parse(textBox2.Text);} comboBox2.Text + \提醒时间='\ + catch (Exception s)
{ MessageBox.Show(\你输入的日期格式不正\,
\错误提示\); return; textBox2.Text + \备忘标题='\ +
textBox1.Text + \;
comboBox2.Text = null; }
str = \from 备忘录 where 备忘类别='\ + comboBox2.Text + \提醒时间='\ + textBox2.Text + \;
comboBox2.Text = null; textBox2.Clear(); } else
if (textBox1.Text != \ && textBox2.Text != \ && comboBox2.Text != \) { string lei = comboBox2.Text;
if (lei.Equals(\日程表\) == false && lei.Equals(\纪念日\) == false && lei.Equals(\记事本\) == false &&
lei.Equals(\节日\) == false && lei.Equals(\备忘录\) == false)
{ MessageBox.Show(\你输入的类别不正确,请重新输入!\, \错误提示\);
return; } else
{ DateTime time = DateTime.Now; try
{ time = DateTime.Parse(textBox2.Text); } catch (Exception s)
{ MessageBox.Show(\你输入的日期格式不正确\,
\错误提示\); return;
}
textBox2.Clear(); textBox1.Clear(); } else
{ MessageBox.Show(\你没有输入要删除的条件\,\错误提示\); return;
}
string connstr = \Source=(local);Initial Catalog=Message;Integrated Security=True\; SqlConnection con = new SqlConnection (connstr); con.Open(); try
{ SqlCommand comm = new SqlCommand(str, con); comm.ExecuteNonQuery(); }
catch (Exception ex) { MessageBox.Show(\没有找到你要删除的信息\, \错误提示\); return; } MessageBox.Show(\信息删除成功!\,\提示\); con.Close(); } (2)备忘录的修改按钮的代码实现: private void button1_Click(object sender,
EventArgs e) { string str = null;
string title=textBox3.Text;
if (textBox3.Text == \) { MessageBox.Show(\你没有输入要修改的标题
\,\错误提示\); return;
} else
if (textBox4.Text != \ && textBox5.Text == \ } 重新输入!\, \错误提示\); return;
&& comboBox1.Text == \)
{ str = \备忘录 set 备忘内容='\+textBox4.Text+\备忘标题='\+title+\; textBox4.Clear(); } else
if (textBox4.Text == \ && textBox5.Text != \&& comboBox1.Text == \) { DateTime time = DateTime.Now; try
{ time = DateTime.Parse(textBox5.Text);} catch (Exception s)
{ MessageBox.Show(\你输入的日期格式不正确\, \错误提示\); return; }
str = \备忘录 set 提醒时间='\ + textBox5.Text + \where 备忘标题='\ + title textBox5.Clear(); } else
if (textBox4.Text == \ && textBox5.Text == \&& comboBox1.Text != \) { string lei = comboBox1.Text;
if (lei.Equals(\日程表\) == false &&
lei.Equals(\纪念日\) == false && lei.Equals(\记事本\) == false && lei.Equals(\节日\) == false && lei.Equals(\备忘录\) == false) MessageBox.Show(\你输入的类别不正确,请
else
{ str = \备忘录 set 备忘类别='\ + comboBox1.Text + \备忘标题='\ + title + \;
comboBox1.Text = null; } else
if (textBox4.Text != \\ { DateTime time = DateTime.Now; try
{ time = DateTime.Parse(textBox5.Text);} catch (Exception s)
{ MessageBox.Show(\你输入的日期格式不正确\错误提示\ return; }
str = \备忘录 set 备忘内容='\textBox4.Text + \提醒时间='\
textBox5.Text + \备忘标题='\+ title ;
textBox4.Clear(); textBox5.Clear(); } else
if (textBox4.Text != \
\ { string lei = comboBox1.Text; if (lei.Equals(\日程表\
lei.Equals(\纪念日\lei.Equals(\记事本\lei.Equals(\节日\
lei.Equals(\备忘录\ { MessageBox.Show(\你输入的类别不正确,
comboBox1.Text + \备忘标题='\ +
title + \;
请重新输入!\错误提示\comboBox1.Text = null; textBox5.Clear();
} else
{ str = \备忘录 set 备忘内容='\textBox4.Text + \备忘类别='\
comboBox1.Text + \备忘标题='\title + \
comboBox1.Text = null; textBox4.Clear(); } else
if (textBox4.Text == \\{ string lei = comboBox1.Text; if (lei.Equals(\日程表\lei.Equals(\纪念日\lei.Equals(\记事本\lei.Equals(\节日\lei.Equals(\备忘录\
{ MessageBox.Show(\你输入的类别不正确,请
重新输入!\错误提示\ } else
{ DateTime time = DateTime.Now; try
{ time = DateTime.Parse(textBox5.Text);} catch (Exception s)
{ MessageBox.Show(\你输入的日期格式不正确\, \错误提示\); return;
} str = \备忘录 set 提醒时间='\ + textBox5.Text + \备忘类别='\ +
} else
if (textBox4.Text != \ && textBox5.Text != \ && comboBox1.Text != \)
{ string lei = comboBox1.Text; if (lei.Equals(\日程表\) == false
&&lei.Equals(\纪念日\) == false && lei.Equals(\记事本\) == false &&
lei.Equals(\节日\) == false && lei.Equals(\备忘录\) == false)
{ MessageBox.Show(\你输入的类别不正确,请重
新输入!\, \错误提示\); return; } else { DateTime time = DateTime.Now; try
{ time = DateTime.Parse(textBox5.Text);} catch (Exception s)
{ MessageBox.Show(\你输入的日期格式不正确\,
\错误提示\); return; }
str = \备忘录 set 备忘内容='\ +
textBox4.Text + \提醒时间='\ +
textBox5.Text + \备忘类别='\ +
comboBox1.Text + \备忘标题='\ + title + \; comboBox1.Text = null; textBox4.Clear(); textBox5.Clear(); }
string connstr = \Source=(local);Initial
Catalog=Message;Integrated Security=True\; SqlConnection con = new SqlConnection(connstr); con.Open(); try
{ SqlCommand comm = new SqlCommand(str, con); comm.ExecuteNonQuery();
}
catch (Exception ex)
{ MessageBox.Show(\没有找到你要修改的信息\, \错误提示\); return; }
MessageBox.Show(\信息修改成功!\, \提示\); con.Close(); }
个人理财界面的实现如下图4-5所示:
图4-5 个人理财界面的实现
(1)显示全部费用按钮的代码的实现: private void button15_Click(object sender, EventArgs e)
{ DataSet dst = new DataSet();
string connstr = \Source=(local);Initial Catalog=Message;Integrated Security=True\; SqlConnection con = new SqlConnection (connstr); con.Open();
string str = \个人理财\; SqlDataAdapter sda = new SqlDataAdapter(str,
con);
SqlCommandBuilder scd = new SqlCommand Builder(sda); sda.Fill(dst, \); dataGridView2.DataSource = dst.Tables [\].DefaultView; con.Close(); }
(2)实现查询费用下一条按钮的实现代码: private void button9_Click(object sender, EventArgs e)
{row = dataGridView2.RowCount;
for (int i = 0; i < row - 1; i++)
{ if (dataGridView2.Rows[i].Selected == true) { dataGridView2.Rows[i].Selected = false; if (i == row - 2)
{ dataGridView2.Rows[0].Selected = true;} else
dataGridView2.Rows[i + 1].Selected = true; else
if (textBox12.Text == \)
{ MessageBox.Show(\你没有输入费用\,\错误提示\); return; } else
if (textBox14.Text == \)
}
(3)实现费用查询的上一条按钮代码的实现: private void button8_Click(object sender, EventArgs e)
{ row = this.dataGridView2.RowCount; for (int i = 0; i < row - 1; i++)
{if (dataGridView2.Rows[i].Selected == true) {dataGridView2.Rows[i].Selected = false; if (i == 0)
dataGridView2.Rows[row - 2].Selected = true; else
dataGridView2.Rows[i - 1].Selected = true;break; }
(4)费用的删除按钮的代码实现:
private void button10_Click(object sender, EventArgs e)
{ 查询个人理财 chaxun = new 查询个人理财(); chaxun.Visible = true; }
(5)添加个人费用按钮代码的实现:
private void button13_Click(object sender, EventArgs e)
{ if (textBox11.Text == \)
{ MessageBox.Show(\你没有输入费用名称!\,\
错误提示\); return; }
{ MessageBox.Show(\你没有输入备忘录的提示时 间\, \错误提示\); return; }
DateTime time = DateTime.Now; Try
{ time = DateTime.Parse(textBox14.Text);} catch (Exception s)
{ MessageBox.Show(\你输入的日期格式不正确\, \错误提示\); return; }
DataSet dst = new DataSet();
string connstr = \Source=(local);Initial Catalog=Message;Integrated Security=True\; SqlConnection con = new SqlConnection (connstr); ; con.Open();
string name = null; int danjia = 0; string beizhu = null;
DateTime date = DateTime.Now;
string leixing = \支出\;name = textBox11.Text; try
{ danjia = int.Parse(textBox12.Text.Trim());}catch(Exception d){MessageBox.Show(\你输入的单价信息错误!\,\提示\);} beizhu = textBox13.Text.Trim();
date = Convert.ToDateTime(textBox14.Text. Trim());