-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathForm2.cs
More file actions
110 lines (101 loc) · 4.72 KB
/
Form2.cs
File metadata and controls
110 lines (101 loc) · 4.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.IO;
namespace DesignPattern
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "*.jpg|*.jpg|*.gif|*.gif|*.BMP|*.BMP";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string fullpath = openFileDialog1.FileName;
FileStream fs = new FileStream(fullpath, FileMode.Open);
byte[] imagebytes = new byte[fs.Length];
BinaryReader br = new BinaryReader(fs);
imagebytes = br.ReadBytes(Convert.ToInt32(fs.Length));
//string strpath = Application.StartupPath + "\\a.xls";
//string strpath = Application.StartupPath + "\\b.mdb";
string path = Application.StartupPath;
string strpath = path + @"/datebase.mdb";
string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strpath;
OleDbConnection olecon = new OleDbConnection(constr);
olecon.Open();
//OleDbCommand oledcom = new OleDbCommand("insert into dezignpattern(UML) values(@ImageList)", olecon);
OleDbCommand oledcom = new OleDbCommand("update dezignpattern set UML=@ImageList where Name='"+richTextBox1.Text+"'", olecon);
oledcom.Parameters.Add("ImageList", OleDbType.Binary);
oledcom.Parameters["ImageList"].Value = imagebytes;
oledcom.ExecuteNonQuery();
olecon.Close();
MessageBox.Show("图片保存完毕");
}
}
private void Form2_Load(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
//更新简介
string path = Application.StartupPath;
string strpath = path + @"/datebase.mdb";
string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strpath;
OleDbConnection olecon = new OleDbConnection(constr);
olecon.Open();
//OleDbCommand oledcom = new OleDbCommand("insert into dezignpattern(UML) values(@ImageList)", olecon);
OleDbCommand oledcom = new OleDbCommand("update dezignpattern set Summer='"+richTextBox2.Text+"' where Name='" + richTextBox1.Text + "'", olecon);
oledcom.ExecuteNonQuery();
olecon.Close();
MessageBox.Show("简介更新完毕");
}
private void button3_Click(object sender, EventArgs e)
{
//更新总结
string path = Application.StartupPath;
string strpath = path + @"/datebase.mdb";
string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strpath;
OleDbConnection olecon = new OleDbConnection(constr);
olecon.Open();
//OleDbCommand oledcom = new OleDbCommand("insert into dezignpattern(UML) values(@ImageList)", olecon);
OleDbCommand oledcom = new OleDbCommand("update dezignpattern set MainText='" + richTextBox3.Text + "' where Name='" + richTextBox1.Text + "'", olecon);
oledcom.ExecuteNonQuery();
olecon.Close();
MessageBox.Show("总结更新完毕");
}
private void button4_Click(object sender, EventArgs e)
{
//更新代码
try
{
string path = Application.StartupPath;
string strpath = path + @"/datebase.mdb";
string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strpath;
OleDbConnection olecon = new OleDbConnection(constr);
olecon.Open();
//OleDbCommand oledcom = new OleDbCommand("insert into dezignpattern(UML) values(@ImageList)", olecon);
OleDbCommand oledcom = new OleDbCommand("update dezignpattern set exCode='" + richTextBox4.Text + "' where Name='" + richTextBox1.Text + "'", olecon);
oledcom.ExecuteNonQuery();
olecon.Close();
MessageBox.Show("代码更新完毕");
}
catch (Exception ex)
{
MessageBox.Show("代码更新失败,出现异常"+ex.ToString());
}
}
private void richTextBox3_TextChanged(object sender, EventArgs e)
{
}
}
}