private void 除ToolStripButton_Click(object sender, EventArgs e) { int rowAffected = 0; if (tb_id.Text != "" && tb_name.Text != "") { try { rowAffected = mysql.getcom("DELETE FROM tb_dept WHERE NO='" + tb_id.Text.Trim() + "';"); } catch (SqlException sqlEx) { MessageBox.Show("数据库异常:" + sqlEx.Message, "数据库异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (rowAffected == 1) { MessageBox.Show("删除科室成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None); } else { MessageBox.Show("删除科室失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None); } } else { MessageBox.Show("请选择要删除的科室!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } this.setFalse(); this.init(); }
private void btn_pay_Click(object sender, EventArgs e) { int rowAffected = 0; if (Convert.ToDouble(tb_total.Text.Trim()) <= Convert.ToDouble(tb_balance.Text.Trim())) { //账户余额充足 try { rowAffected = mysql.getcom("UPDATE tb_expensesRecord SET havePaid=1 " + ",payDate='" + dtp_paydate.Value.ToString() + "'" + " WHERE ticketNo='" + tb_ticketNo.Text.Trim() + "';"); rowAffected += mysql.getcom("UPDATE tb_card SET balance=" + (Convert.ToDouble(tb_balance.Text.Trim()) - Convert.ToDouble(tb_total.Text.Trim())) + " WHERE patientNo='" + tb_patientNo.Text.Trim() + "';"); } catch (SqlException sqlEx) { MessageBox.Show("数据库异常:" + sqlEx.Message, "数据库异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (rowAffected == 2) { MessageBox.Show("付款成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None); } else { MessageBox.Show("付款失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else //账户余额不足 { if (Convert.ToDouble(tb_balance.Text.Trim()) + Convert.ToDouble(tb_creditLimit.Text.Trim()) >= Convert.ToDouble(tb_total.Text.Trim())) { //余额加上信用额度足够支付 try { rowAffected = mysql.getcom("UPDATE tb_expensesRecord SET havePaid=1 " + ",payDate='" + dtp_paydate.Value.ToString() + "'" + " WHERE ticketNo='" + tb_ticketNo.Text.Trim() + "';"); rowAffected += mysql.getcom("UPDATE tb_card SET balance=" + (Convert.ToDouble(tb_balance.Text.Trim()) - Convert.ToDouble(tb_total.Text.Trim())) + " WHERE patientNo='" + tb_patientNo.Text.Trim() + "';"); } catch (SqlException sqlEx) { MessageBox.Show("数据库异常:" + sqlEx.Message, "数据库异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (rowAffected == 2) { MessageBox.Show("信用额度付款成功,已欠费 " + (Convert.ToDouble(tb_total.Text.Trim()) - Convert.ToDouble(tb_balance.Text.Trim())) + " 元,请及时补交欠费款!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None); } else { MessageBox.Show("付款失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { //余额加上信用额度任然不够支付 MessageBox.Show("余额不足,请先进行充值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } this.init(); }
private void btn_rebuild_Click(object sender, EventArgs e) { if (tb_password.Text == userHelper.operatorPsw) { //清空业务数据 if (ckb_clearBusiness.Checked) { rowAffected = 0; try { rowAffected = mysql.getcom("DELETE FROM dbo.tb_expensesRecord; DELETE FROM dbo.tb_registration; " + "DELETE FROM dbo.tb_docScore; DELETE FROM dbo.tb_receipt;"); } catch (SqlException sqlEx) { MessageBox.Show("数据库异常:" + sqlEx.Message, "数据库异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (rowAffected >= 1) { MessageBox.Show("清空业务数据成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("清空业务数据失败!请稍后重试或联系信息科", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } //清空基础资料 if (ckb_clearBasic.Checked) { rowAffected = 0; try { rowAffected = mysql.getcom("DELETE FROM dbo.tb_patient; DELETE FROM dbo.tb_card; DELETE FROM dbo.tb_dept; " + "DELETE FROM dbo.tb_doctor; DELETE FROM dbo.tb_regType;"); } catch (SqlException sqlEx) { MessageBox.Show("数据库异常:" + sqlEx.Message, "数据库异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (rowAffected >= 1) { MessageBox.Show("清空基础资料成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("清空基础资料失败!请稍后重试或联系信息科", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { MessageBox.Show("用户密码错误,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tb_password.Focus(); tb_password.SelectAll(); } }
private void btn_pay_Click(object sender, EventArgs e) { int rowAffected = 0; if (nud_pay.Value != 0) { try { rowAffected = mysql.getcom("UPDATE tb_card SET balance=" + (Convert.ToSingle(nud_pay.Value) + Convert.ToSingle(tb_balance.Text.Trim())) + " WHERE patientNo='" + tb_patientno.Text.Trim() + "';"); } catch (SqlException sqlEx) { MessageBox.Show("数据库异常:" + sqlEx.Message, "数据库异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (rowAffected == 1) { MessageBox.Show("还款成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None); nud_pay.Value = 0; } else { MessageBox.Show("还款失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("本次还款额不能为0!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); nud_pay.Focus(); } this.init(); }
private void btn_ok_Click(object sender, EventArgs e) { if (tb_oldPsw.Text == "") { MessageBox.Show("原密码不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_oldPsw.Focus(); } else { if (tb_oldPsw.Text.Trim() != userHelper.operatorPsw) { MessageBox.Show("旧密码输入错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_oldPsw.Focus(); tb_oldPsw.SelectAll(); } else { if (tb_newPsw.Text == "") { MessageBox.Show("新密码不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_newPsw.Focus(); } else { if (tb_confirmPsw.Text == "") { MessageBox.Show("请再次输入新密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_confirmPsw.Focus(); } else { if (tb_newPsw.Text != tb_confirmPsw.Text) { MessageBox.Show("两次输入的新密码不一致!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { int rowAffected = 0; try { rowAffected = mysql.getcom("UPDATE tb_operator SET password=HASHBYTES('SHA','" + tb_newPsw.Text.Trim() + "') WHERE No='" + tb_no.Text.Trim() + "';"); } catch (SqlException sqlEx) { MessageBox.Show("数据库异常:" + sqlEx.Message, "数据库异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (rowAffected == 1) { MessageBox.Show("密码修改成功,请重新登录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None); Application.Restart(); } } } } } } }
private void btn_addappointment_Click(object sender, EventArgs e) { if (tb_name.Text == "") { MessageBox.Show("请选择预约病人!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (cmb_docname.Text == "") { MessageBox.Show("请选择预约医生!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (cmb_dept.Text == "") { MessageBox.Show("请选择预约科室!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { int rowAffected = 0; try { rowAffected = mysql.getcom("INSERT tb_registration ( patientNo , deptNo , docNo , regDate ,regTime ,operater ) SELECT '" + tb_patientNo.Text.Trim() + "',d2.NO,d1.No,'" + dtp_regDate.Value.ToShortDateString() + "','" + dtp_regTime.Value.ToShortTimeString() + "','" + userHelper.operatorNo + "' FROM tb_doctor d1 JOIN tb_dept d2 ON d1.deptNo = d2.NO WHERE d1.NAME='" + cmb_docname.SelectedItem.ToString() + "' AND d2.NAME='" + cmb_dept.SelectedItem.ToString() + "';"); } catch (SqlException sqlEx) { MessageBox.Show("数据库异常:" + sqlEx.Message, "数据库异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (rowAffected == 1) { MessageBox.Show("添加预约成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None); this.gridviewinit(); } else { MessageBox.Show("添加预约失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } }
private void btn_recharge_Click(object sender, EventArgs e) { int rowAffected = 0; if (rdo_cash.Checked) { try { rowAffected = mysql.getcom("UPDATE tb_card SET balance=" + (Convert.ToSingle(nud_money.Value) + Convert.ToSingle(tb_balance.Text.Trim())) + " WHERE patientNo='" + tb_patientno.Text.Trim() + "';"); } catch (SqlException sqlEx) { MessageBox.Show("数据库异常:" + sqlEx.Message, "数据库异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (rowAffected == 1) { MessageBox.Show("充值成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None); nud_money.Value = 0; //刷新页面? } else { MessageBox.Show("充值失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("充值金额不能为0!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); nud_money.Focus(); } if (rdo_creditCard.Checked) //待添加 { } if (rdo_alipay.Checked) { } if (rdo_wechat.Checked) { } }
private void btn_addpatient_Click(object sender, EventArgs e) { if (btn_addpatient.Text == "添加病人") { this.initAdd(); } else { if (tb_name.Text == "") { MessageBox.Show("请输入病人的姓名!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_name.Focus(); } else { if (tb_cellphone.Text == "") { MessageBox.Show("请输入病人的联系电话!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_cellphone.Focus(); } else { if (tb_patientNo.Text == "") { MessageBox.Show("患者编号不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (cmb_cardtype.SelectedIndex == 0 && tb_cardNo.Text == "") { MessageBox.Show("请输入病人的就诊卡号!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_cardNo.Focus(); } else { if (cmb_cardtype.SelectedIndex == 1 && tb_id.Text == "") { MessageBox.Show("请输入病人的身份证号码!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_id.Focus(); } else { int rowAffected = 0; try { rowAffected = mysql.getcom("INSERT tb_patient" + "(No,Name,age,sex,id,visitNo,birthday,nationality,nation,email,tel,Address,firstman1,firstmantel1,firstman2,firstmantel2,regDate,allergyHistory,operationHistory)" + "VALUES('" + tb_patientNo.Text.Trim() + "','" + tb_name.Text.Trim() + "'," + tb_age.Text.Trim() + "," + cmb_sex.SelectedIndex + ",'" + tb_id.Text.Trim() + "','" + tb_cardNo.Text.Trim() + "','" + dtp_birthday.Value.ToShortDateString() + "','" + tb_nationality.Text.Trim() + "','" + tb_nation.Text.Trim() + "','" + tb_email.Text.Trim() + "','" + tb_cellphone.Text.Trim() + "','" + tb_address.Text.Trim() + "','" + tb_firstman1.Text.Trim() + "','" + tb_firstphone1.Text.Trim() + "','" + tb_firstman2.Text.Trim() + "','" + tb_firstphone2.Text.Trim() + "','" + dtp_recdate.Value.ToShortDateString() + "','" + tb_hispass.Text.Trim() + "','" + tb_operate.Text.Trim() + "')"); } catch (SqlException sqlEx) { MessageBox.Show("数据库异常:" + sqlEx.Message, "数据库异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (rowAffected == 1) { MessageBox.Show("添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None); this.setFalse(); btn_appointment.Enabled = true; btn_regno.Enabled = true; btn_modifypatient.Enabled = true; btn_addpatient.Text = "添加病人"; } else { MessageBox.Show("添加失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } } } } }