protected void btnDel_Click(object sender, EventArgs e) { try { Dicttestitem item = new Dicttestitem(); //List<Dicttestitem> testitemgoutpLst = BindTestGourp();//所有组合项目 if (ViewState["TestItemID"] != null) { double?id = Convert.ToDouble(ViewState["TestItemID"]); //item = (from Dicttestitem in testitemgoutpLst where Dicttestitem.Dicttestitemid == id select Dicttestitem).ToList<Dicttestitem>()[0]; item = testitemservice.SelectDicttestitemByDicttestitemid(id); } DicttestitemService service = new DicttestitemService(); bool b = service.DelDictGrouptestitemByID(item);//删除操作 if (b) { AddTestGroup();//清空 CacheHelper.RemoveAllCache("daan.GetDicttestitem"); BindSearchData(); MessageBoxShow("删除成功!"); } } catch (Exception ex) { MessageBoxShow(ex.Message); } }
///选择套餐添加 protected void DropItem_SelectedIndexChanged(object sender, EventArgs e) { if (DropItem.SelectedIndex == 0) { return; } ExtAspNet.ListItem li = DropItem.SelectedItem; CacheHelper.RemoveAllCache("daan.GetDictproductdetail"); List <Dictproductdetail> dictproduct = loginservice.GetLoginDictproductdetail(); List <Dictproductdetail> dictprodu = (from Dictproductdetail in dictproduct where (Dictproductdetail.Productid == Convert.ToDouble(li.Value)) select Dictproductdetail).ToList <Dictproductdetail>(); if (dictprodu.Count > 0) { for (int i = 0; i < dictprodu.Count; i++) { Dicttestitem dictestitem = new DicttestitemService().SelectDicttestitemByDicttestitemid(Convert.ToDouble(dictprodu[i].Testgroupid)); if (dictestitem != null) { if (dictestitem.Tubegroup == "" || dictestitem.Dictlabdeptid.ToString() == "" || dictestitem.Dictspecimentypeid.ToString() == "") { if (dictestitem.Tubegroup == "") { MessageBoxShow("" + dictestitem.Testname + "分管原则不能为空,请重新维护后再添加!"); return; } else if (dictestitem.Dictlabdeptid.ToString() == "") { MessageBoxShow("" + dictestitem.Testname + "所属科室不能为空,请重新维护后再添加!"); return; } else if (dictestitem.Dictspecimentypeid.ToString() == "") { MessageBoxShow("" + dictestitem.Testname + "标本类型不能为空,请重新维护后再添加!"); return; } } } } } string productname = ""; List <OrderRegister> _gridtestList = GetGridTest(false); string msg = registerserver.AddProduct(ref _gridtestList, DropSex.SelectedValue, Convert.ToDouble(li.Value), false, Userinfo, ref productname, null); if (msg != string.Empty) { MessageBoxShow(msg); return; } tbxItemTest.Text += productname + ","; BindGridTest(_gridtestList);//绑定数据 //DropItem.SelectedItem.Value = "-1"; }
private bool AutoUploadFile(DataTable dt, DataRow headerDr) { double?Orderfileheaderid = Convert.ToDouble(headerDr["Orderfileheaderid"]); double?enterby = Convert.ToDouble(headerDr["enterby"]); double?dictcustormer = Convert.ToDouble(headerDr["dictcustormer"]); double?dictlabid = Convert.ToDouble(headerDr["dictlabid"]); string province = headerDr["province"].ToString(); string city = headerDr["city"].ToString(); string county = headerDr["county"].ToString(); bool isunifiedpost = false; if (headerDr["isunifiedpost"].ToString() == "1") { isunifiedpost = true; } string postaddress = headerDr["postaddress"].ToString(); string recipient = headerDr["recipient"].ToString(); string contactnumber = headerDr["contactnumber"].ToString(); DictuserService userService = new DictuserService(); string username = userService.GetDictuserInfoAuto(enterby).Username; Orderfiledetail filedetail = new Orderfiledetail(); Orderfileheader fileheader = new Orderfileheader() { Orderfileheaderid = Orderfileheaderid, Status = 1 }; //bool isCacheData = true; //string conTestCode = ConfigurationManager.AppSettings["NoCacheTestCode"]; //List<Dicttestitem> TestItemList = loginservice.GetLoginDicttestitemListNoCache();//项目字典表 List <Dictproductdetail> ProductDetail = loginservice.GetLoginDictproductdetailNoCache(); //套餐组合字典 List <Dicttestitem> productlistTemp = new DicttestitemService().GetProduct(TypeParse.StrToDouble(dictcustormer, 0)); //查询分点+公用套餐 string _productname = string.Empty; for (int i = (dt.Rows.Count - 1); i >= 0; i--) { bool b = false;//添加是否成功 string errstr = ""; DataRow dr = dt.Rows[i]; string productTestCode = dr["套餐代码"].ToString().Replace('_', ' ').Trim(); string detailbarcode = string.Empty; try { detailbarcode = dr["条码号"].ToString().Replace('_', ' ').Trim(); if (detailbarcode != string.Empty) { Convert.ToDouble(detailbarcode); } } catch (Exception) { } string mobile = dr["手机"].ToString().Trim(); string idnumber = dr["身份证"].ToString().Trim(); string realname = dr["姓名"].ToString().Trim(); if (string.IsNullOrEmpty(realname) || string.IsNullOrEmpty(productTestCode)) { filedetail.Reason = "姓名、套餐代码不可以为空!"; filedetail.Status = 0; filedetail.Barcode = detailbarcode; filedetail.Orderfileheaderid = Orderfileheaderid; filedetail.Createdate = DateTime.Now; filedetail.Realname = realname; filedetail.Mobile = mobile; filedetail.Idnumber = idnumber; detailservice.InsertOrderfiledetail(filedetail); continue; } #region 条码号检查 if (detailbarcode != string.Empty && detailbarcode.Length != 12)//条码号非12位 { filedetail.Reason = string.Format("条码号[{0}]必须为12位数字,可以为空!", detailbarcode); filedetail.Status = 0; filedetail.Barcode = detailbarcode; filedetail.Orderfileheaderid = Orderfileheaderid; filedetail.Createdate = DateTime.Now; filedetail.Realname = realname; filedetail.Mobile = mobile; filedetail.Idnumber = idnumber; detailservice.InsertOrderfiledetail(filedetail); continue; } if (detailbarcode != string.Empty && detailbarcode.Substring(detailbarcode.Length - 2) != "00")//条码号不以00结尾 { filedetail.Reason = string.Format("此条码号[{0}]不是以00结尾,请更改条码号!", detailbarcode); filedetail.Status = 0; filedetail.Barcode = detailbarcode; filedetail.Orderfileheaderid = Orderfileheaderid; filedetail.Createdate = DateTime.Now; filedetail.Realname = realname; filedetail.Mobile = mobile; filedetail.Idnumber = idnumber; detailservice.InsertOrderfiledetail(filedetail); continue; } if (barcodeservice.CheckBarCode(detailbarcode))//条码号存在 { filedetail.Reason = string.Format("此条码号[{0}]已在本系统内生成,请更改条码号!", detailbarcode); filedetail.Status = 0; filedetail.Barcode = detailbarcode; filedetail.Orderfileheaderid = Orderfileheaderid; filedetail.Createdate = DateTime.Now; filedetail.Realname = realname; filedetail.Mobile = mobile; filedetail.Idnumber = idnumber; detailservice.InsertOrderfiledetail(filedetail); continue; } #endregion string sex = "U"; if (dr["性别"] != DBNull.Value && !string.IsNullOrEmpty(dr["性别"].ToString())) { //if (dr["性别"].ToString() == "女") // sex = "F"; //else if (dr["性别"].ToString() == "男") // sex = "M"; sex = dr["性别"].ToString().Replace('_', ' ').Trim() == "女" ? "F" : (dr["性别"].ToString().Replace('_', ' ').Trim() == "男" ? "M" : "U"); } List <Dicttestitem> productList = productlistTemp.Where <Dicttestitem>(c => c.Testcode == productTestCode && (c.Forsex.ToUpper() == sex.ToUpper() || c.Forsex.ToUpper() == "B")).ToList <Dicttestitem>(); List <Dicttestitem> grouptestList = new List <Dicttestitem>(); Dicttestitem productinfo = null; if (productList.Count == 0) { filedetail.Reason = String.Format("套餐代码[{0}]无匹配项,请查看性别是否匹配或者是否有该套餐。", productTestCode); filedetail.Status = 0; filedetail.Barcode = detailbarcode; filedetail.Orderfileheaderid = Orderfileheaderid; filedetail.Createdate = DateTime.Now; filedetail.Realname = realname; filedetail.Mobile = mobile; filedetail.Idnumber = idnumber; detailservice.InsertOrderfiledetail(filedetail); continue; } else if (productList.Count > 1) { filedetail.Reason = String.Format("存在多个套餐代码为[{0}]的套餐", productTestCode); filedetail.Status = 0; filedetail.Barcode = detailbarcode; filedetail.Orderfileheaderid = Orderfileheaderid; filedetail.Createdate = DateTime.Now; filedetail.Realname = realname; filedetail.Mobile = mobile; filedetail.Idnumber = idnumber; detailservice.InsertOrderfiledetail(filedetail); continue; } else { productinfo = productList[0]; if (productinfo.Testtype == "2")//公用套餐 { _productname = productinfo.Testname.ToString().Replace("(公用套餐)", ""); } else { _productname = productinfo.Testname; } //检验套餐中项目组合信息(性别是否相符;是否重复添加项目组合;项目是否维护分管原则、科室和标本类型) string msg = registerservice.AddProductAuto(sex, productinfo, detailbarcode); if (msg != string.Empty) { filedetail.Reason = msg; filedetail.Status = 0; filedetail.Barcode = detailbarcode; filedetail.Orderfileheaderid = Orderfileheaderid; filedetail.Createdate = DateTime.Now; filedetail.Realname = realname; filedetail.Mobile = mobile; filedetail.Idnumber = idnumber; detailservice.InsertOrderfiledetail(filedetail); continue; } //套餐下组合项目 IEnumerable <Dictproductdetail> IEgroup = ProductDetail.Where <Dictproductdetail>(c => c.Productid == productinfo.Dicttestitemid); bool iscontinue = true; string msgdetail = string.Empty; foreach (Dictproductdetail item in IEgroup) { Dicttestitem groupinfo = registerservice.SelectDicttestitemByDicttestitemid(item.Testgroupid); if (groupinfo == null) { msgdetail += string.Format("没有找到套餐[{0}]下ID为[{1}]的{2}[{3}]!", _productname, item.Testgroupid, groupinfo.Testtype == "0" ? "单项" : "组合", groupinfo.Testname) + ";"; iscontinue = false; continue; } groupinfo.Productid = productinfo.Dicttestitemid; groupinfo.Productname = productinfo.Testname; ///套餐名 groupinfo.IsActive = "1"; //是否停止测试 groupinfo.Isadd = "0"; ///是否追加 groupinfo.Billed = "0"; groupinfo.Sendbilled = "0"; groupinfo.Adduserid = null;//追加人ID if (detailbarcode == string.Empty) { IEnumerable <Dicttestitem> IEtempbarcodeList = grouptestList.Where <Dicttestitem>(c => c.Tubegroup == groupinfo.Tubegroup); if (IEtempbarcodeList.Count() > 0) { groupinfo.Barcode = IEtempbarcodeList.First <Dicttestitem>().Barcode; } else { groupinfo.Barcode = registerservice.GetBarCode(); } } else { groupinfo.Barcode = detailbarcode; } //获取外包客户 Dictproductdetail detail = ProductDetail.Where <Dictproductdetail>(c => c.Productid == productinfo.Dicttestitemid && c.Testgroupid == groupinfo.Dicttestitemid).First <Dictproductdetail>(); groupinfo.Sendoutcustomerid = detail.Sendoutcustomerid; grouptestList.Add(groupinfo); } if (!iscontinue) { if (!string.IsNullOrEmpty(msgdetail)) { filedetail.Reason = msgdetail; filedetail.Status = 0; filedetail.Barcode = detailbarcode; filedetail.Orderfileheaderid = Orderfileheaderid; filedetail.Createdate = DateTime.Now; filedetail.Realname = realname; filedetail.Mobile = mobile; filedetail.Idnumber = idnumber; detailservice.InsertOrderfiledetail(filedetail); } continue; } } #region >>>> 不存在此会员添加会员 Dictmember member = new Dictmember() { Realname = realname, Idnumber = idnumber }; //检查会员 errstr = registerservice.checkmember(null, ref member); if (errstr != string.Empty) { filedetail.Reason = errstr; filedetail.Status = 0; filedetail.Barcode = detailbarcode; filedetail.Orderfileheaderid = Orderfileheaderid; filedetail.Createdate = DateTime.Now; filedetail.Realname = realname; filedetail.Mobile = mobile; filedetail.Idnumber = idnumber; detailservice.InsertOrderfiledetail(filedetail); continue; } member.Nickname = member.Realname; member.Sex = sex; DateTime datebirthday; bool dateb = DateTime.TryParse(dr["出生日期"].ToString(), out datebirthday); if (dateb) { member.Birthday = datebirthday; } member.Addres = dr["住址"].ToString().Trim(); member.Phone = dr["电话"].ToString().Trim(); if (!string.IsNullOrWhiteSpace(dr["手机"].ToString().Trim())) { double a; bool mobileb = double.TryParse(dr["手机"].ToString().Trim(), out a); if (!mobileb) { filedetail.Reason = "手机号码填写不正确,不要有特殊字符,[-]也不能包含"; filedetail.Barcode = detailbarcode; filedetail.Status = 0; filedetail.Orderfileheaderid = Orderfileheaderid; filedetail.Createdate = DateTime.Now; filedetail.Realname = realname; filedetail.Mobile = mobile; filedetail.Idnumber = idnumber; detailservice.InsertOrderfiledetail(filedetail); continue; } } member.Mobile = dr["手机"].ToString().Trim(); member.Email = dr["邮箱"].ToString().Trim(); #endregion #region >>>> insert Orders double year = 0, month = 0, day = 0; double hours = 0;//小时 double age = 0; string agestr = dr["年龄"].ToString().Replace('_', ' ').Trim(); string ageFiled = string.Empty; bool ageb = double.TryParse(agestr, out age); if (member.Birthday == null) { if (agestr != string.Empty && ageb) { year = age; day = age * 365; member.Birthday = datebirthday = DateTime.Now.AddDays((0 - day)); } else { filedetail.Reason = "生日和年龄必须填写一项或者两项均填写错误"; filedetail.Barcode = detailbarcode; filedetail.Status = 0; filedetail.Orderfileheaderid = Orderfileheaderid; filedetail.Createdate = DateTime.Now; filedetail.Realname = realname; filedetail.Mobile = mobile; filedetail.Idnumber = idnumber; detailservice.InsertOrderfiledetail(filedetail); continue; } } TimeSpan ts = DateTime.Now - Convert.ToDateTime(member.Birthday);//时间差 year = Math.Truncate((double)(ts.Days / 365)); month = (ts.Days % 365) / 30; day = (ts.Days % 365) % 30; hours = ts.TotalHours; ageFiled = string.Format("{0}岁{1}月{2}日{3}时", year, month, day, 0);; //年龄字符串拼接 岁月日时 Orders _orders = new Orders(); _orders.Ordernum = new ProRegisterService().GetOrderNum();; //体检流水号 _orders.Remarks = dr["备注"].ToString().Trim(); //备注 _orders.Dictmemberid = member.Dictmemberid; //会员ID _orders.Dictcustomerid = dictcustormer; //所属客户ID 界面选择 _orders.Realname = member.Realname; _orders.Sex = member.Sex; //性别 对应INITBASIC表 _orders.Caculatedage = hours; //计算后的年龄(小时为单位) _orders.Age = ageFiled; _orders.Enterby = username; //录入人 _orders.Ordertestlst = _productname + ","; //项目清单(冗余字段) _orders.Dictlabid = dictlabid; //实验室分点 _orders.Ordersource = "1"; //单位上传 全是单位来源 _orders.Ismarried = dr["婚否"].ToString() == "未婚" ? "0" : (dr["婚否"].ToString() == "已婚" ? "1" : "2"); _orders.Section = dr["部门"].ToString().Trim(); _orders.Status = ((int)ParamStatus.OrdersStatus.BarCodePrint).ToString(); DateTime samplingdate; bool s = DateTime.TryParse(dr["采样日期"].ToString(), out samplingdate); if (s) { TimeSpan timespan = DateTime.Now - samplingdate; if (Math.Abs(timespan.Days) > 30) { filedetail.Reason = "采样时间与当前时间相差不能超过一个月"; filedetail.Barcode = detailbarcode; filedetail.Status = 0; filedetail.Orderfileheaderid = Orderfileheaderid; filedetail.Createdate = DateTime.Now; filedetail.Realname = realname; filedetail.Mobile = mobile; filedetail.Idnumber = idnumber; detailservice.InsertOrderfiledetail(filedetail); continue; } _orders.SamplingDate = samplingdate; } _orders.Province = province; _orders.City = city; _orders.County = county; if (isunifiedpost) { _orders.PostAddress = postaddress; _orders.Recipient = recipient; _orders.ContactNumber = contactnumber; } else { _orders.PostAddress = dr["住址"].ToString().Trim(); _orders.Recipient = realname; _orders.ContactNumber = dr["手机"].ToString().Trim(); } _orders.Area = dr["营业区"].ToString().Replace('_', ' ').Trim(); _orders.BatchNumber = dr["场次号"].ToString().Replace('_', ' ').Trim(); //add 20160530 增加客户经理字段 if (dt.Columns.Contains("客户经理")) { _orders.AccountManager = dr["客户经理"].ToString().Replace('_', ' ').Trim(); } //add 20160612 增加本批标本总数字段 if (dt.Columns.Contains("本批标本总数")) { _orders.SpecimenCount = dr["本批标本总数"].ToString().Replace('_', ' ').Trim(); } #endregion System.Collections.Hashtable htScan = new System.Collections.Hashtable(); htScan.Add("isScan", true); htScan.Add("EnterByID", enterby); htScan.Add("EnterBy", username); b = registerservice.insertUpdateOrdersAuto("单位批量上传", "", true, productList, grouptestList, member, _orders, "", ref errstr, htScan); if (b) { filedetail.Barcode = detailbarcode; filedetail.Reason = ""; filedetail.Status = 1; filedetail.Orderfileheaderid = Orderfileheaderid; filedetail.Createdate = DateTime.Now; filedetail.Realname = realname; filedetail.Mobile = mobile; filedetail.Idnumber = idnumber; detailservice.InsertOrderfiledetail(filedetail); } else { filedetail.Barcode = detailbarcode; filedetail.Reason = errstr + " 【Excel格式参照导入模版说明】"; filedetail.Status = 0; filedetail.Orderfileheaderid = Orderfileheaderid; filedetail.Createdate = DateTime.Now; filedetail.Realname = realname; filedetail.Mobile = mobile; filedetail.Idnumber = idnumber; detailservice.InsertOrderfiledetail(filedetail); } } return(headerservice.UpdateOrderfileheader(fileheader)); }
///选择组合项目添加 protected void DropTest_SelectedIndexChanged(object sender, EventArgs e) { if (DropTest.SelectedIndex == 0) { return; } ExtAspNet.ListItem li = DropTest.SelectedItem; List <OrderRegister> _gridtestList = GetGridTest(false); Dicttestitem dictestitem = new DicttestitemService().SelectDicttestitemByDicttestitemid(Convert.ToDouble(li.Value.ToString())); if (dictestitem != null) { if (dictestitem.Tubegroup == "" || dictestitem.Dictlabdeptid.ToString() == "" || dictestitem.Dictspecimentypeid.ToString() == "") { if (dictestitem.Tubegroup == "") { MessageBoxShow("" + dictestitem.Testname + "分管原则不能为空,请重新维护后再添加!"); return; } else if (dictestitem.Dictlabdeptid.ToString() == "") { MessageBoxShow("" + dictestitem.Testname + "所属科室不能为空,请重新维护后再添加!"); return; } else if (dictestitem.Dictspecimentypeid.ToString() == "") { MessageBoxShow("" + dictestitem.Testname + "标本类型不能为空,请重新维护后再添加!"); return; } } } string msg = registerserver.AddGroupTest(ref _gridtestList, DropSex.SelectedValue, null, Convert.ToDouble(li.Value), false, Userinfo, null, null); if (msg != string.Empty) { MessageBoxShow(msg); return; } //Dicttestitem itemtest = registerserver.SelectsTestItemListById(Convert.ToDouble(li.Value)); ////校验性别是否符合 //string str = registerserver.checkSex(itemtest.Dicttestitemid, DropSex.SelectedValue); //if (str != string.Empty) { MessageBoxShow(str); return; } //bool isNewBarcode = true; //string barccode = ""; //foreach (OrderRegister item in _gridtestList) //{ // string msg = registerserver.checkInsert(item, itemtest, string.Empty); // //此处判断组合存在,或者项目报告ID不同就不需要允许添加 // if (msg != string.Empty) { MessageBoxShow(msg); return; } // //分管原则相同时 没有标本接受时使用以前条码 // if (item.Tubegroup == itemtest.Tubegroup && (Convert.ToInt32(item.Status)) < ((int)daan.service.common.ParamStatus.OrderbarcodeStatus.Received)) // { // isNewBarcode = false; // barccode = item.Barcode; // } //} ////判断使用原条码还是新条码 //if (isNewBarcode) { barccode = registerserver.GetBarCode(); } //OrderRegister newOrderRegister = new OrderRegister(); //newOrderRegister.Productid = null; //newOrderRegister.Productname = null; //newOrderRegister.Id = itemtest.Dicttestitemid; //newOrderRegister.Code = itemtest.Testcode; //newOrderRegister.Name = itemtest.Testname; //newOrderRegister.Type = itemtest.Testtype; //newOrderRegister.Isadd = PageIsInsert.Readonly ? "1" : "0"; //if (PageIsInsert.Readonly) //{ // newOrderRegister.Adduserid = Userinfo.userId;///追加人 取当前用户名,ID // newOrderRegister.Addusername = Userinfo.userName; //} //newOrderRegister.Isactive = "1"; //newOrderRegister.Billed = "0"; //newOrderRegister.Sendbilled = "0"; //newOrderRegister.Sendoutcustomerid = null; //newOrderRegister.Tubegroup = itemtest.Tubegroup; //newOrderRegister.Barcode = barccode; //_gridtestList.Add(newOrderRegister); BindGridTest(_gridtestList);//绑定数据 tbxItemTest.Text += li.Text + ","; //DropTest.SelectedItem.Value = "-1"; // DropTest.SelectedValue = "-1"; }
/// <summary>上传体检订单 /// /// </summary> /// <param name="xmlStr"></param> /// <returns></returns> public static string UploadOrderInfo(string xmlStr) { xmlStr = xmlStr.TrimStart(''); string str = "<?xml version='1.0' encoding='utf-8'?>" + StringToXML(xmlStr); string strMessage = string.Empty; DataTable dt = new DataTable(); try { dt = GetDataTable(str); } catch (Exception ex) { return(String.Format("{0} {1}", ErrorCode.Up_0001, ex.Message)); } if (dt == null || dt.Rows.Count == 0 || dt.Columns.Count != 20) { return(ErrorCode.Up_0002); } List <Dicttestitem> TestItemList = loginservice.GetLoginDicttestitemList(); //项目字典表 List <Dictproductdetail> ProductDetail = loginservice.GetLoginDictproductdetail(); //套餐组合字典 string _productname = string.Empty; foreach (DataRow dr in dt.Rows) { #region 必填项 //套餐代码 string productTestCode = dr["uniquecode"].ToString().Replace('_', ' ').Trim(); //客户代码 string dictcustomerid = dr["dictcustomerid"].ToString().Trim(); //姓名 string realname = dr["realname"].ToString().Trim(); //性别 string sex = dr["sex"].ToString().Replace('_', ' ').Trim() == "女" ? "F" : (dr["sex"].ToString().Replace('_', ' ').Trim() == "男" ? "M" : "U"); //婚否 string ismarried = dr["ismarried"].ToString().Trim(); //手机 string mobile = dr["mobile"].ToString().Trim(); //住址 string address = dr["address"].ToString().Trim(); //省 string province = dr["province"].ToString().Trim(); //市 string city = dr["city"].ToString().Trim(); //分点实验室 string dictlabid = dr["dictlabid"].ToString().Trim(); //条码号 string barcode = dr["barcode"].ToString().Trim(); if (string.IsNullOrEmpty(productTestCode) || string.IsNullOrEmpty(dictcustomerid) || string.IsNullOrEmpty(dictlabid) || string.IsNullOrEmpty(barcode) || string.IsNullOrEmpty(realname) || string.IsNullOrEmpty(sex) || string.IsNullOrEmpty(ismarried) || string.IsNullOrEmpty(mobile) || string.IsNullOrEmpty(address) || string.IsNullOrEmpty(province) || string.IsNullOrEmpty(city)) { strMessage = ErrorCode.Up_0003; break; } #endregion #region 二者不可都为空 //出生日期 string birthday = dr["birthday"].ToString().Trim(); //年龄 string age = dr["age"].ToString().Trim(); if (string.IsNullOrEmpty(birthday) && string.IsNullOrEmpty(age)) { strMessage = ErrorCode.Up_0004; break; } #endregion #region 可空字段 //身份证 string idnumber = dr["idnumber"].ToString().Trim(); //部门 string section = dr["section"].ToString().Trim(); //备注 string remark = dr["remark"].ToString().Trim(); //电话 string phone = dr["phone"].ToString().Trim(); //邮箱 string email = dr["email"].ToString().Trim(); //采样日期 string samplingdate = dr["samplingdate"].ToString().Trim(); //区 string county = dr["county"].ToString().Trim(); #endregion DateTime datebirthday; bool datebirthdayb = DateTime.TryParse(birthday, out datebirthday); DateTime datesamplingdate; bool datesamplingdateb = DateTime.TryParse(samplingdate, out datesamplingdate); if ((birthday != string.Empty && !datebirthdayb) || (samplingdate != string.Empty && !datesamplingdateb)) { strMessage = ErrorCode.Up_0010; break; } //检查单位是否在体检系统中有维护 try { using (DataTable d = customerservice.CheckHasCustomer(dictcustomerid)) { if (d == null || d.Rows.Count == 0 || d.Rows.Count > 1) { strMessage = ErrorCode.Up_0011; break; } } } catch (Exception ee) { strMessage = ErrorCode.Up_0015 + " " + ee.Message; break; } #region 添加套餐 //查询分点+公用套餐 List <Dicttestitem> productlistTemp = new DicttestitemService().GetProduct(TypeParse.StrToDouble(dictcustomerid, 0)); List <Dicttestitem> productList = productlistTemp.Where <Dicttestitem>(c => c.Testcode == productTestCode && (c.Forsex == sex || c.Forsex == "B")).ToList <Dicttestitem>(); List <Dicttestitem> grouptestList = new List <Dicttestitem>(); Dicttestitem productinfo = null; if (productList.Count == 0) { strMessage = ErrorCode.Up_0005; break; } else if (productList.Count > 1) { strMessage = ErrorCode.Up_0006; break; } else { productinfo = productList.First <Dicttestitem>(); List <OrderRegister> _gridtestList = null; #region 添加套餐 string msg = registerservice.AddProduct(ref _gridtestList, sex, productinfo.Dicttestitemid, false, null, ref _productname, null); if (msg != string.Empty) { strMessage = ErrorCode.Up_0014; break; } #endregion if (barcode != string.Empty && barcode.Length != 12)//条码号必须为12位数字 { strMessage = ErrorCode.Up_0007; break; } if (barcode != string.Empty && barcode.Substring(barcode.Length - 2) != "00")//条码号必须以00结尾 { strMessage = ErrorCode.Up_0008; break; } //检验条码号是否合格且存在于体检系统 DataTable dtBarcode = barcodeservice.CheckBarCode2(barcode); if (dtBarcode != null && dtBarcode.Rows.Count > 0) { //判断已存在的条码是否来自大众平台 if (!dtBarcode.Rows[0]["enterby"].ToString().Contains("大众平台")) { //条码已存在且不是通过大众平台上传 strMessage = ErrorCode.Up_0009; break; } else { //判断该条码是否已经上传到康源系统,否则不允许修改; if (dtBarcode.Rows[0]["transed"].ToString() == "1") { strMessage = ErrorCode.Update_0005; break; } //删除该体检系统中订单 string ordernum = dtBarcode.Rows[0]["ordernum"].ToString(); Hashtable ht = new Hashtable(); ht["ordernum"] = ordernum; new ProCentralizedManagementService().DeleteOrders(ht); } } //套餐下组合项目 IEnumerable <Dictproductdetail> IEgroup = ProductDetail.Where <Dictproductdetail>(c => c.Productid == productinfo.Dicttestitemid); bool iscontinue = true; int count = IEgroup.Count <Dictproductdetail>(); int k = 0; foreach (Dictproductdetail item in IEgroup) { IEnumerable <Dicttestitem> IEgruptest = TestItemList.Where <Dicttestitem>(c => c.Dicttestitemid == item.Testgroupid); if (IEgruptest.Count() <= 0) { //没有找到套餐下组合 k++; continue; } Dicttestitem groupinfo = IEgruptest.First <Dicttestitem>(); //校验性别是否符合 string res = registerservice.checkSex(groupinfo.Dicttestitemid, sex); if (res != string.Empty) { //性别项目不合 strMessage = ErrorCode.Up_0012; iscontinue = false; break; } groupinfo.Productid = productinfo.Dicttestitemid; groupinfo.Productname = productinfo.Testname; ///套餐名 groupinfo.IsActive = "1"; //是否停止测试 groupinfo.Isadd = "0"; ///是否追加 groupinfo.Billed = "0"; groupinfo.Sendbilled = "0"; groupinfo.Adduserid = null;//追加人ID if (barcode == string.Empty) { IEnumerable <Dicttestitem> IEtempbarcodeList = grouptestList.Where <Dicttestitem>(c => c.Tubegroup == groupinfo.Tubegroup); if (IEtempbarcodeList.Count() > 0) { groupinfo.Barcode = IEtempbarcodeList.First <Dicttestitem>().Barcode; } else { groupinfo.Barcode = registerservice.GetBarCode(); } } else { groupinfo.Barcode = barcode; } //获取外包客户 Dictproductdetail detail = ProductDetail.Where <Dictproductdetail>(c => c.Productid == productinfo.Dicttestitemid && c.Testgroupid == groupinfo.Dicttestitemid).First <Dictproductdetail>(); groupinfo.Sendoutcustomerid = detail.Sendoutcustomerid; grouptestList.Add(groupinfo); } if (!iscontinue) { continue; } else { if (k >= count) { strMessage = ErrorCode.Up_0013; break; } } } #endregion #region 添加会员信息 Dictmember member = new Dictmember() { Realname = realname, Idnumber = idnumber }; registerservice.checkmember(null, ref member); if (datebirthdayb) { member.Birthday = datebirthday; } member.Nickname = member.Realname; member.Sex = sex; member.Addres = address; member.Phone = phone; member.Mobile = mobile; member.Email = email; #endregion #region 添加订单 double year = 0, month = 0, day = 0; double hours = 0; double aged = 0; string agestr = age; bool ageb = double.TryParse(agestr, out aged); if (member.Birthday == null) { if (agestr != string.Empty && ageb) { year = aged; day = aged * 365; member.Birthday = datebirthday = DateTime.Now.AddDays((0 - day)); } else { strMessage = ErrorCode.Up_0004; break; } } TimeSpan ts = DateTime.Now - Convert.ToDateTime(member.Birthday);//时间差 year = Math.Truncate((double)(ts.Days / 365)); month = (ts.Days % 365) / 30; day = (ts.Days % 365) % 30; hours = ts.TotalHours; Orders _orders = new Orders() { Ordernum = new ProRegisterService().GetOrderNum(), Dictmemberid = member.Dictmemberid, Dictcustomerid = Convert.ToDouble(dictcustomerid), Realname = realname, Sex = sex, Caculatedage = hours, Remarks = remark, Age = string.Format("{0}岁{1}月{2}日{3}时", year, month, day, 0), Enterby = enterby, Ordertestlst = _productname + ",", Dictlabid = Convert.ToDouble(dictlabid), Ordersource = "1", Ismarried = ismarried == "未婚" ? "0" : (ismarried == "已婚" ? "1" : "2"), Section = section, Status = ((int)daan.service.common.ParamStatus.OrdersStatus.BarCodePrint).ToString(), Province = province, City = city, County = county }; if (datesamplingdateb) { _orders.SamplingDate = datesamplingdate; } string errstr = string.Empty; System.Collections.Hashtable htScan = new System.Collections.Hashtable(); htScan.Add("isScan", true); htScan.Add("EnterByID", enterbyID); htScan.Add("EnterBy", enterby); bool b = registerservice.insertUpdateOrders("大众健康平台对接订单", "", true, productList, grouptestList, member, _orders, "", ref errstr, htScan); if (!b) { strMessage = String.Format("{0} {1}", ErrorCode.Up_0015, errstr); break; } #endregion } return(strMessage); }
protected void btnSave_Click(object sender, EventArgs e) { try { Dicttestitem item = new Dicttestitem(); Dicttestitem itemtest = new Dicttestitem();//修改前的信息 用作日志 //List<Dicttestitem> testitemList = BindTestItemAll();//所有单项的集合 List <Dicttestitem> dicttestitemList = new List <Dicttestitem>(); if (txtUniQueid.Text.Trim() == "") { MessageBoxShow("全国统一码不能为空!"); return; } if (txtEngName.Text.Trim() == "") { MessageBoxShow("英文缩写不能为空!"); return; } if (txtItemCode.Text.Trim() == "") { MessageBoxShow("项目代码不能为空!"); return; } if (txtEngLongName.Text.Trim() == "") { MessageBoxShow("英文全称不能为空!"); return; } if (txtTestName.Text.Trim() == "") { MessageBoxShow("项目名称不能为空!"); return; } if (txtPrintOrder.Text.Trim() == "") { MessageBoxShow("打印次序不能为空!"); return; } if (txtFastCode.Text.Trim() == "") { MessageBoxShow("助记符不能为空!"); return; } if (txtLabelNumber.Text.Trim() == "") { MessageBoxShow("标签份数不能为空!"); return; } if (txtStandardPrice.Text.Trim() == "") { MessageBoxShow("标准价格不能为空!"); return; } if (ddlforsex.SelectedValue == "-1") { MessageBoxShow("测试项性别不能为空!"); return; } if (ddlforsex.SelectedValue == "-1") { MessageBoxShow("测试项性别不能为空!"); return; } if (ddlResultType.SelectedValue == "-1") { MessageBoxShow("结果类型不能为空!"); return; } if (ddlReportTemplate.SelectedValue == "-1") { MessageBoxShow("报告模板不能为空!"); return; } if (ViewState["TestItemID"] != null) { double?id = Convert.ToDouble(ViewState["TestItemID"]); //item = (from Dicttestitem in testitemList where Dicttestitem.Dicttestitemid == id select Dicttestitem).ToList<Dicttestitem>()[0]; item = testitemservice.SelectDicttestitemByDicttestitemid(id); itemtest = item; Hashtable ht = new Hashtable(); ht.Add("Uniqueid", txtUniQueid.Text.Trim()); ht.Add("Dicttestitemid", id); dicttestitemList = new DicttestitemService().GetDicttestitemByCode(ht); } else { Hashtable ht = new Hashtable(); ht.Add("Uniqueid", txtUniQueid.Text.Trim()); dicttestitemList = new DicttestitemService().GetDicttestitemByCode(ht); } if (dicttestitemList.Count > 0) { MessageBoxShow("已存在相同的全国统一码!"); return; } item.Uniqueid = txtUniQueid.Text.Trim(); item.Engname = txtEngName.Text.Trim(); item.Testcode = txtItemCode.Text.Trim(); item.Englongname = txtEngLongName.Text.Trim(); item.Testname = txtTestName.Text.Trim(); item.Unit = txtUnit.Text.Trim(); item.Fastcode = txtFastCode.Text.Trim(); item.Dictcontainerid = Convert.ToDouble(ddlContainerType.SelectedValue); //试管类型 item.Dictreporttemplateid = Convert.ToDouble(ddlReportTemplate.SelectedValue); //报告模板 item.Dictspecimentypeid = Convert.ToDouble(ddlSpecimenType.SelectedValue); //标本类型 item.Dictlabdeptid = Convert.ToDouble(ddlPhysicalGourp.SelectedValue); //物理组 item.Tubegroup = ddlTubeGroup.SelectedValue.ToString(); //分管原则 item.Precision = txtPrecision.Text.Trim() == "" ? 0 : Convert.ToDouble(txtPrecision.Text.Trim()); item.Forsex = ddlforsex.SelectedValue; item.Resulttype = ddlResultType.SelectedValue; item.Defaultresult = txtDefaultResult.Text.Trim(); item.Refmethod = ddlRefmethod.SelectedValue; item.Price = Convert.ToDouble(txtStandardPrice.Text.Trim());//价格 item.Limithigh = txtLimitHight.Text == "" ? 0 : Convert.ToDouble(txtLimitHight.Text.Trim()); item.Limitlow = txtLimiLow.Text == "" ? 0 : Convert.ToDouble(txtLimiLow.Text.Trim()); item.Labelnumber = txtLabelNumber.Text == "" ? 0 : Convert.ToDouble(txtLabelNumber.Text.Trim()); item.Displayorder = txtPrintOrder.Text == "" ? 0 : Convert.ToDouble(txtPrintOrder.Text.Trim()); //打印排序 item.Testtype = "0"; //单项 item.Operationremark = txtOperationRemark.Text.Trim(); //操作指引说明 if (chbActive.Checked) { item.Active = "1"; } else { item.Active = "0"; } if (chbBillable.Checked) { item.Billable = "1"; } else { item.Billable = "0"; } if (chbReport.Checked) { item.Report = "1"; } else { item.Report = "0"; } if (chbImportanttest.Checked) { item.Isimportant = "1"; } else { item.Isimportant = "0"; } if (chbIsonlyForBill.Checked) { item.Isonlyforbill = "1"; } else { item.Isonlyforbill = "0"; } //if (item.Dicttestitemid != null) //{ // itemtest = (from Dicttestitem in testitemList where Dicttestitem.Dicttestitemid == item.Dicttestitemid select Dicttestitem).ToList<Dicttestitem>()[0]; //} double?f = testitemservice.SaveDictTestItem(item, itemtest); //新增、修改操作 if (f > 0) { item.Dicttestitemid = f; ViewState["TestItemID"] = f; CacheHelper.RemoveAllCache("daan.GetDicttestitem"); MessageBoxShow("新增项目成功!此项目在康源系统未做对照,需做完项目对照才可开单,请及时对照!"); BindSearchData(); //项目可选结果 //BindTestResult(item.Dicttestitemid); // AddTestItem();//清空 } else if (f == 0) { CacheHelper.RemoveAllCache("daan.GetDicttestitem"); Hashtable htPara = new Hashtable(); htPara.Add("olduniquecode", txtUniQueid.Text.Trim()); //htPara.Add("testname", txtTestName.Text.Trim()); if (new daan.service.ProjectControlService().GetProjectControlCountByUniquecode(htPara)) { MessageBoxShow("修改成功!"); } else { MessageBoxShow("修改成功!修改后的项目在康源系统未做对照,需做完项目对照才可开单,请及时对照!"); } BindSearchData(); //项目可选结果 //BindTestResult(item.Dicttestitemid); // AddTestItem();//清空 } else { MessageBoxShow("操作出错!"); } } catch (Exception ex) { MessageBoxShow(string.Format("保存数据出错,错误原因:{0}", ex.Message)); } }
//private void BindSearchData() //{ // List<Dicttestitem> testitemLst = GetGroupTestItemByC(); // gdGroupTestItem.DataSource = testitemLst; // gdGroupTestItem.DataBind(); //} //public List<Dicttestitem> GetGroupTestItemByC() //{ // List<Dicttestitem> testitemgoutpLst = BindTestGourp();//所有组合项目 // List<Dicttestitem> testitemLst = new List<Dicttestitem>(); // double? Dictlabdeptid = Convert.ToDouble(ddlgoupLibrary.SelectedValue); // if (Dictlabdeptid == -1) // { // testitemLst = testitemgoutpLst; // } // else // { // testitemLst = (from Dicttestitem in testitemgoutpLst where Dicttestitem.Dictlabdeptid == Dictlabdeptid select Dicttestitem).ToList<Dicttestitem>(); // } // string testitemStr = ttbSearch.Text; // List<Dicttestitem> newslist = new List<Dicttestitem>(); // foreach (Dicttestitem item in testitemLst) // { // if ((item.Fastcode != null && item.Fastcode.ToLower().Contains(testitemStr.ToLower())) || // (item.Engname != null && item.Engname.ToLower().Contains(testitemStr.ToLower())) || // (item.Testname != null && item.Testname.ToLower().Contains(testitemStr.ToLower())) || // (item.Testcode != null && item.Testcode.ToLower().Contains(testitemStr.ToLower())) || // (item.Uniqueid != null && item.Uniqueid.ToLower().Contains(testitemStr.ToLower())) || // (item.Englongname != null && item.Englongname.ToLower().Contains(testitemStr.ToLower())) // || testitemStr == "") // { // newslist.Add(item); // } // } // return newslist; //} #endregion #region 保存组合信息 protected void btnSave_Click(object sender, EventArgs e) { try { if (ddlPhysicalGourp.SelectedValue == "-1") { MessageBoxShow("请选择物理组!"); return; } if (ddlSpecimenType.SelectedValue == "-1") { MessageBoxShow("请选择标本类型!"); return; } if (ddlTubeGroup.SelectedValue == "-1") { MessageBoxShow("请选择分管原则!"); return; } if (txtGroupTestCode.Text.Trim() == "") { MessageBoxShow("请填写组合代码名称"); return; } if (txtGroupTestName.Text.Trim() == "") { MessageBoxShow("请填写组合名称"); return; } if (txtFastCode.Text.Trim() == "") { MessageBoxShow("请填写助记符名称"); return; } if (nbbStandardPrice.Text.Trim() == "") { MessageBoxShow("请填写标准价格"); return; } if (txtUniQueid.Text.Trim() == "") { MessageBoxShow("请填写全国统一码"); return; } Dicttestitem item = new Dicttestitem(); Dicttestitem testitem = new Dicttestitem();//日志操作,旧值 List <Dicttestitem> dicttestitemList = new List <Dicttestitem>(); //List<Dicttestitem> testitemgoutpLst = BindTestGourp();//所有组合项目 if (ViewState["TestItemID"] != null) { double?id = Convert.ToDouble(ViewState["TestItemID"]); //item = (from Dicttestitem in testitemgoutpLst where Dicttestitem.Dicttestitemid == id select Dicttestitem).ToList<Dicttestitem>()[0]; item = testitemservice.SelectDicttestitemByDicttestitemid(id); testitem = item; Hashtable ht = new Hashtable(); ht.Add("Uniqueid", txtUniQueid.Text.Trim()); ht.Add("Dicttestitemid", id); dicttestitemList = new DicttestitemService().GetDicttestitemByCode(ht); } else { Hashtable ht = new Hashtable(); ht.Add("Uniqueid", txtUniQueid.Text.Trim()); dicttestitemList = new DicttestitemService().GetDicttestitemByCode(ht); } if (dicttestitemList.Count > 0) { MessageBoxShow("已存在相同的全国统一码!"); return; } item.Fastcode = txtFastCode.Text.Trim(); item.Testcode = txtGroupTestCode.Text.Trim(); item.Testname = txtGroupTestName.Text.Trim(); item.Operationremark = txtOperationRemark.Text.Trim(); item.Price = Convert.ToDouble(nbbStandardPrice.Text.Trim()); item.Uniqueid = txtUniQueid.Text.Trim(); item.Dictlabdeptid = Convert.ToDouble(ddlPhysicalGourp.SelectedValue); item.Dictspecimentypeid = Convert.ToDouble(ddlSpecimenType.SelectedValue); item.Testtype = "1"; //1,组合 item.Tubegroup = ddlTubeGroup.SelectedValue; //分管原则 item.Displayorder = int.Parse(txtDisplayOrder.Text); if (chbActive.Checked) { item.Active = "1"; } else { item.Active = "0"; } if (chbIsonlyForBill.Checked) { item.Isonlyforbill = "1"; } else { item.Isonlyforbill = "0"; } //if (item.Dicttestitemid != null) //{ // testitem = (from Dicttestitem in testitemgoutpLst where Dicttestitem.Dicttestitemid == item.Dicttestitemid select Dicttestitem).ToList<Dicttestitem>()[0]; //} List <Dicttestitem> listIn = GridlistIn();//包含的项目 int num = 0; int flag = 0; StringBuilder type = new StringBuilder(); for (int i = 0; i < listIn.Count(); i++) { if (listIn[i].Tubegroup != "" && listIn[i].Dictlabdeptid.ToString() != "" && listIn[i].Dictspecimentypeid.ToString() != "") { //if (this.ddlTubeGroup.SelectedValue != listIn[i].Tubegroup || this.ddlPhysicalGourp.SelectedValue != listIn[i].Dictlabdeptid.ToString() || this.ddlSpecimenType.SelectedValue != listIn[i].Dictspecimentypeid.ToString()) if (ddlTubeGroup.SelectedValue != listIn[i].Tubegroup || ddlSpecimenType.SelectedValue != listIn[i].Dictspecimentypeid.ToString()) { num++; type.Append(listIn[i].Testname + ","); } } else { flag++; type.Append(listIn[i].Testname + ","); } } if (flag > 0) { MessageBoxShow(String.Format("{0}分管原则、所属科室、标本类型都不能为空,请重新维护!", type)); return; } if (num > 0) { //MessageBoxShow(String.Format("{0}必须与所选分管原则、所属科室、标本类型相同!", type)); MessageBoxShow(String.Format("{0}必须与所选分管原则、标本类型相同!", type)); return; } string strerr = string.Empty; double?f = testitemservice.SaveDictTestItem(item, listIn, testitem, ref strerr); if (f > 0) { item.Dicttestitemid = f; ViewState["TestItemID"] = f; CacheHelper.RemoveAllCache("daan.GetDicttestitem"); //删除项目缓存 CacheHelper.RemoveAllCache("daan.GetDicttestgroupdetail"); //删除项目结果缓存 BindSearchData(); //筛选下的项目 // AddTestGroup();//清空 MessageBoxShow("新增成功!"); } else if (f == 0) { CacheHelper.RemoveAllCache("daan.GetDicttestitem"); //删除项目缓存 CacheHelper.RemoveAllCache("daan.GetDicttestgroupdetail"); //删除项目结果缓存 BindSearchData(); //筛选下的项目 // AddTestGroup();//清空 MessageBoxShow("修改成功!"); } else { MessageBoxShow("操作出错:" + strerr); } } catch (Exception ex) { MessageBoxShow(ex.ToString()); } }
//导入 protected void btnImport_Click(object sender, EventArgs e) { if (DropDictLab.SelectedValue == null) { MessageBoxShow("请先选择分点!"); return; } if (DropCustomer.SelectedIndex == 0) { MessageBoxShow("请先选择单位!"); return; } if (dpProvince.SelectedValue == "-1" || dpCity.SelectedValue == "-1") { MessageBoxShow("请选择省、市"); return; } string fileType = fileExcel.PostedFile.ContentType; if (fileType != "application/octet-stream" && fileType != "application/vnd.ms-excel" && fileType != "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" && fileType != "application/kset") { MessageBoxShow("请上传指定格式的Excel文件"); return; } if (ck1.Checked) { if (string.IsNullOrEmpty(txtAddress.Text.Trim()) || string.IsNullOrEmpty(txtRecName.Text.Trim()) || string.IsNullOrEmpty(txtTelphone.Text.Trim())) { MessageBoxShow("邮寄地址、收件人、联系电话不能为空"); return; } } string fileName = fileExcel.ShortFileName; fileName = fileName.Replace(":", "_").Replace(" ", "_").Replace("\\", "_").Replace("/", "_"); fileName = String.Format("{0}_{1}", DateTime.Now.Ticks, fileName); string savePath = Server.MapPath("~/upload/ExcelFiles/" + fileName); if (fileExcel.HasFile) { if (!Directory.Exists(Server.MapPath("~/upload/ExcelFiles"))) { Directory.CreateDirectory(Server.MapPath("~/upload/ExcelFiles")); } try { fileExcel.SaveAs(savePath); } catch (Exception ex) { MessageBoxShow("上传错误:" + ex.Message); return; } } DataTable dt; try { dt = RenderDataTableFromExcel(savePath); if (dt == null || dt.Rows.Count == 0) { MessageBoxShow("上传的文件数据不能为空!"); return; } //验证上传的excel是否符合模板标准,否则不让上传订单并删除上传的文件 string str = CheckDate(dt, fileName); if (!string.IsNullOrEmpty(str)) { MessageBoxShow(str); File.Delete(savePath);//删除文件 return; } } catch (Exception ex) { MessageBoxShow("请上传指定格式的Excel文件!\r\n提示信息:" + ex.Message); return; } List <Dicttestitem> TestItemList = loginservice.GetLoginDicttestitemList(); //项目字典表 List <Dictproductdetail> ProductDetail = loginservice.GetLoginDictproductdetail(); //套餐组合字典 //查询分点+公用套餐 List <Dicttestitem> productlistTemp = new DicttestitemService().GetProduct(TypeParse.StrToDouble(DropCustomer.SelectedValue, 0)); string _productname = string.Empty; #region 读取excel数据并上传订单 try { for (int i = (dt.Rows.Count - 1); i >= 0; i--) { bool b = false;//添加是否成功 string errstr = ""; DataRow dr = dt.Rows[i]; string productTestCode = dr["套餐代码"].ToString().Replace('_', ' ').Trim(); string sex = dr["性别"].ToString().Replace('_', ' ').Trim() == "女" ? "F" : (dr["性别"].ToString().Replace('_', ' ').Trim() == "男" ? "M" : "U"); List <Dicttestitem> productList = productlistTemp.Where <Dicttestitem>(c => c.Testcode == productTestCode && (c.Forsex == sex || c.Forsex == "B")).ToList <Dicttestitem>(); List <Dicttestitem> grouptestList = new List <Dicttestitem>(); Dicttestitem productinfo = null; if (productList.Count == 0) { errstr = String.Format("套餐代码[{0}]无匹配项,请查看性别是否匹配或者是否有该套餐。", productTestCode); SetTableValue(false, errstr, dr); continue; } else if (productList.Count > 1) { errstr = String.Format("存在多个套餐代码为[{0}]的套餐", productTestCode); SetTableValue(false, errstr, dr); continue; } else { productinfo = productList.First <Dicttestitem>(); List <OrderRegister> _gridtestList = null; string msg = registerservice.AddProduct(ref _gridtestList, sex, productinfo.Dicttestitemid, false, Userinfo, ref _productname, null); if (msg != string.Empty) { //错误 SetTableValue(false, msg, dr); continue; } string barcode = dr["条码号"].ToString().Replace('_', ' ').Trim(); if (barcode != string.Empty && barcode.Length != 12) { errstr = string.Format("条码号[{0}]必须为12位数字,可以为空!", barcode); SetTableValue(false, errstr, dr); continue; } if (barcode != string.Empty && barcode.Substring(barcode.Length - 2) != "00") { errstr = string.Format("条码号[{0}]必须以00结尾!", barcode); SetTableValue(false, errstr, dr); continue; } if (barcodeservice.CheckBarCode(barcode))//条码号存在 { errstr = string.Format("此条码号[{0}]已在本系统内生成,请更改条码号!", barcode); SetTableValue(false, errstr, dr); continue; } //套餐下组合项目 IEnumerable <Dictproductdetail> IEgroup = ProductDetail.Where <Dictproductdetail>(c => c.Productid == productinfo.Dicttestitemid); bool iscontinue = true; foreach (Dictproductdetail item in IEgroup) { IEnumerable <Dicttestitem> IEgruptest = TestItemList.Where <Dicttestitem>(c => c.Dicttestitemid == item.Testgroupid); if (IEgruptest.Count() <= 0) { errstr = string.Format("没有找到套餐[{0}]下ID为[{1}]的组合!", _productname, item.Testgroupid); SetTableValue(false, errstr, dr); continue; } Dicttestitem groupinfo = IEgruptest.First <Dicttestitem>(); //校验性别是否符合 string str = registerservice.checkSex(groupinfo.Dicttestitemid, sex); if (str != string.Empty) { SetTableValue(false, str, dr); iscontinue = false; break; } groupinfo.Productid = productinfo.Dicttestitemid; groupinfo.Productname = productinfo.Testname; ///套餐名 groupinfo.IsActive = "1"; //是否停止测试 groupinfo.Isadd = "0"; ///是否追加 groupinfo.Billed = "0"; groupinfo.Sendbilled = "0"; groupinfo.Adduserid = null;//追加人ID if (barcode == string.Empty) { IEnumerable <Dicttestitem> IEtempbarcodeList = grouptestList.Where <Dicttestitem>(c => c.Tubegroup == groupinfo.Tubegroup); if (IEtempbarcodeList.Count() > 0) { groupinfo.Barcode = IEtempbarcodeList.First <Dicttestitem>().Barcode; } else { groupinfo.Barcode = registerservice.GetBarCode(); } } else { groupinfo.Barcode = barcode; } //获取外包客户 Dictproductdetail detail = ProductDetail.Where <Dictproductdetail>(c => c.Productid == productinfo.Dicttestitemid && c.Testgroupid == groupinfo.Dicttestitemid).First <Dictproductdetail>(); groupinfo.Sendoutcustomerid = detail.Sendoutcustomerid; grouptestList.Add(groupinfo); } if (!iscontinue) { continue; } } #region >>>> zhouy 不存在此会员添加会员 string realname = dr["姓名"].ToString().Trim(); Dictmember member = new Dictmember() { Realname = realname }; string idnumber = dr["身份证"].ToString().Trim(); member.Idnumber = idnumber; //检查会员 errstr = registerservice.checkmember(null, ref member); if (errstr != string.Empty) { SetTableValue(false, errstr, dr); continue; } //List<Dictmember> memberList = memberservice.GetDictmemberList(member); //if (memberList.Count == 1)//存在此会员记录且只有一条 //{ // member = memberList[0]; // member.isAdd = false;//标识是否添加 //} //else //{ // member.Dictmemberid = loginservice.getSeqID("SEQ_DICTMEMBER"); // member.Islock = "F";//是否锁定 // member.isAdd = true; //} member.Nickname = member.Realname; member.Sex = sex; DateTime datebirthday; bool dateb = DateTime.TryParse(dr["出生日期"].ToString(), out datebirthday); if (dateb) { member.Birthday = datebirthday; } member.Addres = dr["住址"].ToString().Trim(); member.Phone = dr["电话"].ToString().Trim(); if (!string.IsNullOrWhiteSpace(dr["手机"].ToString().Trim())) { double a; bool mobileb = double.TryParse(dr["手机"].ToString().Trim(), out a); if (!mobileb) { SetTableValue(false, "手机号码填写不正确,不要有特殊字符,[-]也不能包含", dr); continue; } } member.Mobile = dr["手机"].ToString().Trim(); member.Email = dr["邮箱"].ToString().Trim(); #endregion double year = 0, month = 0, day = 0; double hours = 0;//小时 double age = 0; string agestr = dr["年龄"].ToString().Replace('_', ' ').Trim(); bool ageb = double.TryParse(agestr, out age); if (member.Birthday == null) { if (agestr != string.Empty && ageb) { year = age; day = age * 365; member.Birthday = datebirthday = DateTime.Now.AddDays((0 - day)); } else { SetTableValue(false, "生日和年龄必须填写一项或者两项均填写错误", dr); continue; } } TimeSpan ts = DateTime.Now - Convert.ToDateTime(member.Birthday);//时间差 year = Math.Truncate((double)(ts.Days / 365)); month = (ts.Days % 365) / 30; day = (ts.Days % 365) % 30; hours = ts.TotalHours; Orders _orders = new Orders(); _orders.Ordernum = new ProRegisterService().GetOrderNum();; //体检流水号 _orders.Remarks = dr["备注"].ToString().Trim(); //备注 _orders.Dictmemberid = member.Dictmemberid; //会员ID _orders.Dictcustomerid = Convert.ToDouble(DropCustomer.SelectedValue); //所属客户ID 界面选择 _orders.Realname = member.Realname; _orders.Sex = member.Sex; //性别 对应INITBASIC表 _orders.Caculatedage = hours; //计算后的年龄(小时为单位) _orders.Age = string.Format("{0}岁{1}月{2}日{3}时", year, month, day, 0); //年龄字符串拼接 岁月日时 _orders.Enterby = Userinfo.userName; //录入人 _orders.Ordertestlst = _productname + ","; //项目清单(冗余字段) _orders.Dictlabid = Convert.ToDouble(DropDictLab.SelectedValue); //实验室分点 _orders.Ordersource = "1"; //单位上传 全是单位来源 _orders.Ismarried = dr["婚否"].ToString() == "未婚" ? "0" : (dr["婚否"].ToString() == "已婚" ? "1" : "2"); _orders.Section = dr["部门"].ToString().Trim(); _orders.Status = ((int)ParamStatus.OrdersStatus.BarCodePrint).ToString(); DateTime samplingdate; bool s = DateTime.TryParse(dr["采样日期"].ToString(), out samplingdate); if (s) { TimeSpan timespan = DateTime.Now - samplingdate; if (Math.Abs(timespan.Days) > 30) { SetTableValue(false, "采样时间与当前时间相差不能超过一个月", dr); continue; } _orders.SamplingDate = samplingdate; } _orders.Province = dpProvince.SelectedValue == "-1" ? "" : dpProvince.SelectedText; _orders.City = dpCity.SelectedValue == "-1" ? "" : dpCity.SelectedText; _orders.County = dpCounty.SelectedValue == "-1" ? "" : dpCounty.SelectedText; if (ck1.Checked) { _orders.PostAddress = Regex.Replace(txtAddress.Text, @"\s", ""); _orders.ContactNumber = Regex.Replace(txtTelphone.Text, @"\s", ""); _orders.Recipient = Regex.Replace(txtRecName.Text, @"\s", ""); } else { _orders.PostAddress = dr["住址"].ToString().Trim(); _orders.Recipient = realname; _orders.ContactNumber = dr["手机"].ToString().Trim(); } //add 20160421 增加营业区、场次号 _orders.Area = dr["营业区"].ToString().Replace('_', ' ').Trim(); _orders.BatchNumber = dr["场次号"].ToString().Replace('_', ' ').Trim(); //add 20160530 增加客户经理字段 if (dt.Columns.Contains("客户经理")) { _orders.AccountManager = dr["客户经理"].ToString().Replace('_', ' ').Trim(); } //add 20160612 增加本批标本总数字段 if (dt.Columns.Contains("本批标本总数")) { _orders.SpecimenCount = dr["本批标本总数"].ToString().Replace('_', ' ').Trim(); } b = registerservice.insertUpdateOrders("单位批量上传", "", true, productList, grouptestList, member, _orders, "", ref errstr); SetTableValue(b, errstr, dr); } GridUpload.DataSource = dt; GridUpload.DataBind(); } catch (Exception ee) { string str = string.Format("导入失败,异常信息:{0}【Excel格式请严格参照导入模版说明】\n\n导入过程中如有疑问,请将异常信息截图后发与系统管理员。", ee.Message); MessageBoxShow(str); } #endregion }
/// <summary> /// 接收数据 /// </summary> /// <param name="SID"></param> /// <param name="XML"></param> /// <returns></returns> public static string ReceiveXMLData(string SID, string xmlStr) { xmlStr = xmlStr.TrimStart(''); // if (xmlStr == string.Empty) // { // xmlStr = @" // <data><datarow> // <uniquecode >TY0008</uniquecode > // <dictcustomerid>1396</dictcustomerid> // <barcode>380003772900</barcode> // <realname>马昌武3</realname> // <sex>男</sex> // <birthday></birthday> // <age>41</age> // <ismarried>未知</ismarried> // <mobile>13096786113</mobile> // <idnumber></idnumber> // <address>地址</address> // <section>遵义</section> // <remark>备注</remark> // <phone></phone> // <email></email> // <samplingdate>2014-12-18</samplingdate> // <province>广东</province> // <city>广州市</city> // <county>天河区</county> // <dictlabid>3</dictlabid> // </datarow></data> // "; // } string str = "<?xml version='1.0' encoding='utf-8'?>" + StringToXML(xmlStr); string strMessage = string.Empty; //缓存取登录用户 Cache cache = new Cache(); CacheInfo info = cache.GetCacheData(SID); DataTable dt = new DataTable(); try { dt = GetDataTable(str); } catch (Exception ex) { return(String.Format("{0} {1}", ErrorCode.Rec_1002, ex.Message)); } if (dt == null || dt.Rows.Count == 0 || dt.Columns.Count != 20) { return(ErrorCode.Rec_1003); } List <Dicttestitem> TestItemList = loginservice.GetLoginDicttestitemList(); //项目字典表 List <Dictproductdetail> ProductDetail = loginservice.GetLoginDictproductdetail(); //套餐组合字典 string _productname = string.Empty; foreach (DataRow dr in dt.Rows) { #region 必填项 //套餐代码 string productTestCode = dr["uniquecode"].ToString().Replace('_', ' ').Trim(); //客户代码 string dictcustomercode = dr["dictcustomerid"].ToString().Trim(); //条码号 string barcode = dr["barcode"].ToString().Trim(); //姓名 string realname = dr["realname"].ToString().Trim(); //性别 string sex = dr["sex"].ToString().Replace('_', ' ').Trim() == "女" ? "F" : (dr["sex"].ToString().Replace('_', ' ').Trim() == "男" ? "M" : "U"); //婚否 string ismarried = dr["ismarried"].ToString().Trim(); //手机 string mobile = dr["mobile"].ToString().Trim(); //住址 string address = dr["address"].ToString().Trim(); //省 string province = dr["province"].ToString().Trim(); //市 string city = dr["city"].ToString().Trim(); //分点实验室 string dictlabid = dr["dictlabid"].ToString().Trim(); if (string.IsNullOrEmpty(productTestCode) || string.IsNullOrEmpty(dictcustomercode) || string.IsNullOrEmpty(dictlabid) || string.IsNullOrEmpty(realname) || string.IsNullOrEmpty(sex) || string.IsNullOrEmpty(ismarried) || string.IsNullOrEmpty(mobile) || string.IsNullOrEmpty(address) || string.IsNullOrEmpty(province) || string.IsNullOrEmpty(city)) { strMessage = ErrorCode.Rec_1005; break; } #endregion #region 二者不可都为空 //出生日期 string birthday = dr["birthday"].ToString().Trim(); //年龄 string age = dr["age"].ToString().Trim(); if (string.IsNullOrEmpty(birthday) && string.IsNullOrEmpty(age)) { strMessage = ErrorCode.Rec_1006; break; } #endregion #region 可空字段 //身份证 string idnumber = dr["idnumber"].ToString().Trim(); //部门 string section = dr["section"].ToString().Trim(); //备注 string remark = dr["remark"].ToString().Trim(); //电话 string phone = dr["phone"].ToString().Trim(); //邮箱 string email = dr["email"].ToString().Trim(); //采样日期 string samplingdate = dr["samplingdate"].ToString().Trim(); //区 string county = dr["county"].ToString().Trim(); #endregion DateTime datebirthday; bool datebirthdayb = DateTime.TryParse(birthday, out datebirthday); DateTime datesamplingdate; bool datesamplingdateb = DateTime.TryParse(samplingdate, out datesamplingdate); if ((birthday != string.Empty && !datebirthdayb) || (samplingdate != string.Empty && !datesamplingdateb)) { strMessage = ErrorCode.Rec_1013; break; } //检查单位是否在体检系统中有维护 string dictcustomerid = string.Empty; try { using (DataTable d = customerservice.CheckHasCustomer(dictcustomercode)) { if (d == null || d.Rows.Count == 0 || d.Rows.Count > 1) { strMessage = ErrorCode.Up_0011; break; } else { dictcustomerid = d.Rows[0][0].ToString(); } } } catch (Exception ee) { strMessage = ErrorCode.Up_0015 + " " + ee.Message; break; } #region 添加套餐 //查询分点+公用套餐 List <Dicttestitem> productlistTemp = new DicttestitemService().GetProduct(TypeParse.StrToDouble(dictcustomerid, 0)); List <Dicttestitem> productList = productlistTemp.Where <Dicttestitem>(c => c.Testcode == productTestCode && (c.Forsex == sex || c.Forsex == "B")).ToList <Dicttestitem>(); List <Dicttestitem> grouptestList = new List <Dicttestitem>(); Dicttestitem productinfo = null; if (productList.Count == 0) { strMessage = ErrorCode.Rec_1008; break; } else if (productList.Count > 1) { strMessage = ErrorCode.Rec_1009; break; } else { productinfo = productList.First <Dicttestitem>(); List <OrderRegister> _gridtestList = null; #region 添加套餐 string msg = registerservice.AddProduct(ref _gridtestList, sex, productinfo.Dicttestitemid, false, null, ref _productname, null); if (msg != string.Empty) { strMessage = ErrorCode.Rec_1017; break; } #endregion if (barcode != string.Empty && barcode.Length != 12)//条码号必须为12位数字 { strMessage = ErrorCode.Rec_1010; break; } if (barcode != string.Empty && barcode.Substring(barcode.Length - 2) != "00")//条码号必须以00结尾 { strMessage = ErrorCode.Rec_1011; break; } if (barcodeservice.CheckBarCode(barcode))//条码号已在系统中存在 { strMessage = ErrorCode.Rec_1012; break; } //套餐下组合项目 IEnumerable <Dictproductdetail> IEgroup = ProductDetail.Where <Dictproductdetail>(c => c.Productid == productinfo.Dicttestitemid); bool iscontinue = true; int count = IEgroup.Count <Dictproductdetail>(); int k = 0; foreach (Dictproductdetail item in IEgroup) { IEnumerable <Dicttestitem> IEgruptest = TestItemList.Where <Dicttestitem>(c => c.Dicttestitemid == item.Testgroupid); if (IEgruptest.Count() <= 0) { //没有找到套餐下组合 k++; continue; } Dicttestitem groupinfo = IEgruptest.First <Dicttestitem>(); //校验性别是否符合 string res = registerservice.checkSex(groupinfo.Dicttestitemid, sex); if (res != string.Empty) { //性别项目不合 strMessage = ErrorCode.Rec_1015; iscontinue = false; break; } groupinfo.Productid = productinfo.Dicttestitemid; groupinfo.Productname = productinfo.Testname; ///套餐名 groupinfo.IsActive = "1"; //是否停止测试 groupinfo.Isadd = "0"; ///是否追加 groupinfo.Billed = "0"; groupinfo.Sendbilled = "0"; groupinfo.Adduserid = null;//追加人ID if (barcode == string.Empty) { IEnumerable <Dicttestitem> IEtempbarcodeList = grouptestList.Where <Dicttestitem>(c => c.Tubegroup == groupinfo.Tubegroup); if (IEtempbarcodeList.Count() > 0) { groupinfo.Barcode = IEtempbarcodeList.First <Dicttestitem>().Barcode; } else { groupinfo.Barcode = registerservice.GetBarCode(); } } else { groupinfo.Barcode = barcode; } //获取外包客户 Dictproductdetail detail = ProductDetail.Where <Dictproductdetail>(c => c.Productid == productinfo.Dicttestitemid && c.Testgroupid == groupinfo.Dicttestitemid).First <Dictproductdetail>(); groupinfo.Sendoutcustomerid = detail.Sendoutcustomerid; grouptestList.Add(groupinfo); } if (!iscontinue) { continue; } else { if (k >= count) { strMessage = ErrorCode.Rec_1016; break; } } } #endregion #region 添加会员 Dictmember member = new Dictmember() { Realname = realname, Idnumber = idnumber, Nickname = realname, Sex = sex, Addres = address, Phone = phone, Mobile = mobile, Email = email }; if (datebirthdayb) { member.Birthday = datebirthday; } registerservice.checkmember(null, ref member); #endregion #region 添加订单 double year = 0, month = 0, day = 0; double hours = 0; double aged = 0; string agestr = age; bool ageb = double.TryParse(agestr, out aged); if (member.Birthday == null) { if (agestr != string.Empty && ageb) { year = aged; day = aged * 365; member.Birthday = datebirthday = DateTime.Now.AddDays((0 - day)); } else { strMessage = ErrorCode.Rec_1006; break; } } TimeSpan ts = DateTime.Now - Convert.ToDateTime(member.Birthday);//时间差 year = Math.Truncate((double)(ts.Days / 365)); month = (ts.Days % 365) / 30; day = (ts.Days % 365) % 30; hours = ts.TotalHours; Orders _orders = new Orders() { Ordernum = new ProRegisterService().GetOrderNum(), Dictmemberid = member.Dictmemberid, Dictcustomerid = Convert.ToDouble(dictcustomerid), Realname = realname, Sex = sex, Caculatedage = hours, Remarks = remark, Age = string.Format("{0}岁{1}月{2}日{3}时", year, month, day, 0), Enterby = "admin", Ordertestlst = _productname + ",", Dictlabid = Convert.ToDouble(dictlabid), Ordersource = "1", Ismarried = ismarried == "未婚" ? "0" : (ismarried == "已婚" ? "1" : "2"), Section = section, Status = ((int)daan.service.common.ParamStatus.OrdersStatus.BarCodePrint).ToString(), Province = province, City = city, County = county }; if (datesamplingdateb) { _orders.SamplingDate = datesamplingdate; } string errstr = string.Empty; bool b = registerservice.insertUpdateOrders("易感基因对接订单", "", true, productList, grouptestList, member, _orders, "", ref errstr); if (!b) { strMessage = String.Format("{0} {1}", ErrorCode.Rec_1018, errstr); } #endregion } return(strMessage); }