예제 #1
0
        public static void UpdateAirport(AirportView airportView, string account)
        {
            var airport         = Airport.GetAirport(airportView);
            var originalAirport = QueryAirport(airport.Code);

            if (null == originalAirport)
            {
                throw new ChinaPay.Core.CustomException("原机场不存在");
            }
            var sameNameAirport = QueryAirportByName(airport.Name);

            if (sameNameAirport != null && sameNameAirport.Code.Value != airport.Code.Value)
            {
                throw new ChinaPay.Core.Exception.KeyRepeatedException("名称[" + airport.Name + "]已存在");
            }
            var sameShortNameAirport = QueryAirportByShortName(airport.ShortName);

            if (sameShortNameAirport != null && sameShortNameAirport.Code.Value != airport.Code.Value)
            {
                throw new ChinaPay.Core.Exception.KeyRepeatedException("简称[" + airport.ShortName + "]已存在");
            }
            var originalContent = originalAirport.ToString();

            AirportCollection.Instance.Update(airport.Code, airport);
            saveUpdateLog("机场", originalContent, airport.ToString(), airport.Code.Value, account);
        }
        public IActionResult Put([FromBody] AirportView item)
        {
            if (item == null || !ModelState.IsValid)
            {
                return(BadRequest());
            }

            var resp = _Service.Update(item);

            return(Ok(resp));
        }
예제 #3
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (Request.QueryString["action"] != null)
     {
         string        locationCode  = string.Empty;
         LocationLevel locationLevel = LocationLevel.City;
         if (this.ddlCounty.SelectedValue != "0")
         {
             locationCode  = this.ddlCounty.SelectedValue;
             locationLevel = LocationLevel.County;
         }
         else
         {
             locationCode = this.ddlCity.SelectedValue;
         }
         AirportView airportView = new AirportView()
         {
             Code          = this.txtAirportCode.Text.Trim(),
             Name          = this.txtAirportName.Text.Trim(),
             ShortName     = this.txtAirportShortName.Text.Trim(),
             Valid         = this.ddlAirportStatus.SelectedValue == "T" ? true : false,
             LocationCode  = locationCode,
             LocationLevel = locationLevel,
             IsMain        = this.rdoOK.Checked == true ? true : false
         };
         if (Request.QueryString["action"].ToString() == "add")
         {
             try
             {
                 FoundationService.AddAirport(airportView, CurrentUser.UserName);
                 RegisterScript("alert('添加成功!'); window.location.href='Airport.aspx'");
             } catch (Exception ex) {
                 ShowExceptionMessage(ex, "添加");
             }
         }
         else
         {
             try
             {
                 FoundationService.UpdateAirport(airportView, CurrentUser.UserName);
                 RegisterScript("alert('修改成功!'); window.location.href='Airport.aspx?Search=Back'");
             } catch (Exception ex) {
                 ShowExceptionMessage(ex, "修改");
             }
         }
     }
 }
예제 #4
0
파일: Airport.cs 프로젝트: 842549829/Pool
 internal static Airport GetAirport(AirportView airportView)
 {
     if (null == airportView)
     {
         throw new ArgumentNullException("airportView");
     }
     airportView.Validate();
     return(new Airport(airportView.Code.Trim())
     {
         Name = ChinaPay.Utility.StringUtility.Trim(airportView.Name),
         ShortName = ChinaPay.Utility.StringUtility.Trim(airportView.ShortName),
         Valid = airportView.Valid,
         LocationCode = ChinaPay.Utility.StringUtility.Trim(airportView.LocationCode),
         LocationLevel = airportView.LocationLevel,
         IsMain = airportView.IsMain
     });
 }
예제 #5
0
        public static void AddAirport(AirportView airportView, string account)
        {
            var airport = Airport.GetAirport(airportView);

            if (QueryAirport(airport.Code) != null)
            {
                throw new ChinaPay.Core.Exception.KeyRepeatedException("代码[" + airport.Code + "]已存在");
            }
            if (QueryAirportByName(airport.Name) != null)
            {
                throw new ChinaPay.Core.Exception.KeyRepeatedException("名称[" + airport.Name + "]已存在");
            }
            if (QueryAirportByShortName(airport.ShortName) != null)
            {
                throw new ChinaPay.Core.Exception.KeyRepeatedException("简称[" + airport.ShortName + "]已存在");
            }
            AirportCollection.Instance.Add(airport.Code, airport);
            saveAddLog("机场", airport.ToString(), airport.Code.Value, account);
        }
예제 #6
0
 protected void gvAirport_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "opdate")
     {
         string code = e.CommandArgument.ToString();
         ChinaPay.B3B.Service.Foundation.Domain.Airport air = FoundationService.QueryAirport(code);
         if (air == null)
         {
             return;
         }
         AirportView airportView = new AirportView()
         {
             Code          = code.Trim(),
             Valid         = air.Valid == true ? false : true,
             Name          = air.Name,
             ShortName     = air.ShortName,
             LocationCode  = air.LocationCode,
             IsMain        = air.IsMain,
             LocationLevel = air.LocationLevel
         };
         try {
             FoundationService.UpdateAirport(airportView, CurrentUser.UserName);
             if (air.Valid)
             {
                 RegisterScript("alert('禁用成功!'); window.location.href='Airport.aspx?Search=Back';");
             }
             else
             {
                 RegisterScript("alert('启用成功!'); window.location.href='Airport.aspx?Search=Back';");
             }
         } catch (Exception ex) {
             ShowExceptionMessage(ex, air.Valid ? "禁用" : "启用");
             return;
         }
         refresh();
     }
 }