zoukankan      html  css  js  c++  java
  • 解析机票舱位和子舱位方法

    public static string GetSeats(string _f_az, string _s_az, string _airCom, string _trip, string _date, decimal _yPrice)
    {
    // SA--Q1SA--AAAS-SS-AS-SQ-A-
    // 1-8: number of seat; A: seat number >= 9
    GetAirSeats(_airCom, _trip, _date, _yPrice); // get seat codes & discount
    string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string airSeats = "";
    try
    {
    airSeats = HTAirSeat[_airCom + "-" + _trip].ToString();
    }
    catch
    {
    airSeats = "A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0";
    }
    ArrayList al = new ArrayList();
    for (int i = 0; i < _f_az.Length; i++)
    {
    string c = _f_az.Substring(i, 1);
    string _s = s.Substring(i, 1);
    if (c.MatchReg(@"^A|[1-8]{1}$"))
    {
    try
    {
    al.Add(_s + "=" + airSeats.Substring(airSeats.IndexOf(_s + "=")).Split(',')[0].Split('=')[1] + "=" + c);

    // 子舱位
    if (_s_az != "" && _s_az.IndexOf(_s) != -1)
    {
    string saz = _s_az.Substring(_s_az.IndexOf(_s), 2);
    al.Add(saz + "=" + airSeats.Substring(airSeats.IndexOf(saz + "=")).Split(',')[0].Split('=')[1] + "=" + c);
    }
    }
    catch
    {
    continue;
    }
    }
    }
    if (al.Count == 0)
    {
    return "";
    }
    al.Sort(new Common.SeatComparer());
    string[] gs = new string[al.Count];
    al.CopyTo(gs);
    al = null;
    return gs.JOIN(",");
    }

    public class SeatComparer : IComparer
    {
    // Calls CaseInsensitiveComparer.Compare with the parameters reversed.
    int IComparer.Compare(Object x, Object y)
    {
    decimal X = Convert.ToDecimal((x.ToString().Split('=')[1]));
    decimal Y = Convert.ToDecimal((y.ToString().Split('=')[1]));
    return X == Y ? 0 : (X > Y ? 1 : -1);
    }
    }

  • 相关阅读:
    HTML 样式表
    HTML笔记(框架)
    HTML笔记1
    SQL server 笔记9(备份还原触发器事务三范式)
    拦截器传参问题
    MethodFilterInterceptor(方法拦截器)配置excludeMethors
    js基础学习笔记(五)
    js基础学习笔记(四)
    笔记:CSS常用中文字体英文名称对照表
    推荐:掌握单页网站设计的5大技巧(转)
  • 原文地址:https://www.cnblogs.com/taomylife/p/3424664.html
Copyright © 2011-2022 走看看