Esempio n. 1
0
        /****
        *  /// <summary>
        *  /// 导入数据
        *  /// </summary>
        *  /// <param name="dt"></param>
        *  /// <param name="headerDr"></param>
        *  private bool AutoUploadFile1(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;
        *
        *   Orderfileheader fileheader = new Orderfileheader(){Orderfileheaderid = Orderfileheaderid,Status = 1};
        *
        *   IList<Dicttestitem> TestItemList = loginservice.GetLoginDicttestitemListNoCache();//项目字典表
        *   IList<Dictproductdetail> ProductDetail = loginservice.GetLoginDictproductdetailNoCache();//套餐组合字典
        *
        *   string error = string.Empty;
        *   IList<Dicttestitem> productlistTemp = new DicttestitemService().GetProduct(TypeParse.StrToDouble(dictcustormer, 0));
        *   Dicttestitem productinfo = null;
        *
        *
        *   IList<Orderfiledetail> list = new List<Orderfiledetail>();
        *   if (!dt.Columns.Contains("Error"))
        *   {
        *       dt.Columns.Add("Error");
        *   }
        *   foreach (DataRow dr in dt.Rows)
        *   {
        *       List<Dicttestitem> grouptestList = new List<Dicttestitem>();
        *       string productTestCode = dr["套餐代码"] == DBNull.Value ? string.Empty : dr["套餐代码"].ToString().Replace("_", "").Trim();
        *       string detailbarcode = dr["条码号"] == DBNull.Value ? string.Empty : dr["条码号"].ToString().Replace('_', ' ').Trim();
        *
        *       string realname = dr["姓名"] == DBNull.Value ? string.Empty : dr["姓名"].ToString();
        *       string idnumber = dr["身份证"] == DBNull.Value ? string.Empty : dr["身份证"].ToString();
        *
        *       Regex reMobile = new Regex("(^18\\d{9}$)|(^13\\d{9}$)|(^15\\d{9})|(^14\\d{9})|(^17\\d{9}$)");    //验证手机号码的正则表达式
        *       Regex reNumber = new Regex("^[0-9]*$");  //验证是否为全数字的  正则表达式
        *       string mobile = dr["手机"] == DBNull.Value ? string.Empty : dr["手机"].ToString();
        *
        *       string _productname = string.Empty;
        *       if (string.IsNullOrEmpty(productTestCode))
        *       {
        *           error += "套餐代码不可以为空;";
        *       }
        *       if (string.IsNullOrEmpty(realname))
        *       {
        *           error += "姓名不可以为空;";
        *       }
        *       if (!string.IsNullOrEmpty(detailbarcode))
        *       {
        *           if (detailbarcode.Length != 12 && !reNumber.IsMatch(detailbarcode))
        *           {
        *               error += "条码号:[" + detailbarcode + "]必须为12位的数字;";
        *           }
        *           if (detailbarcode.Substring(detailbarcode.Length - 2) != "00")  //条码号不以00结尾
        *           {
        *               error += "条码号:[" + detailbarcode + "] 最后两位不是00,请更改条码号;";
        *           }
        *       }
        *       string sex = "U";
        *       if (dr["性别"] != DBNull.Value && !string.IsNullOrEmpty(dr["性别"].ToString()))
        *       {
        *           if (dr["性别"].ToString() == "女")
        *               sex = "F";
        *           else if (dr["性别"].ToString() == "男")
        *               sex = "M";
        *       }
        *
        *       List<Dicttestitem> productList = productlistTemp.Where<Dicttestitem>(c => c.Testcode == productTestCode && (c.Forsex.ToUpper() == sex.ToUpper() || c.Forsex.ToUpper() == "B")).ToList<Dicttestitem>();
        *       if (productList.Count == 0)
        *       {
        *           error += String.Format("套餐代码[{0}]无匹配项,请查看性别是否匹配或者是否有该套餐;", productTestCode);
        *       }
        *       else if (productList.Count > 1)
        *       {
        *           error += String.Format("存在多个套餐代码为[{0}]的套餐;", productTestCode);
        *       }
        *       else
        *       {
        *           List<OrderRegister> _gridtestList = null;
        *           productinfo = productList[0];
        *           string msg = registerservice.AddProductAuto(ref _gridtestList, sex, productinfo.Dicttestitemid, false, enterby, ref _productname, null,true);
        *           if (!string.IsNullOrEmpty(msg))
        *           {
        *               error += msg + ";";
        *           }
        *
        #region 套餐下组合项目
        *           //套餐下组合项目
        *           IEnumerable<Dictproductdetail> IEgroup = ProductDetail.Where<Dictproductdetail>(c => c.Productid == productinfo.Dicttestitemid);
        *
        *           foreach (Dictproductdetail item in IEgroup)
        *           {
        *               IEnumerable<Dicttestitem> IEgruptest = TestItemList.Where<Dicttestitem>(c => c.Dicttestitemid == item.Testgroupid);
        *               if (IEgruptest.Count() <= 0)
        *               {
        *                   error += string.Format("没有找到套餐[{0}]下ID为[{1}]的组合;", _productname, item.Testgroupid);
        *                   break;
        *               }
        *               Dicttestitem groupinfo = IEgruptest.First<Dicttestitem>();
        *
        *               //校验性别是否符合
        *               string str = registerservice.checkSex(groupinfo.Dicttestitemid, sex);
        *               if (!string.IsNullOrEmpty(str))
        *               {
        *                   error += str + ";";
        *                   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 (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);
        *           }
        #endregion
        *       }
        #region >>>>  不存在此会员添加会员
        *       Dictmember member = new Dictmember() { Realname = realname, Idnumber = idnumber };
        *       //检查会员
        *       string errstr = registerservice.checkmember(null, ref member);
        *       if (!string.IsNullOrEmpty(errstr))
        *       {
        *           error += errstr + ";";
        *       }
        *
        *       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.IsNullOrEmpty(mobile))
        *       {
        *           if (!reMobile.IsMatch(mobile))
        *           {
        *               error += "手机号码填写不正确,不要有特殊字符,[-]也不能包含;";
        *           }
        *       }
        *       member.Mobile = mobile;
        *       member.Email = dr["邮箱"].ToString().Trim();
        *       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
        *           {
        *               error += "生日和年龄必须填写一项或者两项均填写错误;";
        *           }
        *       }
        #endregion
        *       if (!string.IsNullOrEmpty(error))
        *       {
        *           if (!string.IsNullOrEmpty(error))
        *           {
        *               dr["Error"] = error.TrimEnd(';');
        *               error = string.Empty;
        *           }
        *       }
        *       else
        *       {
        #region 订单信息
        *           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 = string.Format("{0}岁{1}月{2}日{3}时", year, month, day, 0); ;//年龄字符串拼接 岁月日时
        *           _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) { _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 = mobile;
        *           }
        #endregion
        *           Hashtable htScan = new Hashtable();
        *           htScan.Add("isScan", true);
        *           htScan.Add("EnterByID", enterby);
        *           htScan.Add("EnterBy", username);
        *           bool result = registerservice.insertUpdateOrders("单位批量上传", "", true, productList, grouptestList, member, _orders, "", ref errstr, htScan);
        *           if (!result)
        *           {
        *               error = " 【Excel格式参照导入模版说明】";
        *
        *               dr["Error"] = error.TrimEnd(';');
        *           }
        *       }
        *
        *       Orderfiledetail filedetail = this.GetOrderfiledetail(dr, Orderfileheaderid);
        *       list.Add(filedetail);
        *   }
        *   if (list.Count > 0)
        *   {
        *      return detailservice.InsertOrderfiledetail(list, fileheader);
        *   }
        *   return false;
        *  }
        ****/

        /// <summary>
        /// 根据数据行 获取数据对象
        /// </summary>
        /// <param name="dr"></param>
        /// <returns></returns>
        private Orderfiledetail GetOrderfiledetail(DataRow dr, double?Orderfileheaderid)
        {
            Orderfiledetail filedetail = new Orderfiledetail();

            filedetail.Barcode           = dr["条码号"] != DBNull.Value ? string.Empty : dr["条码号"].ToString().Replace('_', ' ').Trim();;
            filedetail.Reason            = dr["Error"] == DBNull.Value ? string.Empty : dr["Error"].ToString();
            filedetail.Status            = 0;
            filedetail.Orderfileheaderid = Orderfileheaderid;
            filedetail.Createdate        = DateTime.Now;
            filedetail.Realname          = dr["姓名"] == DBNull.Value ? string.Empty : dr["姓名"].ToString();
            filedetail.Mobile            = dr["手机"] == DBNull.Value ? string.Empty : dr["手机"].ToString().Trim();
            filedetail.Idnumber          = dr["身份证"] == DBNull.Value ? string.Empty : dr["身份证"].ToString();
            return(filedetail);
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
 /// <summary>
 /// 添加订单明细
 /// </summary>
 /// <param name="orc"></param>
 public void InsertOrderfiledetail(Orderfiledetail orc)
 {
     orc.Orderfiledetailid = getSeqID("SEQ_ORDERFILEDETAIL");
     insert("Order.InsertOrderfiledetail", orc);
 }