資源簡介
學校老師要求的數據庫系統的三級項目,一個OJ系統的數據庫實現部分,其中有個txt文檔是創建數據庫,創建之后修改C#中的數據庫鏈接代碼即可實現。需要安裝sqlserver。

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Drawing;
using?System.Data;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
using?System.Data.SqlClient;
namespace?DB1
{
????public?partial?class?chuangjianshanchuxiaozu?:?UserControl
????{
????????public?chuangjianshanchuxiaozu()
????????{
????????????InitializeComponent();
????????}
????????private?void?button2_Click(object?sender?EventArgs?e)
????????{
????????????string?GR=textBox1.Text;
????????????string?GRname?=?textBox2.Text;
????????????string?now=DateTime.Now.ToString();
????????????string?user=Form1.nowUser;
????????????string?sql?=?“Insert?into?OJ_GROUP?values(‘“+GR+“‘‘“+GRname+“‘‘“+now+“‘‘“+user+“‘)“;
????????????SqlCommand?cmd?=?con.CreateCommand();
????????????cmd.CommandText?=?sql;
????????????try
????????????{
????????????????if?(cmd.ExecuteNonQuery()?==?1)
????????????????{
????????????????????MessageBox.Show(“添加小組成功!“);
????????????????}
????????????????else
????????????????????MessageBox.Show(“添加失敗!請重新添加“);
????????????}
????????????catch
????????????{
????????????????MessageBox.Show(“添加失敗!請重新添加“);
????????????}
????????}
????????SqlConnection?con;
????????private?void?chuangjianshanchuxiaozu_Load(object?sender?EventArgs?e)
????????{
????????????con?=?conn.GetInstance();
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????string?GR?=?textBox1.Text;
????????????string?GRname?=?textBox2.Text;
????????????string?now?=?DateTime.Now.ToString();
????????????string?user?=?Form1.nowUser;
????????????string?sql?=?“DELETE?FROM?OJ_ADMIN_GRO_QUE?WHERE?GR#=‘“?+?GR?+?“‘;DELETE?FROM?OJ_JOIN_GRO?WHERE?GR#=‘“?+?GR?+?“‘;DELETE?FROM?OJ_STU_QUE_GRADE?WHERE?GR#=‘“?+?GR?+?“‘;DELETE?FROM?OJ_GROUP?WHERE?GR#=‘“?+?GR?+?“‘;“;
????????????SqlCommand?cmd?=?con.CreateCommand();
????????????cmd.CommandText?=?sql;
????????????try
????????????{
????????????????if?(cmd.ExecuteNonQuery()?==?1)
????????????????{
????????????????????MessageBox.Show(“刪除成功!“);
????????????????}
????????????????else
????????????????{
????????????????????MessageBox.Show(“無效刪除!請檢查小組編號“);
????????????????}
????????????}
????????????catch
????????????{
????????????????MessageBox.Show(“刪除失敗!請重新操作“);
????????????}
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-12-12?10:31??DB1\
?????目錄???????????0??2017-12-14?14:24??DB1\DB1\
?????文件?????????187??2017-12-12?10:31??DB1\DB1\App.config
?????文件????????6865??2017-12-13?20:11??DB1\DB1\DB1.csproj
?????文件???????17789??2017-12-13?16:12??DB1\DB1\Form1.Designer.cs
?????文件????????7114??2017-12-13?19:45??DB1\DB1\Form1.cs
?????文件????????5817??2017-12-13?16:12??DB1\DB1\Form1.resx
?????文件?????????515??2017-12-12?10:31??DB1\DB1\Program.cs
?????目錄???????????0??2017-12-12?10:31??DB1\DB1\Properties\
?????文件????????1330??2017-12-12?10:31??DB1\DB1\Properties\AssemblyInfo.cs
?????文件????????2858??2017-12-12?10:31??DB1\DB1\Properties\Resources.Designer.cs
?????文件????????5612??2017-12-12?10:31??DB1\DB1\Properties\Resources.resx
?????文件????????1090??2017-12-12?10:31??DB1\DB1\Properties\Settings.Designer.cs
?????文件?????????249??2017-12-12?10:31??DB1\DB1\Properties\Settings.settings
?????目錄???????????0??2017-12-12?20:00??DB1\DB1\bin\
?????目錄???????????0??2017-12-13?21:08??DB1\DB1\bin\Debug\
?????文件???????43520??2017-12-14?14:55??DB1\DB1\bin\Debug\DB1.exe
?????文件?????????187??2017-12-12?10:31??DB1\DB1\bin\Debug\DB1.exe.config
?????文件??????101888??2017-12-14?14:55??DB1\DB1\bin\Debug\DB1.pdb
?????文件???????24224??2017-12-14?18:19??DB1\DB1\bin\Debug\DB1.vshost.exe
?????文件?????????187??2017-12-12?10:31??DB1\DB1\bin\Debug\DB1.vshost.exe.config
?????文件?????????490??2017-03-19?05:00??DB1\DB1\bin\Debug\DB1.vshost.exe.manifest
?????目錄???????????0??2017-12-16?15:28??DB1\DB1\bin\Release\
?????文件????????5031??2017-12-13?09:43??DB1\DB1\chuangjianshanchuxiaozu.Designer.cs
?????文件????????2503??2017-12-13?09:50??DB1\DB1\chuangjianshanchuxiaozu.cs
?????文件????????5817??2017-12-13?09:43??DB1\DB1\chuangjianshanchuxiaozu.resx
?????文件????????8980??2017-12-12?23:26??DB1\DB1\chuti.Designer.cs
?????文件????????2683??2017-12-13?09:50??DB1\DB1\chuti.cs
?????文件????????5817??2017-12-12?23:26??DB1\DB1\chuti.resx
?????文件????????1203??2017-12-14?14:11??DB1\DB1\conn.cs
?????文件????????6897??2017-12-13?20:20??DB1\DB1\dati.Designer.cs
............此處省略47個文件信息
- 上一篇:C# 串口調試助手源代碼
- 下一篇:C#經典編程220-含隨書視頻及源代碼
評論
共有 條評論