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) { zhanghao = Login.Text; mima = Password.Text; bool pzhanhao = false; DataTable dt = new DataTable(); dt = OperateDatabase.QueryData("select * from Zhaohao", constr); for (int i = 0; i < dt.Rows.Count; i++) { if (zhanghao.Trim().Equals(dt.Rows[i][0].ToString().Trim())) { pzhanhao = true; if (mima.Trim().Equals(dt.Rows[i][1].ToString().Trim())) { ID.setid(zhanghao); this.DialogResult = DialogResult.OK; } else { MessageBox.Show("密码错误!请重新输入"); } break; } } if (pzhanhao == false) { MessageBox.Show("账号不存在"); } }
private void initDeptDocList() { DataTable dt = new DataTable(); dt = OperateDatabase.QueryData("select * from Menzhenpaiban where Dno=" + doctorid, constr); if (dt.Rows.Count == 0) { MessageBox.Show("尚未找到该医生的排班信息,请您稍后进行预约!或换个医生"); paibantreeView.Nodes.Add("暂无排班信息!"); return; } for (int i = 0; i < dt.Rows.Count; i++) { string[] dateInfo = dt.Rows[i][2].ToString().Split(' '); //日期和时间分离 if (dt.Rows[i][3].Equals(true)) //判断上午还是下午 { paibantreeView.Nodes.Add(dateInfo[0] + " " + changeweek(dt.Rows[i][2]) + " 下午"); DataTable dt1 = new DataTable(); //子节点(号源表) int flag = 0; //标记 dt1 = OperateDatabase.QueryData("select * from Hyc where Dno=" + doctorid, constr); for (int j = 0; j < dt1.Rows.Count; j++) { if (dt1.Rows[j][2].Equals(dt.Rows[i][2]) && dt1.Rows[j][3].Equals(true)) { paibantreeView.Nodes[i].Nodes.Add("剩余号源数:" + dt1.Rows[j][5]); flag = 1; } } if (flag == 0) { paibantreeView.Nodes[i].Nodes.Add("数据库错误!!此医生已排班但无号源!"); } } else { paibantreeView.Nodes.Add(dateInfo[0] + " " + changeweek(dt.Rows[i][2]) + " 上午"); DataTable dt1 = new DataTable(); //子节点(号源表) int flag = 0; //标记 dt1 = OperateDatabase.QueryData("select * from Hyc where Dno=" + doctorid, constr); for (int j = 0; j < dt1.Rows.Count; j++) { if (dt1.Rows[j][2].Equals(dt.Rows[i][2]) && dt1.Rows[j][3].Equals(false)) { paibantreeView.Nodes[i].Nodes.Add("剩余号源数:" + dt1.Rows[j][5]); flag = 1; } } if (flag == 0) { paibantreeView.Nodes[i].Nodes.Add("数据库错误!!此医生已排班但无号源!"); } } } }
private void selectks_Load()//科室表处理 { DataTable dt = new DataTable(); dt = OperateDatabase.QueryData("select * from Ks", constr); comboBox1.DataSource = dt; comboBox1.DisplayMember = "Kname"; comboBox1.ValueMember = "Kno"; departmentid = comboBox1.SelectedValue.ToString(); this.comboBox1.SelectedIndex = -1;//初始状态内容为空 }
private void selectdoc_Load()//医生信息表处理 { DataTable dt = new DataTable(); dt = OperateDatabase.QueryData("select * from Dc where Kno=" + departmentid, constr); comboBox2.DataSource = dt; comboBox2.DisplayMember = "Dname"; comboBox2.ValueMember = "Dno"; this.comboBox2.SelectedIndex = -1;//初始状态内容为空 try { departmentid = comboBox1.SelectedValue.ToString(); } catch (Exception ex) { } }
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("预约成功"); } } }
private void main_Load(object sender, EventArgs e) { bool panduan = false; if (id.Length < 4) { DataTable dt1 = new DataTable(); dt1 = OperateDatabase.QueryData("select Dname from Dc where Dno='" + id + "'", constr); label1.Text = dt1.Rows[0][0].ToString().Trim() + "医生!!欢迎您!!"; DataTable dt3 = new DataTable(); dt3 = OperateDatabase.QueryData("select Pid from Manger", constr); for (int i = 0; i < dt3.Rows.Count; i++) { if (dt3.Rows[i][0].ToString().Trim().Equals(id)) { button1.Visible = true; button2.Visible = true; button3.Visible = true; button4.Visible = true; panduan = true; break; } } if (panduan == false) { button1.Visible = true; button2.Visible = true; button3.Visible = false; button4.Visible = false; } } if (id.Length > 4) { DataTable dt2 = new DataTable(); dt2 = OperateDatabase.QueryData("select Pname from Person where ID='" + id + "'", constr); label1.Text = dt2.Rows[0][0].ToString().Trim() + "!!欢迎您!!"; button1.Visible = true; button2.Visible = true; button3.Visible = false; button4.Visible = false; } }
private Boolean checkclash()//检验患者在一段时间内预约数量是否超限和检验一段时间内是否预约了同一个医生false通过,true不通过 { DataTable dt = new DataTable(); string[] str = selectdate.ToString().Split(' '); string date1;//日期格式转化 Boolean ap; date1 = str[0] + " " + "0:00:00"; if (str[2].Equals("上午")) { ap = false; } else { ap = true; } dt = OperateDatabase.QueryData("select * from Yc where ID=" + patientid, constr); int j = 0; for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i][3].Equals(ap) && dt.Rows[i][2].ToString().Equals(date1)) // { j++; if (dt.Rows[i][1].Equals(doctorid)) { return(true);//检验一段时间内是否预约了同一个医生 } } } if (j >= max) { return(true); } else { return(false); } }