Hệ thống quản lý phòng tập trong C#

1 using System;
2 using
System.Collections.Generic;
3 using
System.ComponentModel;
4 using
System.Data;
5 using
System.Drawing;
6 using
System.Linq;
7 using
System.Text;
8 using
System.Windows.Forms;
9 using
System.Data.SqlClient;
10
11 namespace
GymManagementSystem
12 {
13     
public partial class Register : Form
14     {
15         
public Register()
16         {
17             InitializeComponent();
18         }
19
20         
private void button1_Click(object sender, EventArgs e)
21         {
22             SqlConnection con =
new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\Sem.4\C# Projects\GymManagementSystem in C#\GymManagementSystem\Gym.mdf;Integrated Security=True;User Instance=True");
23             con.Open();
24             
string gender = string.Empty;
25             
if (radioButton1.Checked)
26             {
27                 gender =
"Male";
28             }
29             
else if (radioButton2.Checked)
30             {
31                 gender =
"Female";
32             }
33             
try
34             {
35                 
string str = " INSERT INTO employee(emp_username,name,password,gender,email,mobile,address,date) VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + gender + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "'); ";
36
37                 SqlCommand cmd =
new SqlCommand(str, con);
38                 cmd.ExecuteNonQuery();
39
40                 
string str1 = "select max(emp_id) from employee ;";
41
42                 SqlCommand cmd1 =
new SqlCommand(str1, con);
43                 SqlDataReader dr = cmd1.ExecuteReader();
44                 
if (dr.Read())
45                 {
46                     MessageBox.Show(
"" + textBox1.Text + "'s Details is Inserted Successfully.. " + textBox1.Text + "'s Id is " + dr.GetInt32(0) + ".", "Important Message");
47                     
this.Hide();
48                     Home obj1 =
new Home();
49                     obj1.ShowDialog();
50                 }
51                 
this.Close();
52             }
53             
catch (SqlException excep)
54             {
55                 MessageBox.Show(excep.Message);
56             }
57             con.Close();
58         }
59     }
60 }


Gõ tìm kiếm nhanh...