Ejemplo n.º 1
0
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        Bd_Air_Fares fares = null;

        if (Request.QueryString["Id"] != null && Request.QueryString["Id"].ToString() != "")
        {
            fares = baseDataManage.CallMethod("Bd_Air_Fares", "GetById", null, new object[] { ViewState["Id"].ToString() }) as Bd_Air_Fares;
        }
        else
        {
            fares = new Bd_Air_Fares();
        }
        fares.FromCityName = txtFromCityName.Text.Trim().Replace("'", "");
        fares.FromCityCode = txtFromCityCode.Text.Trim().Replace("'", "");
        fares.ToCityName   = txtToCityName.Text.Trim().Replace("'", "");
        fares.ToCityCode   = txtToCityCode.Text.Trim().Replace("'", "");
        fares.FareFee      = decimal.Parse(txtFareFee.Text.Trim());
        fares.Mileage      = int.Parse(txtMileage.Text.Trim());
        fares.CarryCode    = txtCarryCode.Text.Trim().Replace("'", "");
        fares.EffectTime   = DateTime.Parse(txtEffectTime.Text.Trim());
        fares.InvalidTime  = DateTime.Parse(txtInvalidTime.Text.Trim());
        if (ddlIsDomestic.SelectedIndex == 0)
        {
            fares.IsDomestic = 1;
        }
        else
        {
            fares.IsDomestic = 2;
        }
        if (Request.QueryString["Id"] != null && Request.QueryString["Id"].ToString() != "")
        {
            //if (Manage.Update(fares))
            bool UpdateSuc = (bool)baseDataManage.CallMethod("Bd_Air_Fares", "Update", null, new object[] { fares });
            if (UpdateSuc)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(), "showdialog3('保存成功!');", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(), "showdialog('保存失败!');", true);
            }
        }
        else
        {
            bool InsertSuc = (bool)baseDataManage.CallMethod("Bd_Air_Fares", "Insert", null, new object[] { fares });
            //if (Manage.Insert(fares))
            if (InsertSuc)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(), "showdialog3('添加成功!');", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(), "showdialog('添加失败!');", true);
            }
        }
    }
Ejemplo n.º 2
0
    private void FaresInfoBind()
    {
        //Bd_Air_Fares fares = Manage.GetById(ViewState["Id"].ToString());
        Bd_Air_Fares fares = baseDataManage.CallMethod("Bd_Air_Fares", "GetById", null, new object[] { ViewState["Id"].ToString() }) as Bd_Air_Fares;

        txtFromCityName.Text = fares.FromCityName;
        txtFromCityCode.Text = fares.FromCityCode;
        txtToCityName.Text   = fares.ToCityName;
        txtToCityCode.Text   = fares.ToCityCode;
        txtFareFee.Text      = fares.FareFee.ToString();
        txtMileage.Text      = fares.Mileage.ToString();
        txtCarryCode.Text    = fares.CarryCode;
        txtEffectTime.Text   = fares.EffectTime.ToString().Split(' ')[0];
        txtInvalidTime.Text  = fares.InvalidTime.ToString().Split(' ')[0];
        if (fares.IsDomestic == 1)
        {
            ddlIsDomestic.SelectedIndex = 0;
        }
        else
        {
            ddlIsDomestic.SelectedIndex = 1;
        }
    }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新数据库的舱位运价
        /// </summary>
        /// <param name="FD">运价结果信息</param>
        public static void UpdateDataBasePriceInfo(FDInfo FD)
        {
            BaseDataManage Manage = new BaseDataManage(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\Dal.dll");

            #region 航线舱位价格数据处理
            //删除航线舱位价格数据
            string tmpSQL  = " FromCityCode='" + FD.FromCity + "' and ToCityCode='" + FD.ToCity + "' ";
            bool   DelFlag = (bool)(Manage.CallMethod("Bd_Air_CabinDiscount", "DeleteBySQL", null, new object[] { tmpSQL }));

            if (!DelFlag)
            {
                Log.Record("UpdateClassPrice.log", "UpdateDataBasePriceInfo:处理出现错误!删除Bd_Air_CabinDiscount数据:" +
                           FD.FromCity + "|" + FD.ToCity);
                return;
            }

            //循环插入数据
            for (int i = 0; i < FD.ClassPriceList.Count; i++)
            {
                try
                {
                    Bd_Air_CabinDiscount tmpCabinDiscount = new Bd_Air_CabinDiscount();
                    tmpCabinDiscount.AirCode = FD.ClassPriceList[i].CarrierCode;

                    tmpCabinDiscount.Cabin = FD.ClassPriceList[i].ClassCode;

                    tmpCabinDiscount.CabinName = FD.ClassPriceList[i].ClassLevel;

                    tmpCabinDiscount.CabinPrice = decimal.Parse(FD.ClassPriceList[i].ClassPrice);

                    tmpCabinDiscount.FromCityCode = FD.FromCity;

                    tmpCabinDiscount.ToCityCode = FD.ToCity;

                    tmpCabinDiscount.IsGN = 0;

                    //添加数据
                    bool AddFlag = (bool)Manage.CallMethod("Bd_Air_CabinDiscount", "Insert", null, new object[] { tmpCabinDiscount });

                    if (!AddFlag)
                    {
                        Log.Record("UpdateClassPrice.log", "UpdateDataBasePriceInfo:处理出现错误!添加Bd_Air_CabinDiscount数据:" +
                                   FD.ClassPriceList[i].CarrierCode + "|" + FD.ClassPriceList[i].ClassCode + "|" + FD.FromCity + "|" + FD.ToCity + "|" + FD.ClassPriceList[i].ClassPrice);
                    }
                }
                catch (Exception ex)
                {
                    Log.Record("UpdateClassPrice.log", ex, "UpdateDataBasePriceInfo:处理出现错误!添加Bd_Air_CabinDiscount数据");
                }
            }
            #endregion 航线舱位价格数据处理


            #region 航线价格数据处理
            //删除航线舱位价格数据
            tmpSQL  = " FromCityCode='" + FD.FromCity + "' and ToCityCode='" + FD.ToCity + "' ";
            DelFlag = (bool)(Manage.CallMethod("Bd_Air_Fares", "DeleteBySQL", null, new object[] { tmpSQL }));

            if (!DelFlag)
            {
                Log.Record("UpdateClassPrice.log", "UpdateDataBasePriceInfo:处理出现错误!删除Bd_Air_Fares航线价格数据:" +
                           FD.FromCity + "|" + FD.ToCity);
                return;
            }

            //循环插入数据
            for (int i = 0; i < FD.FullPriceList.Count; i++)
            {
                try
                {
                    Bd_Air_Fares tmpAirFares = new Bd_Air_Fares();

                    tmpAirFares.CarryCode = FD.FullPriceList[i].carrier;

                    tmpAirFares.FromCityCode = FD.FromCity;

                    tmpAirFares.ToCityCode = FD.ToCity;

                    tmpAirFares.FareFee = decimal.Parse(FD.FullPriceList[i].fullPrice);

                    tmpAirFares.IsDomestic = 0;

                    tmpAirFares.Mileage = int.Parse(FD.Mileage);

                    //添加数据
                    bool AddFlag = (bool)Manage.CallMethod("Bd_Air_Fares", "Insert", null, new object[] { tmpAirFares });

                    if (!AddFlag)
                    {
                        Log.Record("UpdateClassPrice.log", "UpdateDataBasePriceInfo:处理出现错误!添加Bd_Air_Fares数据:" +
                                   FD.FullPriceList[i].carrier + "|" + FD.FullPriceList[i].fullPrice + "|" + FD.FromCity + "|" + FD.ToCity);
                    }
                }
                catch (Exception ex)
                {
                    Log.Record("UpdateClassPrice.log", ex, "UpdateDataBasePriceInfo:处理出现错误!添加Bd_Air_Fares数据");
                }
            }
            #endregion 航线价格数据处理
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 更新票价处理
        /// </summary>
        public static void AutoUpdate()
        {
            string StartTime = m_UpdatePriceWorkInfo.beginendtime.Split('|')[0];
            string EndTime   = m_UpdatePriceWorkInfo.beginendtime.Split('|')[1];

            while (true)
            {
                try
                {
                    #region 自动更新处理

                    WebManage.ServerIp   = m_UpdatePriceWorkInfo.serverip;
                    WebManage.ServerPort = m_UpdatePriceWorkInfo.serverport;

                    //如果指定了出发到达城市,则直接调用更新价格
                    if ((m_UpdatePriceWorkInfo.fromcityflag) && (m_UpdatePriceWorkInfo.tocityflag))
                    {
                        UpdatePrice(m_UpdatePriceWorkInfo.fromcity, m_UpdatePriceWorkInfo.tocity);

                        m_UpdatePriceWorkInfo.EndFlag = true;
                        m_UpdatePriceWorkInfo.EndTime = DateTime.Now;

                        //调用label的invoke方法
                        tmpFrm.WriteLog("价格更新完毕!\r\n");

                        break;
                    }
                    else
                    {
                        #region 获取待更新的数据集

                        string tmpSQL = " 1=1 ";

                        //检查上次
                        if (m_UpdatePriceWorkInfo.startfromtocityid != "")
                        {
                            tmpSQL += " and id>='" + m_UpdatePriceWorkInfo.startfromtocityid + "' ";
                        }

                        //检查是否指定了出发城市
                        if (m_UpdatePriceWorkInfo.fromcityflag)
                        {
                            tmpSQL += " and FromCityCode='" + m_UpdatePriceWorkInfo.fromcity + "'";
                        }

                        //检查是否指定了到达城市
                        if (m_UpdatePriceWorkInfo.tocityflag)
                        {
                            tmpSQL += " and ToCityCode='" + m_UpdatePriceWorkInfo.tocity + "'";
                        }

                        tmpSQL += " order by id";

                        BaseDataManage      Manage = new BaseDataManage(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\Dal.dll");
                        List <Bd_Air_Fares> list   = Manage.CallMethod("Bd_Air_Fares", "GetList", null, new object[] { tmpSQL }) as List <Bd_Air_Fares>;

                        #endregion 获取待更新的数据集

                        for (int i = 0; i < list.Count; i++)
                        {
                            //获取待操作的记录
                            Bd_Air_Fares tmpBd_Air_Fares = list[i];
                            //赋值当前操作的记录id
                            m_UpdatePriceWorkInfo.startfromtocityid = tmpBd_Air_Fares.id.ToString();

                            //出发城市
                            string tmpfromcity = tmpBd_Air_Fares.FromCityCode;
                            //到达城市
                            string tmptocity = tmpBd_Air_Fares.ToCityCode;

                            UpdatePrice(tmpfromcity, tmptocity);

                            #region 检查自动更新时间限制
                            if (m_UpdatePriceWorkInfo.timeflag)
                            {
                                //检查当前开始、结束时间
                                string tmpNowTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                                string tmpStartTime = DateTime.Now.ToString("yyyy-MM-dd ") + StartTime;
                                string tmpEndTime   = DateTime.Now.ToString("yyyy-MM-dd ") + EndTime;
                                if (!CheckIfInAutoUpdateTime(DateTime.Parse(tmpStartTime), DateTime.Parse(tmpEndTime)))
                                {
                                    //不在自动更新时间内,则退出线程处理
                                    m_UpdatePriceWorkInfo.PreEndTime = tmpNowTime;

                                    //调用label的invoke方法
                                    tmpFrm.WriteLog("更新到:" + tmpfromcity + tmptocity + "\r\n当前时间已经超过结束时间,中止更新等待下次自动更新!\r\n");

                                    break;
                                }
                            }
                            #endregion 检查自动更新时间限制
                        }
                        m_UpdatePriceWorkInfo.EndFlag = true;
                        m_UpdatePriceWorkInfo.EndTime = DateTime.Now;

                        //调用label的invoke方法
                        tmpFrm.WriteLog("价格更新完毕!\r\n");

                        break;
                    }

                    #endregion 自动更新处理

                    #region 检查自动更新时间限制
                    if (m_UpdatePriceWorkInfo.timeflag)
                    {
                        //检查当前开始、结束时间
                        string tmpNowTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                        string tmpStartTime = DateTime.Now.ToString("yyyy-MM-dd ") + StartTime;
                        string tmpEndTime   = DateTime.Now.ToString("yyyy-MM-dd ") + EndTime;
                        if (!CheckIfInAutoUpdateTime(DateTime.Parse(tmpStartTime), DateTime.Parse(tmpEndTime)))
                        {
                            //不在自动更新时间内,则退出线程处理

                            //调用label的invoke方法
                            tmpFrm.WriteLog("当前时间已经超过结束时间,中止更新等待下次自动更新!\r\n");

                            break;
                        }
                    }
                    #endregion 检查自动更新时间限制
                }
                catch (Exception ex)
                {
                    //记录错误日志
                    Log.Record("UpdateClassPrice.log", ex, "AutoUpdate:自动更新票价线程处理出错!");
                }
            }
        }