2 using System.Collections.Generic;
3 using System.ComponentModel;
8 using System.Windows.Forms;
9 using MySql.Data.MySqlClient;
11 namespace HospitalManageSys
13 public partial class Form_Registration : Form
23 public Form_Registration(MySqlConnection connector, MainForm mainform)
25 InitializeComponent();
29 string constr = "server=localhost;database=hospitalmanagesys;uid=huangweiqiang;pwd=hwq123456;";
30 //con = new MySqlConnection(constr);
33 cmd = new MySqlCommand("select * from administrator", con);
34 ada = new MySqlDataAdapter(cmd);
38 //textBox8.Text = ds.Tables[0].Rows[0].ItemArray[1].ToString();
41 string strID = getID();
43 textBox8.Text = strID;
47 int ds_count = ds.Tables[0].Rows.Count;
48 for (int i = 0; i < ds_count; i++)
50 comboBox1_doctorID.Items.Add(ds.Tables[0].Rows[i].ItemArray[0].ToString());
56 private void Form1_Load(object sender, EventArgs e)
61 private void label5_Click(object sender, EventArgs e)
66 private string getID()
68 string str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZ";
69 int[] iArr = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
70 char[] cArr = str.ToCharArray();
71 Random rad =new Random();
72 string date = DateTime.Now.ToString("yyyyMMddHHmmss");
73 int str_i = rad.Next(cArr.Length);
74 int i = rad.Next(iArr.Length);
75 string name = date;//+ " " + cArr[str_i] + iArr[i];
81 private void textBox8_Click(object sender, EventArgs e)
83 string strID = getID();
85 textBox8.Text = strID;
88 private void button1_Click(object sender, EventArgs e)
90 cmd.CommandText = "insert into registration (registration_count,patient_name,patient_sex,patient_insurance,doctor_ID,patient_address,patient_fee) value"
91 + "('" + textBox8.Text + "','" + textBox_name.Text + "','" + textBox_patientsex.Text + "','" + textBox_patient_insurance.Text + "','" + comboBox1_doctorID.Text + "','" + textBox4_patientaddress.Text + "','" + textBox_patient_fee.Text + "');";
92 cmd.ExecuteNonQuery();
97 private void textBox8_TextChanged(object sender, EventArgs e)
101 textBox8.Text = strID;
104 private void listBox1_SelectedIndexChanged_1(object sender, EventArgs e)
106 /* string constr = "server=localhost;database=hospitalmanagesys;uid=huangweiqiang;pwd=hwq123456;";
107 con = new MySqlConnection(constr);
109 MySqlCommand cm = new MySqlCommand("select admin_name,admin_ID from administrator", con);
111 MySqlDataReader dr = cm.ExecuteReader();
115 this.lbxAdministrator.DataSource = dr; //lbxEmp为ListBox对象
117 this.lbxadministrator.DataTextField = "admin_name";
119 this.lbxadministrator.DataValueField = "admin_ID";
121 this.lbxadministrator.DataBind();
129 private void cBoxTables_SelectedIndexChanged(object sender, EventArgs e)
136 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
139 cmd.CommandText = "select * from administrator where admin_ID='" + comboBox1_doctorID.Text + "';";
140 cmd.ExecuteNonQuery();
144 textBox9_doctorname.Text = ds.Tables[0].Rows[0].ItemArray[1].ToString();
145 textBox5_doctordepartment.Text = ds.Tables[0].Rows[0].ItemArray[4].ToString();
146 textBox7_doctorfee.Text = ds.Tables[0].Rows[0].ItemArray[5].ToString();
147 textBox6_doctorcapability.Text = ds.Tables[0].Rows[0].ItemArray[3].ToString();
152 private void button2_Click(object sender, EventArgs e)
154 cmd.CommandText = "update registration set patient_name = '" + textBox_name.Text
155 + "',patient_sex = '" + textBox_patientsex.Text
156 + "',patient_insurance = '" + textBox_patient_insurance.Text
157 + "',doctor_ID = '" + comboBox1_doctorID.Text
158 + "',patient_address = '" + textBox4_patientaddress.Text
159 + "',patient_fee = '" + textBox_patient_fee.Text
160 + "' where registration_count = " + textBox1.Text;
162 cmd.ExecuteNonQuery();
167 private void button3_Click(object sender, EventArgs e)
170 cmd.CommandText = "select * from registration where registration_count ='" + textBox1.Text + "';";
171 cmd.ExecuteNonQuery();
174 textBox_name.Text = ds.Tables[0].Rows[0].ItemArray[11].ToString();
175 textBox_patient_insurance.Text = ds.Tables[0].Rows[0].ItemArray[12].ToString();
176 textBox_patientsex.Text = ds.Tables[0].Rows[0].ItemArray[13].ToString();
177 textBox4_patientaddress.Text = ds.Tables[0].Rows[0].ItemArray[15].ToString();
178 textBox_patient_fee.Text = ds.Tables[0].Rows[0].ItemArray[16].ToString();
179 comboBox1_doctorID.Text = ds.Tables[0].Rows[0].ItemArray[17].ToString();
184 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)