// 扫描达安条码 插入订单 private void txtDaanBarcode_KeyPress(object sender, KeyPressEventArgs e) { //是否回车键 if (e.KeyChar != (char)Keys.Enter) { return; } string barcode = this.txtDaanBarcode.Text.Trim(); this.txtDaanBarcode.Text = string.Empty; if (barcode == "") { ShowMessageHelper.ShowBoxMsg("达安条码不能为空!"); return; } Regex r = new Regex(@"^\d*00$|\:"); //正则12位数字尾数必须为0 //达安条码为12位 if (barcode.Length != 12) { ShowMessageHelper.ShowBoxMsg("请核对达安条码为12位数字!"); return; } //达安条码为数字 if (!r.IsMatch(barcode)) { ShowMessageHelper.ShowBoxMsg("请核对达安条码后两位为0的12位数字!"); return; } if (gvLisrequest.RowCount == 0) { ShowMessageHelper.ShowBoxMsg("无医院相关信息!"); return; } BindingSource TestData = gvDaLis.DataSource as BindingSource; if (TestData.Count == 0) { ShowMessageHelper.ShowBoxMsg("没有项目,不能添加!"); return; } try { #region >>>> zhouy 添加过滤 //选中的当前行 VDaLisrequest vda = (VDaLisrequest)gvLisrequest.Rows[gvLisrequest.CurrentCell.RowIndex].DataBoundItem; //是否存在相同的达安条码 List <DAOutspecimen> daoutlist = outspecimenbll.GetOutspecimenList(new Hashtable() { { "txtRequestcode", barcode } }); if (daoutlist.Count > 0) { ShowMessageHelper.ShowBoxMsg("已存在相同的达安条码!"); return; } #endregion #region >>>插入订单主表、从表、结果表 //项目列表 取列表项目,可见见即可得 List <VDaLisrequesttest> VTestList = ((BindingCollection <VDaLisrequesttest>)TestData.List).ToList().FindAll(c => c.IsSelect); //项目是否匹配 if (VTestList.FindAll(c => c.Datestcode == "").Count != 0) { ShowMessageHelper.ShowBoxMsg("项目不匹配,数据添加失败!"); return; } SortedList SQLlist = new SortedList(new MySort()); #region >>>> zhouy 申请单 DAOutspecimen daoutspecimen = new DAOutspecimen(); int age = 0; if (vda.Age != null && vda.Age != "") { if (!int.TryParse(vda.Age, out age)) { ShowMessageHelper.ShowBoxMsg("年龄格式不对!"); return; } //如果年龄大于200岁 if (age > 200 && age < 0 && vda.Ageunit == "0") { ShowMessageHelper.ShowBoxMsg("年龄不能大于200岁!"); return; } } daoutspecimen.Age = age; daoutspecimen.Requestcode = barcode; daoutspecimen.Hospsampleid = vda.Hospsampleid; // if (chxHosNumer.Checked) { daoutspecimen.Hospsamplenumber = vda.Hospsamplenumber; // } daoutspecimen.Customercode = SystemConfig.Config.Username; daoutspecimen.Remark = ""; daoutspecimen.Patientnumber = vda.Patientnumber; daoutspecimen.Bednumber = vda.Bednumber; daoutspecimen.Samplingdate = vda.Samplingdate; daoutspecimen.Patientsource = vda.Patientnumber; daoutspecimen.Patientname = vda.Pname; daoutspecimen.Bodystyle = vda.Bodystyle; daoutspecimen.Sex = vda.Sex; daoutspecimen.Patienttel = vda.Patienttel; daoutspecimen.Location = vda.Sectionoffice; daoutspecimen.Doctor = vda.Doctor; daoutspecimen.Doctortel = vda.Doctortel; daoutspecimen.Birthday = vda.Birthday; daoutspecimen.Ageunit = vda.Ageunit; daoutspecimen.Diagnostication = vda.Diagnostication; daoutspecimen.Status = "0"; daoutspecimen.Babycount = vda.Babycount; daoutspecimen.Lmp = vda.Lmp; daoutspecimen.Lmpdate = vda.Lmpdate; daoutspecimen.Uninevolumn = vda.Uninevolumn.ToString(); daoutspecimen.Weight = vda.Weight.ToString(); daoutspecimen.Height = vda.Height.ToString(); daoutspecimen.Bultrasonic = vda.Bultrasonic; daoutspecimen.Pregnant = vda.Pregnant; daoutspecimen.Enterby = SystemConfig.UserInfo.UserCode; //"";//录单人 daoutspecimen.Enterbydate = DateTime.Now; daoutspecimen.Lastupdatedate1 = DateTime.Now; daoutspecimen.Createdate = DateTime.Now; daoutspecimen.Usertype = SystemConfig.UserInfo.UserType.ToString(); #endregion //显示校验医院项目是否与达安项目匹配 List <string> strCoustomercode = new List <string>(); //客户项目代码 List <string> strCoustomername = new List <string>(); //客户项目名称 List <string> strDatecode = new List <string>(); //达安项目代码 List <string> strDatename = new List <string>(); //达安项目名称 //查询系统中 医院中的所有项目 Hashtable ht = new Hashtable(); ht.Add("Hospsampleid", daoutspecimen.Hospsampleid); List <DAResult> _daresult = new DAResultBLL().GetDAResultList(ht); //显示基本信息 foreach (VDaLisrequesttest vdl in VTestList) { string[] dacodearr = vdl.Datestcode.Split(','); #region >>>> 申请单项目表 for (int i = 0; i < dacodearr.Length; i++) { string dacode = dacodearr[i].Trim(); string daname = ""; IEnumerable <string> IEdaname = from a in DaTestList where a.Datestcode.Trim() == dacode select a.Datestname; if (IEdaname.Count() == 0) { //dacode = daname = ""; ShowMessageHelper.ShowBoxMsg(string.Format("达安项目中不存在编号为[{0}]的项目!", dacode)); return; } // else { daname = IEdaname.First(); } DAOutspecimentest daouttest = new DAOutspecimentest(); daouttest.Hospsampleid = vda.Hospsampleid; //if (chxHosNumer.Checked) { daouttest.Hospsamplenumber = vda.Hospsamplenumber; // } daouttest.Requestcode = barcode; daouttest.Customertestcode = vdl.Testcode; daouttest.Customertestname = vdl.Testname; daouttest.Datestcode = dacode; daouttest.Datestname = daname; daouttest.Createdate = DateTime.Now; SQLlist.Add(new Hashtable() { { "INSERT", "Da.InsertDAOutspecimentest" } }, daouttest); } #endregion //保存重复过的项目名称 string testnamelist = ""; #region >>>> 插入结果表 List <VDAListests> vdalisttest = new VDAListestsBLL().GetVDaListestsresultByCode(new Hashtable() { { "Testcode", vdl.Testcode } }); foreach (VDAListests item in vdalisttest) { DAResult daResult = new DAResult(); daResult.Requestcode = barcode; daResult.Hospsampleid = vda.Hospsampleid; //if (chxHosNumer.Checked) { daResult.Hospsamplenumber = vda.Hospsamplenumber; // } daResult.Testtype = item.Testtype; daResult.Customergroupcode = item.CustomerGroupCode; //医院组合代码 daResult.Customergroupname = item.CustomerGroupName; //医院组合名称 daResult.Customertestcode = item.Subtestcode; //医院单项代码 daResult.Customertestname = item.Subtestname; //医院单项名称 //不存在单项名 取组合名 if (item.Subtestcode == null || item.Subtestcode == "") { daResult.Customertestcode = item.CustomerGroupCode; //医院单项代码 daResult.Customertestname = item.CustomerGroupName; //医院单项名称 } //如果已经插入系统的项目 再次扫描不允许插入 if (_daresult.FindAll(c => c.Customertestcode.Trim() == daResult.Customertestcode.Trim()).Count > 0) { testnamelist += daResult.Customertestname + ","; continue; } daResult.Dagroupcode = string.Empty; daResult.Dagroupname = string.Empty; daResult.Datestcode = string.Empty; //达安单项代码 daResult.Datestname = string.Empty; //达安单项名称 SQLlist.Add(new Hashtable() { { "INSERT", "InsertDAResult" } }, daResult); } #endregion //同意医院条码有重复项目 if (testnamelist != "") { ShowMessageHelper.ShowBoxMsg( string.Format("送检人【{0}】医院条码[{1}]的项目[{2}]已经添加到系统中,分开条码请先删除已添加的项目,或者去掉勾选", daoutspecimen.Patientname, daoutspecimen.Hospsampleid, testnamelist.TrimEnd(','))); return; } daoutspecimen.Customertestcodes += vdl.Testcode + ","; daoutspecimen.Customertestnames += vdl.Testname + ","; daoutspecimen.Datestcodes += vdl.Datestcode + ","; daoutspecimen.Datestnames += vdl.Datestname + ","; } daoutspecimen.Customertestcodes = daoutspecimen.Customertestcodes.TrimEnd(','); daoutspecimen.Customertestnames = daoutspecimen.Customertestnames.TrimEnd(','); daoutspecimen.Datestcodes = daoutspecimen.Datestcodes.TrimEnd(','); daoutspecimen.Datestnames = daoutspecimen.Datestnames.TrimEnd(','); SQLlist.Add(new Hashtable() { { "INSERT", "Da.InsertDAOutspecimen" } }, daoutspecimen); #region >>>> 写操作日志 DAOperationlog daoperationlog = new DAOperationlog(); daoperationlog.Dictuserid = SystemConfig.UserInfo.UserId == "" ? 0 : Convert.ToDecimal(SystemConfig.UserInfo.UserId); daoperationlog.Usercode = SystemConfig.UserInfo.UserCode; daoperationlog.Username = SystemConfig.UserInfo.UserName; daoperationlog.Usertype = SystemConfig.UserInfo.UserType.ToString(); daoperationlog.Optype = "新增订单信息"; daoperationlog.Createdate = DateTime.Now; daoperationlog.Opcontent = "生成订单号:" + barcode; daoperationlog.Requestcode = barcode; daoperationlog.Hospsampleid = vda.Hospsampleid; // if (chxHosNumer.Checked) { daoperationlog.Hospsamplenumber = vda.Hospsamplenumber; // } SQLlist.Add(new Hashtable() { { "INSERT", "InsertDAOperationlog" } }, daoperationlog); #endregion string errmsg = ""; if (!outspecimenbll.ExecuteSqlTran(SQLlist, ref errmsg)) { ShowMessageHelper.ShowBoxMsg("添加失败!:" + errmsg); return; } DataBind(daoutspecimen); this.txtBarcode.Focus(); #endregion } catch (Exception Ex) { ShowMessageHelper.ShowBoxMsg("添加订单异常:" + Ex.Message); return; } }
/// <summary> /// 删除订单信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click(object sender, EventArgs e) { //当前GridView是否存在数据 if (dgvReport.Rows.Count == 0) { ShowMessageHelper.ShowBoxMsg("没有要删除的订单!"); return; } //已经选择的记录 记录数为0 则不往下执行 List <DAOutspecimen> SelectList = (bgSource.DataSource as BindingCollection <DAOutspecimen>).ToList <DAOutspecimen>().FindAll(c => c.IsSelect); if (SelectList.Count == 0) { ShowMessageHelper.ShowBoxMsg("没有选择要删除的数据!"); return; } if (MessageBox.Show("您确定要删除吗?", DefaultConfig.MSGTITLE, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } SortedList SQLlist = new SortedList(new MySort()); StringBuilder sb = new StringBuilder(); StringBuilder strb = new StringBuilder(); StringBuilder bacode = new StringBuilder(); for (int i = 0; i < SelectList.Count; i++) { //状态为已申请的可以删除,其它状态不能删除 (admin可以删除任何单据) if (SelectList[i].Status == "0" || (SystemConfig.UserInfo.UserCode == "admin")) { sb.Append(SelectList[i].Outspecimenid); //获取主键信息 sb.Append(","); strb.Append(SelectList[i].Requestcode); //获取达安条码信息 strb.Append(","); //插入节点信息表 DAOperationlog daoperationlog = new DAOperationlog(); daoperationlog.Dictuserid = SystemConfig.UserInfo.UserId == "" ? 0 : Convert.ToDecimal(SystemConfig.UserInfo.UserId); daoperationlog.Usercode = SystemConfig.UserInfo.UserCode; daoperationlog.Username = SystemConfig.UserInfo.UserName; daoperationlog.Usertype = SystemConfig.UserInfo.UserType.ToString(); daoperationlog.Optype = "删除订单信息"; daoperationlog.Createdate = DateTime.Now; daoperationlog.Opcontent = "删除订单号:" + SelectList[i].Requestcode.ToString(); daoperationlog.Requestcode = SelectList[i].Requestcode.ToString(); daoperationlog.Hospsampleid = SelectList[i].Hospsampleid.ToString(); daoperationlog.Hospsamplenumber = SelectList[i].Hospsamplenumber; SQLlist.Add(new Hashtable() { { "INSERT", "InsertDAOperationlog" } }, daoperationlog); } else { if (SelectList[i].Status != "0" && SystemConfig.UserInfo.UserCode == "admin") { } else { bacode.Append(SelectList[i].Requestcode); bacode.Append(","); } } } if (strb.ToString() == "") { ShowMessageHelper.ShowBoxMsg("没有需要删除的数据!"); return; } var library = new DAOutSpecimenBLL(); // SQLlist.Add(new Hashtable() { { "DELETE", "DeleteDAResult" } }, "'"+strb.ToString().TrimEnd(',').Replace(",","','")+"'"); // SQLlist.Add(new Hashtable() { { "DELETE", "DeleteDAOutspecimentest" } }, "'" + strb.ToString().TrimEnd(',').Replace(",", "','") + "'"); SQLlist.Add(new Hashtable() { { "DELETE", "DeleteDAResult" } }, strb.ToString().TrimEnd(',')); SQLlist.Add(new Hashtable() { { "DELETE", "DeleteDAOutspecimentest" } }, strb.ToString().TrimEnd(',')); SQLlist.Add(new Hashtable() { { "DELETE", "Da.DeleteDAOutspecimen" } }, sb.ToString().TrimEnd(',')); if (library.ExecuteSqlTran(SQLlist)) //删除3张表的订单相关信息 { if (strb.ToString() != "") { ShowMessageHelper.ShowBoxMsg(string.Format("{0}" + "条码成功删除", strb.ToString().TrimEnd(','))); } if (bacode.ToString() != "") { ShowMessageHelper.ShowBoxMsg(string.Format("{0}" + "条码不能删除", bacode.ToString().TrimEnd(','))); } HeaderCheckBox.Checked = false; DataBind(); } else { ShowMessageHelper.ShowBoxMsg("数据删除失败!"); HeaderCheckBox.Checked = false; DataBind(); } }