void TextBoxElement_TextChanged(object sender, EventArgs e)
        {
            try
            {
                IsPOI     = false;
                IsKeyword = false;
                timer1.Stop();
                //  IsExistData = false;
                aTxt = (AutoCompleteTextBox)sender;
                aTxt.ResetListBox();

                if (aTxt.Name == "txtFromAddress")
                {
                    txtToAddress.SendToBack();
                }
                else if (aTxt.Name == "txtToAddress")
                {
                    txtToAddress.BringToFront();
                }



                string text = aTxt.Text;
                if (text.Length > 2)
                {
                    if (aTxt.SelectedItem != null && aTxt.SelectedItem.ToLower() == aTxt.Text.ToLower())
                    {
                        aTxt.ListBoxElement.Items.Clear();
                        // aTxt.Values = null;
                        aTxt.ResetListBox();


                        string formerValue = aTxt.FormerValue.ToLower().Trim();

                        int?loctypeId = 0;
                        if (AppVars.keyLocations.Contains(formerValue))
                        {
                            Gen_Location loc = General.GetObject <Gen_Location>(c => c.ShortCutKey == formerValue);
                            if (loc != null)
                            {
                                loctypeId = loc.LocationTypeId;
                            }
                        }

                        if (loctypeId != 0)
                        {
                            if (aTxt.Name == "txtFromAddress")
                            {
                                ddlFromLocType.SelectedValue = loctypeId;
                                RadComboBoxItem item = (RadComboBoxItem)ddlFromLocation.Items.FirstOrDefault(b => b.Text.Equals(aTxt.SelectedItem));
                                if (item != null)
                                {
                                    ddlFromLocation.SelectedValue = item.Value;
                                }

                                if (loctypeId != Enums.LOCATION_TYPES.POSTCODE || loctypeId != Enums.LOCATION_TYPES.ADDRESS ||
                                    loctypeId != Enums.LOCATION_TYPES.AIRPORT || loctypeId != Enums.LOCATION_TYPES.BASE)
                                {
                                    txtToAddress.Focus();
                                }
                            }
                            else if (aTxt.Name == "txtToAddress")
                            {
                                ddlToLocType.SelectedValue = loctypeId;
                                RadComboBoxItem item = (RadComboBoxItem)ddlToLocation.Items.FirstOrDefault(b => b.Text.Equals(aTxt.SelectedItem));
                                if (item != null)
                                {
                                    ddlToLocation.SelectedValue = item.Value;
                                }

                                if (loctypeId == Enums.LOCATION_TYPES.POSTCODE || loctypeId == Enums.LOCATION_TYPES.ADDRESS)
                                {
                                    txtToFlightDoorNo.Focus();
                                }
                            }
                        }

                        return;
                    }



                    if (MapType == Enums.MAP_TYPE.GOOGLEMAPS)
                    {
                        if (UseGoogleMap)
                        {
                            wc.CancelAsync();
                            aTxt.Values = null;
                        }
                    }
                    text = text.ToLower();


                    if (AppVars.keyLocations.Contains(text))
                    {
                        aTxt.ListBoxElement.Items.Clear();
                        var res = (from a in General.GetQueryable <Gen_Location>(c => c.ShortCutKey == text)
                                   select(a.PostCode != string.Empty ? a.LocationName + ", " + a.PostCode : a.LocationName)
                                   ).ToArray <string>();


                        IsKeyword = true;

                        aTxt.ListBoxElement.Items.AddRange(res);
                        aTxt.ShowListBox();

                        if (this.Text != aTxt.FormerValue)
                        {
                            aTxt.FormerValue = aTxt.Text;
                        }
                    }


                    if (MapType == Enums.MAP_TYPE.NONE)
                    {
                        return;
                    }



                    StartAddressTimer(text);
                }
                else
                {
                    if (MapType == Enums.MAP_TYPE.NONE)
                    {
                        return;
                    }


                    if (UseGoogleMap)
                    {
                        wc.CancelAsync();
                        aTxt.Values = null;
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        public override void Save()
        {
            FareBO objFareMaster = null;

            try
            {
                int vehicleId = 0;


                string  oldFrom = string.Empty;
                string  vehicle = string.Empty;
                string  from    = string.Empty;
                string  to      = string.Empty;
                decimal fares   = 0.00m;

                int?fromLocId     = null;
                int?toLocId       = null;
                int?fromLocTypeId = null;
                int?toLocTypeId   = null;

                List <Fleet_VehicleType> listOfVehicle   = AppVars.BLData.GetQueryable <Fleet_VehicleType>(null).ToList();
                List <Gen_Location>      listOfLocations = General.GetQueryable <Gen_Location>(null).ToList();


                LocationBO objLocationMaster = null;

                int recordNo = 0;
                foreach (var row in grdFixFares.Rows)
                {
                    if (!string.IsNullOrEmpty(row.Cells[COLS.VehicleName].Value.ToStr()))
                    {
                        vehicle = row.Cells[COLS.VehicleName].Value.ToStr();
                    }

                    from    = row.Cells[COLS.From].Value.ToStr().ToUpper();
                    oldFrom = from;

                    if (!string.IsNullOrEmpty(row.Cells[COLS.To].Value.ToStr().ToUpper()))
                    {
                        to = row.Cells[COLS.To].Value.ToStr().ToUpper();
                    }

                    if (row.Cells[COLS.Fare].Value.ToStr().StartsWith("£"))
                    {
                        fares = row.Cells[COLS.Fare].Value.ToStr().Substring(1).ToDecimal();
                    }
                    else
                    {
                        fares = row.Cells[COLS.Fare].Value.ToDecimal();
                    }



                    if (string.IsNullOrEmpty(from))
                    {
                        continue;
                    }

                    if (string.IsNullOrEmpty(to))
                    {
                    }

                    vehicleId = listOfVehicle.FirstOrDefault(c => c.VehicleType.ToLower().Trim() == vehicle).DefaultIfEmpty().Id;

                    if (vehicleId == 0)
                    {
                        // row.Cells[COLS.Status].Value = "Required : Vehicle";
                        continue;
                    }



                    Gen_Location objLoc = listOfLocations.FirstOrDefault(c =>
                                                                         ((c.LocationName.ToUpper().Trim() + " " + c.PostCode.ToUpper()) == from) ||
                                                                         (c.PostCode == from));


                    if (objLoc == null)
                    {
                        objLocationMaster = new LocationBO();

                        try
                        {
                            objLocationMaster.New();

                            from = General.GetPostCodeMatch(from);



                            if (string.IsNullOrEmpty(from))
                            {
                            }

                            objLocationMaster.Current.LocationName   = from;
                            objLocationMaster.Current.PostCode       = from;
                            objLocationMaster.Current.LocationTypeId = Enums.LOCATION_TYPES.POSTCODE;

                            objLocationMaster.Save();
                        }
                        catch (Exception ex)
                        {
                            if (objLocationMaster.Errors.Count > 0)
                            {
                                ENUtils.ShowMessage(objLocationMaster.ShowErrors());
                            }
                            else
                            {
                                ENUtils.ShowMessage(ex.Message);
                            }
                            break;
                        }

                        objLoc = objLocationMaster.Current;

                        listOfLocations.Add(objLoc);
                    }

                    fromLocId     = objLoc.Id;
                    fromLocTypeId = objLoc.LocationTypeId;



                    objLoc = listOfLocations.FirstOrDefault(c =>
                                                            ((c.LocationName.ToUpper().Trim() + " " + c.PostCode.ToUpper()) == to) ||
                                                            (c.PostCode == to));

                    if (objLoc == null)
                    {
                        objLocationMaster = new LocationBO();

                        try
                        {
                            objLocationMaster.New();


                            to = General.GetPostCodeMatch(to);

                            // to = General.GetPostCodeMatch(to);


                            if (to.Contains(' ') == false)
                            {
                            }

                            objLocationMaster.Current.LocationName   = to;
                            objLocationMaster.Current.PostCode       = to;
                            objLocationMaster.Current.LocationTypeId = Enums.LOCATION_TYPES.POSTCODE;

                            objLocationMaster.Save();
                        }
                        catch (Exception ex)
                        {
                            if (objLocationMaster.Errors.Count > 0)
                            {
                                ENUtils.ShowMessage(objLocationMaster.ShowErrors());
                            }
                            else
                            {
                                ENUtils.ShowMessage(ex.Message);
                            }
                            break;
                        }
                        objLoc = objLocationMaster.Current;
                        listOfLocations.Add(objLoc);
                    }

                    toLocId     = objLoc.Id;
                    toLocTypeId = objLoc.LocationTypeId;


                    if (recordNo == 0)
                    {
                        objFareMaster = new FareBO();


                        int fareId = General.GetObject <Fare>(c => c.VehicleTypeId == vehicleId).DefaultIfEmpty().Id;

                        if (fareId > 0)
                        {
                            objFareMaster.GetByPrimaryKey(fareId);
                        }
                        else
                        {
                            objFareMaster.New();
                        }


                        objFareMaster.Current.VehicleTypeId = vehicleId;
                        objFareMaster.Current.IsCompanyWise = false;
                    }

                    objFareMaster.Current.Fare_ChargesDetails.Add(new Fare_ChargesDetail
                    {
                        OriginId                  = fromLocId,
                        DestinationId             = toLocId,
                        OriginLocationTypeId      = fromLocTypeId,
                        DestinationLocationTypeId = toLocTypeId,
                        Rate = fares
                    });

                    recordNo++;
                }

                objFareMaster.Save();
            }
            catch (Exception ex)
            {
                if (objFareMaster.Errors.Count > 0)
                {
                    ENUtils.ShowMessage(objFareMaster.ShowErrors());
                }
                else
                {
                    ENUtils.ShowMessage(ex.Message);
                }
            }
        }
        void TextBoxElement_TextChanged(object sender, EventArgs e)
        {
            try
            {
                aTxt = (AutoCompleteTextBox)sender;
                aTxt.ResetListBox();



                string text = aTxt.Text;
                if (text.Length > 2)
                {
                    if (aTxt.SelectedItem != null && aTxt.SelectedItem.ToLower() == aTxt.Text.ToLower())
                    {
                        aTxt.ListBoxElement.Items.Clear();
                        // aTxt.Values = null;
                        aTxt.ResetListBox();


                        string formerValue = aTxt.FormerValue.ToLower().Trim();

                        int?loctypeId = 0;
                        if (AppVars.keyLocations.Contains(formerValue))
                        {
                            Gen_Location loc = General.GetObject <Gen_Location>(c => c.ShortCutKey == formerValue);
                            if (loc != null)
                            {
                                loctypeId = loc.LocationTypeId;
                            }
                        }

                        if (loctypeId != 0)
                        {
                        }

                        aTxt.FormerValue = string.Empty;

                        return;
                    }



                    if (UseGoogleMap)
                    {
                        wc.CancelAsync();
                        aTxt.Values = null;
                    }
                    text = text.ToLower();


                    if (AppVars.keyLocations.Contains(text))
                    {
                        aTxt.ListBoxElement.Items.Clear();
                        var res = (from a in General.GetQueryable <Gen_Location>(c => c.ShortCutKey == text)
                                   select(a.PostCode != string.Empty ? a.LocationName + ", " + a.PostCode : a.LocationName)
                                   ).ToArray <string>();


                        aTxt.ListBoxElement.Items.AddRange(res);
                        aTxt.ShowListBox();


                        if (this.Text != aTxt.FormerValue)
                        {
                            aTxt.FormerValue = aTxt.Text;
                        }
                    }


                    if (MapType == Enums.MAP_TYPE.NONE)
                    {
                        return;
                    }

                    StartAddressTimer(text);
                }
                else
                {
                    if (MapType == Enums.MAP_TYPE.NONE)
                    {
                        return;
                    }


                    if (UseGoogleMap)
                    {
                        wc.CancelAsync();
                        aTxt.Values = null;
                    }
                }
                //txtAddress.Focus();
            }
            catch (Exception ex)
            {
            }
        }