private void buttonNew_Click(object sender, EventArgs e) { int paSexInt = 1; if (paSex.Text == "男") { paSexInt = 1; } else { paSexInt = 2; } if (paID.Text == "") { MessageBox.Show("不允许证件号为空"); } else { string cardNumber = System.DateTime.Now.ToString("yyyyMMddHHmmss") + paID.Text.Substring(paID.Text.Length - 4); cardNum.Text = cardNumber; string query = "INSERT INTO `patient` (`CardNum`, `paName`, `paSex`, `paBorth`, `paIDType`, `paID`, `paAge`, `paPhone`, `paAddress`, `paAllergy`) VALUES ('" + cardNum.Text + "', '" + paName.Text + "', '" + paSexInt + "', '" + paBorth.Value.ToString() + "', '" + paIDType.SelectedIndex + "', '" + paID.Text + "', '" + paAge.Text + "', '" + paPhone.Text + "', '" + paAddress.Text + "', '" + paAllergy.Text + "')"; bool addResult = sql.addDate(query); if (addResult == true) { buttonChange.Enabled = true; buttonChange.Visible = true; buttonNew.Enabled = false; buttonNew.Visible = false; buttonSearch.Enabled = true; buttonSearch.Visible = true; MessageBox.Show("新建诊疗卡成功"); } else { MessageBox.Show("出现错误"); } } }
private void button1_Click(object sender, EventArgs e) { /* * * string name = textBox1.Text; * string passwd = textBox2.Text; * * * string md5Passwd = md5_passwd(passwd); * * string query = "INSERT INTO `his`.`user` (`name`, `passwd`) VALUES ('" + name + "', '" + md5Passwd + "');"; * bool sighResult = mysql.addDate(query); * if (sighResult == true) * { * MessageBox.Show("注册成功"); * } * */ if (textBox2.Text == "") { MessageBox.Show("请填写姓名"); } else if (textBox3.Text == "") { MessageBox.Show("请填写性别"); } else if (textBox5.Text == "") { MessageBox.Show("请填写联系方式"); } else if (textBox6.Text != textBox4.Text) { MessageBox.Show("两次输入的密码不一致"); } else if (comboBox1.SelectedIndex == -1) { MessageBox.Show("请选择职位类别"); } else if (comboBox1.SelectedIndex == 1) { MessageBox.Show("暂不支持医生注册"); } else { string type = (comboBox1.SelectedIndex + 1).ToString(); md5 jiami = new md5(); string hadjiami = jiami.md5_passwd(textBox4.Text); string query = " SELECT COUNT(*) FROM user WHERE type='" + type + "'"; mySql sql = new mySql(); int num = sql.count(query) + 1; string gonghao = "0" + type + num.ToString(); query = "INSERT INTO user (`name`, `passwd`,`realname`,`sex`,`type`,`date`,`phone`) VALUES ('" + gonghao + "', '" + hadjiami + "','" + textBox2.Text + "','" + textBox3.Text + "','" + type + "','" + dateTimePicker1.Value.Date.ToString() + "','" + textBox5.Text + "');"; bool result = sql.addDate(query); if (result) { MessageBox.Show("注册成功,您的工号是" + gonghao); textBox2.Text = textBox3.Text = textBox4.Text = textBox5.Text = textBox6.Text = ""; } else { MessageBox.Show("注册失败,请重试"); } } }