Exemplo n.º 1
0
        private List <InvoiceName> ExtractNames(List <Loop> n1Loop)
        {
            var names = new List <InvoiceName>();

            foreach (var n1 in n1Loop)
            {
                var n2 = n1.Segments.FirstOrDefault(x => x.SegmentId == "N2");
                var n3 = n1.Segments.FirstOrDefault(x => x.SegmentId == "N3");
                var n4 = n1.Segments.FirstOrDefault(x => x.SegmentId == "N4");

                var name = new InvoiceName();

                name.N101_EntityIdentifierCode = n1.GetElement(1);
                name.N102_Name = n1.GetElement(2);
                name.N103_IdentificationCodeQualifier = n1.GetElement(3);
                name.N104_IdentificationCode          = n1.GetElement(4);

                if (n2 != null)
                {
                    name.N201_Name = n2.GetElement(1);
                    name.N202_Name = n2.GetElement(2);
                }

                if (n3 != null)
                {
                    name.N301_Address = n3.GetElement(1);
                    name.N302_Address = n3.GetElement(2);
                }

                if (n4 != null)
                {
                    name.N401_City       = n4.GetElement(1);
                    name.N402_State      = n4.GetElement(2);
                    name.N403_PostalCode = n4.GetElement(3);
                    name.N404_Country    = n4.GetElement(4);
                }

                names.Add(name);
            }
            return(names);
        }
        public List <InvoiceName> GetAllInvoiceNamesSummary()
        {
            List <InvoiceName> iNames = new List <InvoiceName>();

            try
            {
                using (SqlConnection connection = DataAccess.CreateConnection())
                {
                    SqlCommand command = DataAccess.CreateCommand(connection);

                    DataAccess.CreateStoredprocedure(command, "GetAllInvoiceNamesSummary_SP");
                    SqlDataReader reader = DataAccess.ExecuteReader(command);
                    if (reader != null)
                    {
                        while (reader.Read())
                        {
                            InvoiceName iName = new InvoiceName();
                            iName.Amount       = reader["Amount"] is DBNull ? 0 : Convert.ToDouble(reader["Amount"]);
                            iName.Apc          = reader["Apc"] is DBNull ? 0 : Convert.ToInt32(reader["Apc"]);
                            iName.BookingDate  = reader["BookingDate"] is DBNull ? DateTime.MinValue : Convert.ToDateTime(reader["BookingDate"]);
                            iName.CNetFare     = reader["CNetFare"] is DBNull ? 0 : Convert.ToDouble(reader["CNetFare"]);
                            iName.Id           = reader["Id"] is DBNull ? 0 : Convert.ToInt32(reader["Id"]);
                            iName.InvoiceId    = reader["InvoiceId"] is DBNull ? 0 : Convert.ToInt32(reader["InvoiceId"]);
                            iName.Name         = reader["Name"] is DBNull ? string.Empty : Convert.ToString(reader["Name"]);
                            iName.TicketTax    = reader["TicketTax"] is DBNull ? 0 : Convert.ToDouble(reader["TicketTax"]);
                            iName.VendorCharge = reader["VendorCharge"] is DBNull ? 0 : Convert.ToDouble(reader["VendorCharge"]);
                            iName.VNetFare     = reader["VNetFare"] is DBNull ? 0 : Convert.ToDouble(reader["VNetFare"]);
                            iNames.Add(iName);
                        }
                    }
                    reader.Close();
                    return(iNames);
                }
            }
            catch (Exception ex)
            {
                return(iNames);
            }
        }
        public static InvoiceName ParseInvoiceName(List <string> formattedGDSLines, List <InvoiceSegment> segmentsList, int InvoiceId, int pline)
        {
            InvoiceName iName = new InvoiceName();

            if (!formattedGDSLines[pline].Contains("*"))
            {
                string[] paxSingleLine = null;
                string   paxLine       = string.Empty;
                paxSingleLine = formattedGDSLines[pline].Replace("\t", "=").Split('=');
                if (paxSingleLine.Length == 1)
                {
                    paxSingleLine = formattedGDSLines[pline].Replace("   ", "=").Split('=');
                }

                #region Two passengers in one line...
                if (paxSingleLine.Length == 2)
                {
                    InvoiceName _invName = new InvoiceName();
                    _invName.InvoiceId   = InvoiceId;
                    _invName.BookingDate = DateTime.Now;
                    _invName.Name        = paxSingleLine[0].Remove(0, 2).ToString() + "=" + paxSingleLine[1].Remove(0, 2).ToString();
                    _invName.Status      = 1;
                    if (_invName.Name.Contains("(CHD/"))
                    {
                        _invName.PassengerTypes = PassengerType.CHD;
                    }
                    else if (_invName.Name.Contains("(INF/"))
                    {
                        _invName.PassengerTypes = PassengerType.INF;
                    }
                    else
                    {
                        _invName.PassengerTypes = PassengerType.ADT;
                    }
                    iName = _invName;
                }
                #endregion
                #region Three passengers in one line
                else if (paxSingleLine.Length == 3)
                {
                    InvoiceName _invName = new InvoiceName();
                    _invName.InvoiceId   = InvoiceId;
                    _invName.BookingDate = DateTime.Now;
                    _invName.Name        = paxSingleLine[0].Remove(0, 2).ToString() + "=" + paxSingleLine[1].Remove(0, 2).ToString() + "=" + paxSingleLine[2].Remove(0, 2).ToString();
                    _invName.Status      = 1;
                    if (_invName.Name.Contains("(CHD/"))
                    {
                        _invName.PassengerTypes = PassengerType.CHD;
                    }
                    else if (_invName.Name.Contains("(INF/"))
                    {
                        _invName.PassengerTypes = PassengerType.INF;
                    }
                    else
                    {
                        _invName.PassengerTypes = PassengerType.ADT;
                    }
                    iName = _invName;
                }
                #endregion
                #region One passenger in one line...
                else
                {
                    InvoiceName _invName = new InvoiceName();
                    _invName.InvoiceId   = InvoiceId;
                    _invName.BookingDate = DateTime.Now;
                    _invName.Name        = paxSingleLine[0].Remove(0, 2).ToString();
                    _invName.Status      = 1;
                    if (_invName.Name.Contains("(CHD/"))
                    {
                        _invName.PassengerTypes = PassengerType.CHD;
                    }
                    else if (_invName.Name.Contains("(INF/"))
                    {
                        _invName.PassengerTypes = PassengerType.INF;
                    }
                    else
                    {
                        _invName.PassengerTypes = PassengerType.ADT;
                    }
                    iName = _invName;
                }
                #endregion
            }
            return(iName);
        }