예제 #1
0
        public int AddTravelPaper(string buyerBusinessman,
                                  string startTripNumber, string endTripNumber, string useOffice, string iataCode,
                                  string ticketCompanyName, string tripRemark)
        {
            string BusinessmanCode    = currentUser.Code;
            string BusinessmanName    = currentUser.BusinessmanName;
            int    dataCount          = -1;
            string strMsg             = string.Empty;
            string useBusinessmanCode = string.Empty;
            string useBusinessmanName = string.Empty;

            if (string.IsNullOrEmpty(buyerBusinessman))
            {
                strMsg = "分配商户名称或者商户号不能为空!";
            }
            else if (string.IsNullOrEmpty(BusinessmanCode))
            {
                strMsg = "供应商户号不能为空!";
            }
            else if (string.IsNullOrEmpty(BusinessmanName))
            {
                strMsg = "供应商户号不能为空!";
            }
            else if (string.IsNullOrEmpty(startTripNumber) ||
                     string.IsNullOrEmpty(endTripNumber) ||
                     startTripNumber.Trim().Length != 10 ||
                     endTripNumber.Trim().Length != 10
                     )
            {
                strMsg = "行程单号段数据不完整!";
            }
            else if (string.IsNullOrEmpty(useOffice))
            {
                strMsg = "行程单号终端号不能为空!";
            }
            else if (string.IsNullOrEmpty(iataCode))
            {
                strMsg = "航协号不能为空!";
            }
            else if (string.IsNullOrEmpty(ticketCompanyName))
            {
                strMsg = "填开单位不能为空!";
            }
            else
            {
                if (!string.IsNullOrEmpty(startTripNumber) && !string.IsNullOrEmpty(endTripNumber))
                {
                    int start = int.Parse(startTripNumber.Substring(6, 4));
                    int end   = int.Parse(endTripNumber.Substring(6, 4));
                    if (start > end)
                    {
                        strMsg = "行程单号段范围有误!";
                    }
                }
            }
            //判断商户号是否存在
            Businessman businessman = this.m_businessmanRepository.FindAll(p => p.Code == buyerBusinessman || p.Name == buyerBusinessman).FirstOrDefault();

            if (businessman == null)
            {
                strMsg = "分配商户号或者商户名称不存在!";
            }
            else
            {
                useBusinessmanCode = businessman.Code;
                useBusinessmanName = businessman.Name;
            }
            //useBusinessmanCode = "caigou";//businessman.Code;
            //useBusinessmanName = "采购";//businessman.Name;
            if (string.IsNullOrEmpty(useBusinessmanCode))
            {
                strMsg = "分配商户号或者商户名称不存在!";
            }
            if (string.IsNullOrEmpty(strMsg))
            {
                string StartCode = startTripNumber.Substring(0, 6);
                string start     = startTripNumber.Substring(6, 4);
                string end       = endTripNumber.Substring(6, 4);
                tripRemark = tripRemark.Replace("'", "");
                //分配行程单
                dataCount = unitOfWorkRepository.ExecuteCommand(
                    "EXEC [dbo].[TravelPaperImport] @p0,@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8,@p9,@p10,@p11,@p12 ",
                    "0",
                    StartCode,
                    start,
                    end,
                    useOffice,
                    iataCode,
                    ticketCompanyName,
                    BusinessmanCode,
                    BusinessmanName,
                    useBusinessmanCode,
                    useBusinessmanName,
                    tripRemark,
                    ""
                    );
                if (dataCount > 0)
                {
                    TravelGrantRecord travelGrantRecord = new TravelGrantRecord();
                    travelGrantRecord.BusinessmanCode    = BusinessmanCode;
                    travelGrantRecord.BusinessmanName    = BusinessmanName;
                    travelGrantRecord.UseBusinessmanCode = useBusinessmanCode;
                    travelGrantRecord.UseBusinessmanName = useBusinessmanName;
                    travelGrantRecord.GrantTime          = System.DateTime.Now;
                    travelGrantRecord.Office             = useOffice;
                    travelGrantRecord.TripCount          = int.Parse(end) - int.Parse(start) + 1;
                    travelGrantRecord.TripScope          = startTripNumber + "-" + endTripNumber;
                    travelGrantRecord.TripRemark         = tripRemark;
                    //添加发放记录
                    unitOfWorkRepository.PersistCreationOf(travelGrantRecord);
                    unitOfWork.Commit();
                }
            }
            if (!string.IsNullOrEmpty(strMsg))
            {
                throw new OrderCommException(strMsg);
            }
            return(dataCount);
        }