public ErrorTrack ReturnLastLocation(string PhoneMac)
        {
            DBConnection DBop = new DBConnection();
            ErrorTrack error = new ErrorTrack();

            /// check if this account avilable
            DataTable dataTable = new DataTable();
            dataTable = DBop.NewConectionDLL.SelectDataSet("AdminPhones", " * ", "PhoneMac like '" + PhoneMac + "'").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                int PhoneID = (int)dataTable.Rows[0]["PhoneID"];

                dataTable = DBop.NewConectionDLL.SelectDataSet("Tracking", " * ", "PhoneID=" + PhoneID + " and DateRecord=( select max(DateRecord) from Tracking where PhoneID=" + PhoneID + ")").Tables[0];
                if ((dataTable != null) && (dataTable.Rows.Count > 0))
                {
                    TrackingTable[] mytrack1 = new TrackingTable[dataTable.Rows.Count];
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        mytrack1[i] = new TrackingTable();
                        mytrack1[i].Latitude = (Double)dataTable.Rows[i]["Latitude"];
                        mytrack1[i].longitude = (Double)dataTable.Rows[i]["longitude"];
                        mytrack1[i].DateRecord = (DateTime)dataTable.Rows[i]["DateRecord"];

                    }
                    error.myTrack = mytrack1;
                    error.ErrorID = 2;
                    error.ErrorMessage = "Greate you find record";
                    return error;

                }
                else
                {
                    error.ErrorID = 1;
                    error.ErrorMessage = "Error , cannot Find Records in this date Range";
                    return error;
                }


            }
            else
            {
                error.ErrorID = 1;
                error.ErrorMessage = "Error , this phone isnot register in your database";
                return error;
            }


        }
        public ErrorTrack ReturnTrackRange(string PhoneMac, string FromDate,string Todate)
        {
            DBConnection DBop = new DBConnection();
            ErrorTrack error = new ErrorTrack();

            /// check if this account avilable
            DataTable dataTable = new DataTable();
            dataTable = DBop.NewConectionDLL.SelectDataSet("AdminPhones", " * ", "PhoneMac like '" + PhoneMac + "'").Tables[0];
            if ((dataTable != null) && (dataTable.Rows.Count > 0))
            {
                int PhoneID = (int)dataTable.Rows[0]["PhoneID"];

                dataTable = DBop.NewConectionDLL.SelectDataSet("Tracking", " * ", "DateRecord Between '" + FromDate + "' AND '" + Todate + "' and PhoneID="+ PhoneID +" order by DateRecord DESC").Tables[0];
                if ((dataTable != null) && (dataTable.Rows.Count > 0))
                {
                   TrackingTable[] mytrack1 = new TrackingTable[dataTable.Rows.Count ];
                    for (int i = 0; i < dataTable.Rows.Count;i++ )
                    {
                        mytrack1[i] = new TrackingTable();
                      mytrack1[i].Latitude = (Double)dataTable.Rows[i]["Latitude"];
                      mytrack1[i].longitude = (Double)dataTable.Rows[i]["longitude"];
                        mytrack1[i].DateRecord = (DateTime)dataTable.Rows[i]["DateRecord"];

                    }
                    error.myTrack = mytrack1;
                        error.ErrorID = 2;
                    error.ErrorMessage = "Greate you insert new record";
                    return error;

                }
                else
                {
                    error.ErrorID = 1;
                    error.ErrorMessage = "Error , cannot Find Records in this date Range";
                    return error;
                }


            }
            else
            {
                error.ErrorID = 1;
                error.ErrorMessage = "Error , this phone isnot register in your database";
                return error;
            }
        }