private void CabnInDiscountInfoBind()
    {
        //获取实体
        Bd_Air_CabinDiscount cd = baseDataManage.CallMethod("Bd_Air_CabinDiscount", "GetById", null, new object[] { ViewState["Id"].ToString() }) as Bd_Air_CabinDiscount;

        txtCabin.Text = cd.Cabin;

        txtFormCity.Text     = cd.FromCity;
        txtFromCityCode.Text = cd.FromCityCode;
        txtToCity.Text       = cd.ToCity;
        txtToCityCode.Text   = cd.ToCityCode;
        txtBeginTime.Value   = cd.BeginTime.ToString().Split(' ')[0];
        txtEndTime.Value     = cd.EndTime.ToString().Split(' ')[0];
        txtAirPortCode.Text  = cd.AirCode;
        txtAirPortName.Text  = cd.AirName;
        txtDiscountRate.Text = cd.CabinPrice.ToString();
        if (cd.IsGN == 0)
        {
            ddlIsGN.SelectedIndex = 0;
        }
        if (cd.IsGN == 1)
        {
            ddlIsGN.SelectedIndex = 1;
        }
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        Bd_Air_CabinDiscount cd = null;

        if (Request.QueryString["Id"] != null && Request.QueryString["Id"].ToString() != "")
        {
            //获取实体
            cd = baseDataManage.CallMethod("Bd_Air_CabinDiscount", "GetById", null, new object[] { ViewState["Id"].ToString() }) as Bd_Air_CabinDiscount;
        }
        else
        {
            cd = new Bd_Air_CabinDiscount();
        }
        if (Convert.ToDateTime(txtBeginTime.Value).CompareTo(Convert.ToDateTime(txtEndTime.Value)) >= 0)
        {
            ScriptManager.RegisterStartupScript(this, GetType(), "", "showdialog('起始时间不能大于或等于终止时间!');", true);
            return;
        }
        decimal num = 0m;

        if (!decimal.TryParse(txtDiscountRate.Text.ToString(), out num))
        {
            ScriptManager.RegisterStartupScript(this, GetType(), "", "showdialog('舱位价格只能为数字!');", true);
            return;
        }
        cd.Cabin        = txtCabin.Text.ToUpper().Trim().Replace("'", "");
        cd.FromCity     = txtFormCity.Text.Trim().Replace("'", "");
        cd.FromCityCode = txtFromCityCode.Text.ToUpper().Trim().Replace("'", "");
        cd.ToCity       = txtToCity.Text.Trim().Replace("'", "");
        cd.ToCityCode   = txtToCityCode.Text.ToUpper().Trim().Replace("'", "");
        cd.BeginTime    = DateTime.Parse(txtBeginTime.Value.Replace("'", ""));
        cd.EndTime      = DateTime.Parse(txtEndTime.Value.Replace("'", ""));
        cd.IsGN         = int.Parse(ddlIsGN.SelectedValue.Replace("'", ""));
        cd.AddDate      = DateTime.Now;
        cd.AirCode      = txtAirPortCode.Text.Trim().Replace("'", "");
        cd.AirName      = txtAirPortName.Text.Trim().Replace("'", "");
        cd.CabinPrice   = decimal.Parse(txtDiscountRate.Text.ToString());
        if (Request.QueryString["Id"] != null && Request.QueryString["Id"].ToString() != "")
        {
            //修改
            bool UpdateSuc = (bool)baseDataManage.CallMethod("Bd_Air_CabinDiscount", "Update", null, new object[] { cd });
            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_CabinDiscount", "Insert", null, new object[] { cd });
            if (InsertSuc)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(), "showdialog3('添加成功!');", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(), "showdialog('添加失败!');", true);
            }
        }
    }
Exemple #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 航线价格数据处理
        }