private void button1_Click(object sender, EventArgs e) { name = textBox1.Text.ToString().Trim(); tel = textBox2.Text.ToString().Trim(); zhanghao = textBox3.Text.ToString().Trim(); password = textBox4.Text.ToString().Trim(); DataTable dt = new DataTable(); dt = OperateDatabase.QueryData("select* from Zhaohao where ID='" + zhanghao + "'", constr); if (dt.Rows.Count > 0) { MessageBox.Show("账号已存在!"); return; } Boolean flag = OperateDatabase.AddData("insert into Zhaohao(ID,Passwords)values('" + zhanghao + "','" + password + "')", constr); if (flag == true) { Boolean boo = OperateDatabase.AddData("insert into Person (ID,Pname,Tel,idex) values('" + zhanghao + "','" + name + "','" + tel + "',0)", constr); MessageBox.Show("注册成功,请重新登录"); } else { MessageBox.Show("数据库插入失败,注册失败,请重试"); } this.Close(); }
private void button1_Click(object sender, EventArgs e) { if (isdateselect == 0) { MessageBox.Show("请先选择日期"); return; } if (checkclash() == true) { MessageBox.Show("单位时间内预约数量超过上限或单位时间内预约多次同一个医生!请重试"); label4.Text = "请重新选择预约时间或医生"; return; } else { DataTable dt = new DataTable(); dt = OperateDatabase.QueryData("select *from Person where ID=" + patientid, constr); string[] str = selectdate.ToString().Split(' '); string date1;//日期格式转化 int ap; date1 = str[0] + " " + "0:00:00"; if (str[2].Equals("上午")) { ap = 0; } else { ap = 1; } DataTable dt1 = new DataTable(); dt1 = OperateDatabase.QueryData("select * from Hyc where Dno = '" + doctorid + "'and Mtime = '" + date1 + "'and flag = '" + ap + "'", constr); if (dt1.Rows.Count == 0) { MessageBox.Show("由于排班系统错误,该医生此排班无号源!"); return; } int xvhao = Convert.ToInt32(dt1.Rows[0][4]) - Convert.ToInt32(dt1.Rows[0][5]) + 1;//获取医生顺序号 string sqlstr = "insert into Yc([ID],[Dno],[Ytime],[flag],[xuhao],[Tel])values('" + patientid + "','" + doctorid + "','" + date1 + "','" + ap + "','" + xvhao + "','" + dt.Rows[0][2].ToString() + "')"; if (OperateDatabase.AddData(sqlstr, constr) == true) { OperateDatabase.UpdateData("update Hyc set Keyuyueshu='" + (Convert.ToInt32(dt1.Rows[0][5]) - 1).ToString() + "' where Dno='" + doctorid + "'and Mtime='" + date1 + "'and flag='" + ap + "'", constr); label4.Text = "预约成功"; MessageBox.Show("预约成功"); } } }