Exemplo n.º 1
0
        public List <AirplainType> GetAirplainType()
        {
            List <AirplainType> listAirplainType = new List <AirplainType>();
            string sql = "select * from dbo.AirplainType";

            using (SqlConnection conn = new SqlConnection(strConnectionString))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand(sql, conn);
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }
                    SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                    while (rdr.Read())
                    {
                        AirplainType atype = new AirplainType();
                        //atype._id = rdr["_id"] != null ? rdr["_id"].ToString() : "";
                        atype.Code   = rdr["Code"] != null ? rdr["Code"].ToString() : "";
                        atype.TaxFee = decimal.Parse(rdr["TaxFee"] != null ? rdr["TaxFee"].ToString() : "0");
                        listAirplainType.Add(atype);
                    }
                    rdr.Close();
                }
                catch (SqlException ex)
                {
                    JoveZhao.Framework.Logger.WriteLog(JoveZhao.Framework.LogType.ERROR, "航班数据库查询[GetAirplainType]", ex);
                }
                catch (Exception e)
                {
                    JoveZhao.Framework.Logger.WriteLog(JoveZhao.Framework.LogType.ERROR, "航班数据库查询[GetAirplainType]", e);
                }
            }
            return(listAirplainType);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 补全数据
        /// </summary>
        /// <param name="avhData"></param>
        /// <param name="fdData"></param>
        /// <returns></returns>
        public AVHData BuQuanAVH(AVHData avhData, FDData fdData)
        {
            try
            {
                if (avhData.IbeData.Count > 0 && fdData.FdRow.Count > 0)
                {
                    // TestData test = new TestData();
                    List <AirplainType> listAirplainType = new List <AirplainType>();
                    try
                    {
                        //mgHelper.All<AirplainType>().ToList();//
                        listAirplainType = test.GetAirplainType();
                    }
                    catch (Exception)
                    {
                        listAirplainType = new List <AirplainType>();
                    }
                    //所有的baseCabin
                    List <BaseCabin> allBaseCabin = test.GetBaseCabin("");

                    decimal TaxFee = 0m;//机建费
                    for (int i = 0; i < avhData.IbeData.Count; i++)
                    {
                        //空舱位
                        if (avhData.IbeData[i].IBESeat == null || avhData.DicYSeatPrice == null)
                        {
                            continue;
                        }
                        //Y舱价格
                        if (!avhData.DicYSeatPrice.ContainsKey(avhData.IbeData[i].CarrierCode))
                        {
                            if (fdData.YFdRow.ContainsKey(avhData.IbeData[i].CarrierCode))
                            {
                                avhData.DicYSeatPrice.Add(avhData.IbeData[i].CarrierCode, fdData.YFdRow[avhData.IbeData[i].CarrierCode].SeatPrice);
                            }
                        }
                        //查找机建费
                        AirplainType airplainType = listAirplainType.Find(p => p.Code == avhData.IbeData[i].AirModel);
                        if (airplainType != null)
                        {
                            TaxFee = airplainType.TaxFee;
                        }
                        else
                        {
                            try
                            {
                                AirplainType _airplainType = new AirplainType()
                                {
                                    Code   = avhData.IbeData[i].AirModel,
                                    TaxFee = 50m
                                };
                                //补全机型机建
                                //mgHelper.Add<AirplainType>();
                                if (!test.ExistAirplainType(_airplainType.Code))
                                {
                                    test.ExecuteSQL(string.Format("insert into AirplainType(Code,TaxFee) values('{0}',{1})", _airplainType.Code, _airplainType.TaxFee));
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                        for (int j = 0; j < avhData.IbeData[i].IBESeat.Count; j++)
                        {
                            FdRow fdRow = fdData.FdRow.Where(p => p.CarrierCode == avhData.IbeData[i].CarrierCode && p.Seat == avhData.IbeData[i].IBESeat[j].Seat).FirstOrDefault();
                            if (fdRow != null)
                            {
                                //燃油
                                avhData.IbeData[i].ADultFuleFee = fdRow.ADultFuleFee;
                                avhData.IbeData[i].ChildFuleFee = fdRow.ADultFuleFee;
                                //机建费 从数据库中读取 暂时假数据
                                if (TaxFee != 0)
                                {
                                    avhData.IbeData[i].TaxFee = TaxFee;
                                }
                                //舱位价
                                avhData.IbeData[i].IBESeat[j].SeatPrice = fdRow.SeatPrice;
                                //折扣
                                avhData.IbeData[i].IBESeat[j].Rebate = fdRow.Rebate;
                            }
                            else
                            {
                                try
                                {
                                    //从数据库中获取
                                    //BaseCabin baseCabin = mgHelper.Query<BaseCabin>(p => p.CarrierCode == avhData.IbeData[i].CarrierCode && p.Code == avhData.IbeData[i].IBESeat[j].Seat).FirstOrDefault();
                                    //List<BaseCabin> baseCabinList = test.GetBaseCabin(string.Format(" CarrierCode='{0}' and Code='{1}' ", avhData.IbeData[i].CarrierCode, avhData.IbeData[i].IBESeat[j].Seat));
                                    List <BaseCabin> baseCabinList = allBaseCabin.Where(m => m.CarrierCode == avhData.IbeData[i].CarrierCode && m.Code == avhData.IbeData[i].IBESeat[j].Seat).ToList();
                                    BaseCabin        baseCabin     = null;
                                    if (baseCabinList != null && baseCabinList.Count > 0)
                                    {
                                        baseCabin = baseCabinList[0];
                                    }
                                    if (baseCabin != null && avhData.DicYSeatPrice.ContainsKey(avhData.IbeData[i].CarrierCode) && avhData.DicYSeatPrice[avhData.IbeData[i].CarrierCode] != 0m)
                                    {
                                        //折扣
                                        avhData.IbeData[i].IBESeat[j].Rebate = baseCabin.Rebate;
                                        //舱位价
                                        avhData.IbeData[i].IBESeat[j].SeatPrice = dataBill.MinusCeilTen((baseCabin.Rebate / 100) * avhData.DicYSeatPrice[avhData.IbeData[i].CarrierCode]);
                                    }
                                    fdRow = fdData.FdRow.Where(p => p.ADultFuleFee != 0).FirstOrDefault();
                                    //取这条航线的燃油 但不精确
                                    avhData.IbeData[i].ADultFuleFee = fdRow.ADultFuleFee;
                                    avhData.IbeData[i].ChildFuleFee = fdRow.ADultFuleFee;
                                    //机建费 从数据库中读取 暂时假数据
                                    avhData.IbeData[i].TaxFee = TaxFee;
                                }
                                catch (Exception)
                                {
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //记录日志
                log.WriteLog("BuQuanAVH", "异常信息:" + ex.Message + "\r\n");
            }
            return(avhData);
        }