Beispiel #1
0
        /// <summary>
        /// 批量添加运价信息
        /// </summary>
        /// <param name="FreightInfoList">运价信息实体集合</param>
        /// <returns>返回1:添加成功</returns>
        public bool Add(IList <Model.TicketStructure.TicketFreightInfo> FreightInfoList)
        {
            bool IsResult = false;

            if (FreightInfoList != null && FreightInfoList.Count > 0)
            {
                EyouSoft.Model.TicketStructure.TicketFreightInfo tmpModel = (Model.TicketStructure.TicketFreightInfo)FreightInfoList[0];

                IList <EyouSoft.Model.TicketStructure.AvailablePackInfo> list = iBuyDal.GetAvailableInfo(DateTime.Now, tmpModel.Company.ID, tmpModel.RateType, tmpModel.NoGadHomeCityId).Where(item => (item.PackType == EyouSoft.Model.TicketStructure.PackageTypes.常规)).ToList();
                tmpModel = null;

                if (list != null && list.Count > 0)
                {
                    IList <EyouSoft.Model.TicketStructure.AvailablePackInfo> list1 = new List <EyouSoft.Model.TicketStructure.AvailablePackInfo>();

                    int count = 0;
                    foreach (EyouSoft.Model.TicketStructure.AvailablePackInfo AvailModel in list)
                    {
                        int AvailableNum = 0;
                        for (int i = count; i < FreightInfoList.Count; i++)
                        {
                            if (AvailableNum < AvailModel.AvailableNum)
                            {
                                EyouSoft.Model.TicketStructure.TicketFreightInfo FreightModel = FreightInfoList[i];
                                FreightModel.FreightBuyId = FreightModel.IsEnabled ? AvailModel.BuyId : string.Empty;
                                if (FreightModel.IsEnabled)
                                {
                                    AvailableNum++;
                                }
                                count++;
                            }
                            else
                            {
                                break;
                            }
                        }
                        EyouSoft.Model.TicketStructure.AvailablePackInfo AvailModel1 = new EyouSoft.Model.TicketStructure.AvailablePackInfo();
                        AvailModel1.BuyId        = AvailModel.BuyId;
                        AvailModel1.AvailableNum = AvailableNum;
                        AvailModel1.PackType     = AvailModel.PackType;
                        list1.Add(AvailModel1);
                        AvailModel1 = null;
                    }
                    IsResult = idal.AddFreightInfo(FreightInfoList) > 0 ? true : false;
                    if (IsResult)
                    {
                        IsResult = iBuyDal.SetAvailableNum(list1);
                    }
                    list1 = null;
                }
                list = null;
            }

            return(IsResult);
        }
Beispiel #2
0
        /// <summary>
        /// 添加运价信息
        /// </summary>
        /// <param name="model">运价信息实体</param>
        /// <returns>返回1:添加成功</returns>
        public bool Add(Model.TicketStructure.TicketFreightInfo model)
        {
            bool IsResult = false;

            if (model.IsEnabled)
            {
                IList <EyouSoft.Model.TicketStructure.AvailablePackInfo> list = iBuyDal.GetAvailableInfo(DateTime.Now, model.Company.ID, model.RateType, model.NoGadHomeCityId);
                if (list != null && list.Count > 0)
                {
                    EyouSoft.Model.TicketStructure.AvailablePackInfo AvailModel = (EyouSoft.Model.TicketStructure.AvailablePackInfo)list[0];
                    model.FreightBuyId = AvailModel.BuyId;

                    IList <EyouSoft.Model.TicketStructure.AvailablePackInfo> list1      = new List <EyouSoft.Model.TicketStructure.AvailablePackInfo>();
                    EyouSoft.Model.TicketStructure.AvailablePackInfo         AvaiModel1 = new EyouSoft.Model.TicketStructure.AvailablePackInfo();
                    AvaiModel1.BuyId        = AvailModel.BuyId;
                    AvaiModel1.PackType     = AvailModel.PackType;
                    AvaiModel1.AvailableNum = 1;
                    list1.Add(AvaiModel1);
                    AvaiModel1 = null;
                    AvailModel = null;

                    IsResult = idal.AddFreightInfo(model) > 0 ? true : false;
                    if (IsResult)
                    {
                        IsResult = iBuyDal.SetAvailableNum(list1);
                    }
                    list1 = null;
                }
                list = null;
            }
            else
            {
                model.FreightBuyId = string.Empty;
                IsResult           = idal.AddFreightInfo(model) > 0 ? true : false;
            }
            return(IsResult);
        }
Beispiel #3
0
        /// <summary>
        /// 修改运价信息
        /// </summary>
        /// <param name="model">运价信息实体</param>
        /// <returns>返回1:添加成功</returns>
        public bool Update(Model.TicketStructure.TicketFreightInfo model)
        {
            #region 当前运价修改之前的实体
            Model.TicketStructure.TicketFreightInfo OldModel = GetModel(model.Id);
            if (OldModel == null)
            {
                return(false);
            }
            #endregion

            #region 购买记录变量
            IList <EyouSoft.Model.TicketStructure.AvailablePackInfo> AvailableList = new List <EyouSoft.Model.TicketStructure.AvailablePackInfo>();//设置购买记录集合列表
            EyouSoft.Model.TicketStructure.AvailablePackInfo         AvaiModel1    = null;
            #endregion

            bool IsResult = false;
            //[新增时启用状态为关闭]
            if (model.IsEnabled && String.IsNullOrEmpty(model.FreightBuyId.Trim()))
            {
                #region 可用的套餐购买集合
                IList <EyouSoft.Model.TicketStructure.AvailablePackInfo> list = iBuyDal.GetAvailableInfo(DateTime.Now, model.Company.ID, model.RateType, model.NoGadHomeCityId);
                #endregion
                if (list != null && list.Count > 0)
                {
                    //常规的运价购买记录
                    IList <EyouSoft.Model.TicketStructure.AvailablePackInfo> CGeAvailabList = list.Where(Item => (Item.PackType == EyouSoft.Model.TicketStructure.PackageTypes.常规)).ToList();
                    //当前运价信息所属的类型的购买记录
                    IList <EyouSoft.Model.TicketStructure.AvailablePackInfo> CurrTypeAvailabList = list.Where(Item => (Item.PackType == model.BuyType)).ToList();
                    if ((CurrTypeAvailabList == null || CurrTypeAvailabList.Count == 0) &&
                        (CGeAvailabList == null || CGeAvailabList.Count == 0))
                    {
                        return(false); //
                    }
                    EyouSoft.Model.TicketStructure.AvailablePackInfo AvailModel = null;
                    if (CurrTypeAvailabList != null && CurrTypeAvailabList.Count > 0) //当前的购买类型的优先级高
                    {
                        AvailModel = CurrTypeAvailabList[0];
                    }
                    else
                    {
                        AvailModel = CGeAvailabList[0];
                    }
                    CurrTypeAvailabList     = null;
                    CGeAvailabList          = null;
                    model.FreightBuyId      = AvailModel.BuyId;
                    AvaiModel1              = new EyouSoft.Model.TicketStructure.AvailablePackInfo();
                    AvaiModel1.BuyId        = AvailModel.BuyId;
                    AvaiModel1.PackType     = AvailModel.PackType;
                    AvaiModel1.AvailableNum = 1;//注:[此处设置为1在数据层处理为-1]
                    AvailableList.Add(AvaiModel1);
                    AvaiModel1 = null;
                    AvailModel = null;
                    list       = null;
                }
                else
                {
                    return(false); //当前没有可用的运价条数
                }
            }
            else if (model.IsEnabled != OldModel.IsEnabled && model.FreightBuyId.Trim() != "")
            {
                AvaiModel1          = new EyouSoft.Model.TicketStructure.AvailablePackInfo();
                AvaiModel1.BuyId    = model.FreightBuyId;
                AvaiModel1.PackType = model.BuyType;
                if (model.IsEnabled)
                {
                    AvaiModel1.AvailableNum = 1;//注:[此处设置为-1在数据层处理为+1]
                }
                else
                {
                    AvaiModel1.AvailableNum = -1;
                }
                AvailableList.Add(AvaiModel1);
                AvaiModel1 = null;
            }
            OldModel = null;
            IsResult = idal.UpdateFreightInfo(model) > 0 ? true : false;
            if (IsResult && AvailableList.Count > 0)
            {
                IsResult = iBuyDal.SetAvailableNum(AvailableList);
            }
            AvailableList = null;
            return(IsResult);
        }
Beispiel #4
0
        /// <summary>
        /// 获取可用的常规运价套餐列表
        /// </summary>
        /// <param name="StartDate">开始时间</param>
        /// <param name="CompanyId">供应商编号 =""返回全部</param>
        /// <param name="RateType">业务类型 =null返回全部</param>
        /// <param name="HomeCityId">起始地编号</param>
        /// <returns>可用的常规运价套餐列表</returns>
        public virtual IList <EyouSoft.Model.TicketStructure.AvailablePackInfo> GetAvailableInfo(DateTime?StartDate, string CompanyId, EyouSoft.Model.TicketStructure.RateType?RateType, int HomeCityId)
        {
            DbCommand dc = null;
            IList <EyouSoft.Model.TicketStructure.AvailablePackInfo> list = new List <EyouSoft.Model.TicketStructure.AvailablePackInfo>();

            #region 公用查询参数设置
            StringBuilder strWhere = new StringBuilder();
            //当前时间
            if (StartDate.HasValue)
            {
                strWhere.AppendFormat(" and datediff(dd,'{0}',startmonth)<=0 and datediff(dd,'{0}',endmonth)>=0 ", StartDate.Value.ToString());
            }
            if (!string.IsNullOrEmpty(CompanyId))
            {
                strWhere.AppendFormat(" and CompanyId='{0}' ", CompanyId);
            }
            if (RateType.HasValue)
            {
                strWhere.AppendFormat(" and RateType={0} ", (int)RateType.Value);
            }
            #endregion

            #region 可用的非常规[套餐,促销]运价套餐信息集合
            StringBuilder strQuery = new StringBuilder();
            strQuery.Append(strWhere.ToString());
            dc = this._database.GetSqlStringCommand(string.Format(Sql_TicketFreightBuyLog_GetAvailablePackInfo, strQuery.Length > 0 ? strQuery.ToString() : ""));
            using (IDataReader dr = DbHelper.ExecuteReader(dc, this._database))
            {
                while (dr.Read())
                {
                    EyouSoft.Model.TicketStructure.AvailablePackInfo model = new EyouSoft.Model.TicketStructure.AvailablePackInfo();
                    model.BuyId        = dr[0].ToString();
                    model.AvailableNum = dr.GetInt32(1);
                    if (!dr.IsDBNull(2))
                    {
                        model.PackType = (EyouSoft.Model.TicketStructure.PackageTypes) int.Parse(dr.GetByte(2).ToString());
                    }
                    list.Add(model);
                    model = null;
                }
            }
            dc = null;
            #endregion

            #region 可用的常规运价套餐信息集合
            dc = this._database.GetSqlStringCommand(string.Format(Sql_TicketFreightBuyLog_GetAvailableInfo, strWhere.Length > 0?strWhere.ToString():""));
            using (IDataReader dr = DbHelper.ExecuteReader(dc, this._database))
            {
                while (dr.Read())
                {
                    EyouSoft.Model.TicketStructure.AvailablePackInfo model = new EyouSoft.Model.TicketStructure.AvailablePackInfo();
                    model.BuyId        = dr[0].ToString();
                    model.AvailableNum = dr.GetInt32(1);
                    if (!dr.IsDBNull(2))
                    {
                        model.PackType = (EyouSoft.Model.TicketStructure.PackageTypes) int.Parse(dr.GetByte(2).ToString());
                    }
                    list.Add(model);
                    model = null;
                }
            }
            #endregion

            return(list);
        }