private void bt_save_Click_1(object sender, EventArgs e) { Model.Drug drug = new Model.Drug(); string msg = ""; for (int i = 0; i < this.dataGridView1.Rows.Count - 1; i++) { drug.Drug_ab = dataGridView1.Rows[i].Cells["简码"].Value.ToString(); drug.Drug_name = dataGridView1.Rows[i].Cells["药物"].Value.ToString(); drug.Effect = dataGridView1.Rows[i].Cells["功效"].Value.ToString(); drug.From_where = dataGridView1.Rows[i].Cells["产地"].Value.ToString(); drug.In_price = Double.Parse(dataGridView1.Rows[i].Cells["进价"].Value.ToString()); drug.Notice = dataGridView1.Rows[i].Cells["注意"].Value.ToString(); drug.Stock = Double.Parse(dataGridView1.Rows[i].Cells["数量"].Value.ToString()); drug.Unit = dataGridView1.Rows[i].Cells["单位"].Value.ToString(); drug.Unit_price = Double.Parse(dataGridView1.Rows[i].Cells["单价"].Value.ToString()); drug.Use_down = Double.Parse(dataGridView1.Rows[i].Cells["上限"].Value.ToString()); drug.Use_up = Double.Parse(dataGridView1.Rows[i].Cells["下限"].Value.ToString()); drug.Wei_jin = dataGridView1.Rows[i].Cells["味经"].Value.ToString(); if (!drugbll.AddDrug(drug, out msg)) { MessageBoxBuilder.buildErrbox("插入第" + i + "出错!" + msg); } } MessageBoxBuilder.buildbox("插入成功!", "ok"); }
private void btn_delete_Click_1(object sender, EventArgs e) { string msg = ""; if (drugBLL.DeleteById(drug_id, out msg)) { MessageBoxBuilder.buildbox(msg, "ok"); } else { MessageBoxBuilder.buildErrbox(msg); } }
private void bt_delete_Click(object sender, EventArgs e) { string msg = ""; if (empTabBLL.DeleteEmp(text_name.Text.Trim(), out msg)) { MessageBoxBuilder.buildbox(msg, "ok"); } else { MessageBoxBuilder.buildErrbox(msg); } }
private void login_btn_Click(object sender, EventArgs e) { string username = this.userName_txb.Text.Trim(); string passwd = this.passwd_txb.Text.Trim(); BLL.UserBLL instance = BLL.UserBLL.GetUserBLL(); string msg = ""; if (instance.Login(username, passwd, out msg)) //通过调用UserBLL的Login方法检测用户名密码是否正确 { if (remenber_ckb.Checked) //若成功登陆,则检测是否勾选记住密码 { //勾选则将用户名密码保存到user.xml文件中,该文件为xml文件 if (!XmlRW.GetXmlRW().UpdateXML(@"user.xml", "1", username, passwd)) { MessageBoxBuilder.buildbox("保存失败!", "错误!"); } } else { XmlRW.GetXmlRW().UpdateXML(@"user.xml", "0", "", "");//没有勾选则将上次保存记录删除 } UserHelper.userName = username; UserHelper.password = passwd; //将用户名密码保存为static全局变量,让其能在程序任意地方调用 UserHelper.id = BLL.UserBLL.GetUserBLL().GetIdByName(username); this.Hide(); MainUI r = new MainUI(); //将界面切换至主界面 r.Show(); } //检测失败则给用户显示错误信息 else if (!"".Equals(msg)) { MessageBoxBuilder.buildbox(msg, "错误!"); this.userName_txb.Text = ""; this.passwd_txb.Text = ""; this.userName_txb.Focus(); } else { MessageBoxBuilder.buildbox("登录失败!", "错误!"); this.userName_txb.Text = ""; this.passwd_txb.Text = ""; this.userName_txb.Focus(); } }
private void bt_alter_Click(object sender, EventArgs e) { Clear(); Model.EmpTab empTab = new Model.EmpTab(); empTab.Em_name = this.text_name.Text; empTab.Effect = this.text_method.Text; empTab.Fangjie = this.text_function.Text; empTab.From_where = this.text_from.Text; empTab.Cure = this.text_cure.Text; empTab.Em_ab = this.text_code.Text; empTab.Minus_and_add = "无"; empTab.Apply = "无"; if (empTabBLL.UpdateEmpTab(empTab)) { MessageBoxBuilder.buildbox("更新成功!", "ok"); } Fill(); }
string backupPath = ""; //备份路径 private void btn_export_Click(object sender, EventArgs e) { string msg = ""; DataTable t = drugBLL.GetAllDrug(); sfdlgBackup.FilterIndex = 1; sfdlgBackup.FileName = ""; sfdlgBackup.Filter = "Bak Files (*,xls)|*.xls"; if (sfdlgBackup.ShowDialog() == DialogResult.OK) { backupPath = sfdlgBackup.FileName.ToString(); } if (!"".Equals(backupPath)) { Common.Util.ExportXLS(backupPath, t, out msg); } MessageBoxBuilder.buildbox(msg, " "); }
private void register_btn_Click(object sender, EventArgs e) { string passwd1 = this.passwd_txb_1.Text.Trim(); string passwd2 = this.passwd_txb_2.Text.Trim(); //若两次输入的密码不一致则打回去重做,并弹出对话框提示用户错误信息 if (passwd1 == "" || passwd1 == "") { MessageBoxBuilder.buildErrbox("密码为空!!"); return; } else if (!passwd1.Equals(passwd2)) { MessageBoxBuilder.buildErrbox("两次输入密码不同!"); return; } //通过Model包下的user雨userdata将用户登录信息跟用户信息传给BLL层 Model.User user = new Model.User(); Model.UserData userdata = new Model.UserData(); user.UserName = this.name_txb.Text.Trim(); user.Password = passwd1; userdata.Username = this.name_txb.Text.Trim(); userdata.Department = this.kebie_txb.Text.Trim(); userdata.Address = this.address_txb.Text.Trim(); userdata.Idcard = this.idcard_txb.Text.Trim(); userdata.Gender = this.gender_cb.Text.Trim(); string msg = ""; BLL.UserBLL userBLL = BLL.UserBLL.GetUserBLL(); if (userBLL.Register(user, userdata, out msg)) //userBLL将user跟userdata插入到数据库 { MessageBoxBuilder.buildbox("注册成功!", "ok"); //成功则弹出对话框提示用户注册成功 } //若用户传入的信息不合格,或者再插入数据的时候出现了异常,则弹出对话框提示用户出错信息 else if (!"".Equals(msg)) { MessageBoxBuilder.buildErrbox(msg); } else { MessageBoxBuilder.buildErrbox("注册失败!"); } }
private void ParseEmpTab() { Model.EmpTab empTab = new Model.EmpTab(); empTab.Em_name = this.text_name.Text; empTab.Effect = this.text_method.Text; empTab.Fangjie = this.text_function.Text; empTab.From_where = this.text_from.Text; empTab.Cure = this.text_cure.Text; empTab.Em_ab = this.text_code.Text; empTab.Minus_and_add = "无"; empTab.Apply = "无"; string msg = ""; if (empTabBLL.AddEmpTab(empTab, out msg)) { MessageBoxBuilder.buildbox("更新成功!", "ok"); } this.bt_confirm.Text = "增加"; Fill(); }
private void btnRestore_Click_1(object sender, EventArgs e) { if (restorePath == "") { MessageBoxBuilder.buildbox("请先选择数据库恢复路径", "提示"); return; } try { this.Cursor = Cursors.WaitCursor; bll.RestoreDb(restorePath); MessageBoxBuilder.buildbox("数据库恢复成功", "提示"); } catch (Exception ex) { MessageBoxBuilder.buildErrbox(ex.Message); } finally { this.Cursor = Cursors.Arrow; } }
private void btnBackup_Click(object sender, EventArgs e) { if (backupPath == "") { MessageBoxBuilder.buildbox("请先选择数据库备份路径", "提示"); return; } try { this.Cursor = Cursors.WaitCursor; bll.BackDb(backupPath); MessageBoxBuilder.buildbox("数据库备份成功", "提示"); } catch (Exception ex) { MessageBoxBuilder.buildErrbox(ex.Message); } finally { this.Cursor = Cursors.Arrow; } }
private void save_btn_Click(object sender, EventArgs e) { if (FileName != null && !"".Equals(FileName)) { if ((pb_patient.Image != null)) { pb_patient.Image.Dispose(); pb_patient.Image = null; } byte[] b = Common.Util.GetImageByte(FileName); if (BLL.PatientBLL.GetPatientBLL().UpdatePatientPhoto(pid, b)) { MessageBoxBuilder.buildbox("上传成功!", "ok"); Fill(); ShowPhoto(); } else { MessageBoxBuilder.buildErrbox("上传失败!"); } } }
private void ok_btn_Click(object sender, EventArgs e) { string pass1 = pass1_txb.Text.Trim(); string pass2 = pass2_txb.Text.Trim(); //两次密码输入不一致则提醒用户说明不一致 if (pass1 == "" || pass2 == "") { MessageBoxBuilder.buildErrbox("密码为空!!"); return; } else if (!pass1.Equals(pass2)) { MessageBoxBuilder.buildErrbox("两次输入密码不同!"); return; } //将用户输入的信息封装成model类传给BLL层 string name = name_txb.Text.Trim(); Model.UserData data = new Model.UserData(); data.Username = name; data.Idcard = idcard_txb.Text.Trim(); string msg = ""; //重置成功后返回信息提醒用户重置情况 if (BLL.UserBLL.GetUserBLL().FindPassWord(data, pass1, out msg)) { MessageBoxBuilder.buildbox("重置成功!!", "成功"); } else if (!"".Equals(msg)) { MessageBoxBuilder.buildErrbox(msg); } else { MessageBoxBuilder.buildErrbox("找回失败!未知错误!"); } }
private void baocun_btn_Click(object sender, EventArgs e) { //将输入的信息封装成类对象,传入bll层 Model.Patient patient = new Model.Patient(); Model.Patient_Tab patient_tab = new Model.Patient_Tab(); patient.P_name = tb_pname.Text.Trim(); //年龄信息出错,提醒用户 try { patient.Old = Convert.ToInt16(tb_old.Text.Trim()); } catch (Exception exp) { MessageBoxBuilder.buildbox((exp.Message), "错误!"); return; } patient.Tel = tb_tel.Text.Trim(); patient.Idcard = tb_idcard.Text.Trim(); patient.D_ID = UserHelper.id; //用与得到用户转入的病人照片信息 if (FileName != null && !"".Equals(FileName)) { if ((pictureBox1.Image != null)) { pictureBox1.Image.Dispose(); pictureBox1.Image = null; } patient.Thumb = Common.Util.GetImageByte(FileName); } if (rb_man.Checked) { patient.Gender = "男"; } else if (rb_woman.Checked) { patient.Gender = "女"; } else { patient.Gender = "不详"; } patient_tab.Chufang_count = Convert.ToInt32(tb_jishu.Text.Trim()); patient_tab.Xianbingshi = tb_bingshi.Text.Trim(); patient_tab.Zhengduan = tb_zhenduan.Text.Trim(); string msg = ""; //添加处方信息与病人信息 if (patientInstance.AddPatient(patient, patient_tab, out msg)) { MessageBoxBuilder.buildbox("保存成功!", "ok"); ShowPhoto(); } else if (!"".Equals(msg)) { MessageBoxBuilder.buildbox(msg, "错误"); } else { MessageBoxBuilder.buildbox("未知错误!插入失败!", "错误"); } }