예제 #1
0
        /// <summary>
        /// 修改航空公司信息
        /// </summary>
        /// <param name="vm"></param>
        public string ModiflyAriLine(AirLine vm)
        {
            string         path    = System.AppDomain.CurrentDomain.BaseDirectory + "config\\AirLineManage.xml";
            List <AirLine> list    = BPiaoBao.Common.XmlHelper.XmlDeserializeFromFile <List <AirLine> >(path, Encoding.Default);
            AirLine        airLine = list.Where(x => x.CarrayCode.Equals(vm.CarrayCode) & x.CarrayName.Equals(vm.CarrayName) & x.CarrayAbbreviation.Equals(vm.CarrayAbbreviation)).FirstOrDefault();

            if (airLine != null)
            {
                if (airLine.Id != vm.Id)
                {
                    return("此航空公司已存在!");
                }
            }
            list.ForEach(x =>
            {
                if (x.Id == vm.Id)
                {
                    x.CarrayName         = vm.CarrayName;
                    x.CarrayCode         = vm.CarrayCode;
                    x.CarrayAbbreviation = vm.CarrayAbbreviation;
                    x.B2BStatus          = vm.B2BStatus;
                    x.BSPStatus          = vm.BSPStatus;
                    x.AriLineStatus      = vm.AriLineStatus;
                    x.AriLineType        = vm.AriLineType;
                }
            });
            BPiaoBao.Common.XmlHelper.XmlSerializeToFile(list, path, Encoding.Default);
            InitSystemSwitch.InitAirSystem();
            return("成功");
        }
예제 #2
0
        /// <summary>
        /// 航空公司新增
        /// </summary>
        /// <param name="vm"></param>
        public string AriLineSave(AirLine vm)
        {
            if (vm == null)
            {
                return("设置信息失败");
            }
            List <AirLine> list = null;
            string         path = System.AppDomain.CurrentDomain.BaseDirectory + "config\\AirLineManage.xml";

            if (!File.Exists(path))
            {
                vm.Id = 1;
                list  = new List <AirLine>();
                list.Add(vm);
                BPiaoBao.Common.XmlHelper.XmlSerializeToFile(list, path, Encoding.Default);
            }
            else
            {
                list = BPiaoBao.Common.XmlHelper.XmlDeserializeFromFile <List <AirLine> >(path, Encoding.Default);
                if (list.Where(x => x.CarrayCode.Equals(vm.CarrayCode) & x.CarrayName.Equals(vm.CarrayName)).FirstOrDefault() != null)
                {
                    return("此航空公司已存在!");
                }
                vm.Id = list.Max(x => x.Id).HasValue ? list.Max(x => x.Id) + 1 : 1;
                list.Add(vm);
                BPiaoBao.Common.XmlHelper.XmlSerializeToFile(list, path, Encoding.Default);
            }
            InitSystemSwitch.InitAirSystem();
            return("成功");
        }
예제 #3
0
        /// <summary>
        ///  删除航空公司
        /// </summary>
        /// <param name="CarrayCode"></param>
        public void DeleteAriLine(int Id)
        {
            string         path = System.AppDomain.CurrentDomain.BaseDirectory + "config\\AirLineManage.xml";
            List <AirLine> list = BPiaoBao.Common.XmlHelper.XmlDeserializeFromFile <List <AirLine> >(path, Encoding.Default);

            list.Remove(list.Where(x => x.Id == Id).FirstOrDefault());
            BPiaoBao.Common.XmlHelper.XmlSerializeToFile(list, path, Encoding.Default);
            InitSystemSwitch.InitAirSystem();
        }