Exemplo n.º 1
0
 /// <summary>
 /// Constructor requiring data for each field.
 /// </summary>
 /// <param name="id">The <typeparamref name="TadId"/>.</param>
 /// <param name="frequency">The signals frequency as a float.</param>
 /// <param name="signalStrength">The signal strength in XXX units as a float.</param>
 /// <param name="antenna">The antenna id or reference that detected the read.</param>
 /// <param name="time">The time the tag was detected. Typically encoded as the
 /// number of milliseconds from a past reference date in time (e.g., 1/1/1990)</param>
 public TagInfo(TagId id, float frequency, float signalStrength, int antenna, long time, int hits = 1)
     : this()
 {
     ID = id;
     Frequency = frequency;
     SignalStrenth = signalStrength;
     Antenna = antenna;
     Time = time;
     Hits = hits;
 }
Exemplo n.º 2
0
 public Competitor()
 {
     LastName = "unknown";
     FirstName = "unknown";
     Address = new Address();
     Phone = new PhoneNumber();
     DOB = DateTime.Now;
     Age = 21;
     Gender = true;
     Sponsors = "";
     BikeBrand = "";
     BikeNumber = "1234";
     TagNumber = new TagId();
     TagNumber2 = new TagId();
 }
Exemplo n.º 3
0
        public EventEntry(int ID, int eventID, int competitorID, int dayID, String className, String number, 
            TagId tagNumber, TagId tagNumber2, String bikeBrand, String sponsors)
            : this()
        {
            this.ID = ID;
            this.eventID = eventID;
            this.competitorID = competitorID;
            this.dayID = dayID;
            this.className = className;

            this.bikeNumber = number;
            this.tagNumber = tagNumber;
            this.tagNumber2 = tagNumber2;
            this.bikeBrand = bikeBrand;
            this.sponsors = sponsors;
        }
Exemplo n.º 4
0
 public Competitor(int id, String lastName, String firstName, Address address, PhoneNumber phone,
     DateTime dob, int age, bool gender, String sponsors, String bikeBrand, String bikeNumber, TagId tagNumber, TagId tagNumber2)
     : this()
 {
     this.ID = id;
     this.LastName = lastName;
     this.FirstName = firstName;
     this.Address = address;
     this.Phone = phone;
     this.DOB = dob;
     this.Age = age;
     this.Gender = gender;
     this.Sponsors = sponsors;
     this.BikeBrand = bikeBrand;
     this.BikeNumber = bikeNumber;
     this.TagNumber = tagNumber;
     this.TagNumber2 = tagNumber2;
 }
Exemplo n.º 5
0
        public void SetCompetitors(List<CompetitorRace> crs, PassingsInfo pi, List<TagId> tagClashFormList, 
            Race currentRace, DataGridView passingsGrid, Dictionary<TagId, CompetitorRace> disambiuationCRDict)
        {
            this.crs = crs;
            this.tagClashFormList = tagClashFormList;
            this.tagID = pi.ID;
            this.currentRace = currentRace;
            this.passingsGrid = passingsGrid;
            this.disambiuationCRDict = disambiuationCRDict;

            DataTable t = new DataTable();
            t.Columns.Add("First Name");
            t.Columns.Add("Last Name");
            t.Columns.Add("Tag ID");

            foreach (CompetitorRace cr in crs)
            {
                t.Rows.Add(new object[] { cr.firstName, cr.lastName, pi.ID });
                this.dataGridView1.DataSource = t;
            }
            this.dataGridView1.ClearSelection();
        }
Exemplo n.º 6
0
        private void addPassingButton_Click(object sender, EventArgs e)
        {
            long existingTime = 1;
            int index = -1;
            if (passingsDataGrid.SelectedRows.Count != 0)
            {
                index = passingsDataGrid.SelectedRows[0].Index;
                PassingsInfo pi = (passingsDataGrid.DataSource as BindingList<PassingsInfo>)[index];
                existingTime = pi.Time + 1;//- 1;
            }
            
            Form addPassingDialog = new Form();
            addPassingDialog.Text = "Add a new passing";
            //addPassingDialog.Width = 300;
            //addPassingDialog.Height = 150;
            Button okButton = new Button();
            Button cancelButton = new Button();
            TextBox tagTextBox = new TextBox();
            Label tagLabel = new Label();
            tagLabel.Text = "TagID";
            okButton.Text = "OK";
            cancelButton.Text = "Cancel";

            okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
            cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;

            addPassingDialog.Width = 400;
            addPassingDialog.Height = 135;
            okButton.SetBounds(30, 70, 125, 22);
            cancelButton.SetBounds(160, 70, 120, 22);
            tagLabel.SetBounds(30, 20, 50, 22);
            tagTextBox.SetBounds(85, 20, 196, 22);

            addPassingDialog.Controls.Add(okButton);
            addPassingDialog.Controls.Add(cancelButton);
            addPassingDialog.Controls.Add(tagTextBox);
            addPassingDialog.Controls.Add(tagLabel);
            
            addPassingDialog.CancelButton = cancelButton;

            if (addPassingDialog.ShowDialog() == DialogResult.OK)
            {
                TagId tagID = new TagId(tagTextBox.Text);
                TagInfo ti = new TagInfo(tagID, 0, 0, 0, existingTime);
                TagReadEventArgs newTagArgs = new TagReadEventArgs(TagEventType.NewTagDetected, ti);
                if (index != -1) index += 1;
                UpdatePassingsGrid(newTagArgs, index);
                UpdateRaceStandingsGrid(newTagArgs);
            }

            addPassingDialog.Dispose();
        }
Exemplo n.º 7
0
        private EventEntry IsCompetitorInEvent(TagId tagID)
        {
            if (eventComboBox.SelectedIndex != -1)
            {
                Event currentEvent = DataManager.Instance.Events[eventComboBox.SelectedIndex];
                foreach (EventEntry eve in DataManager.Instance.EventEntries)
                {
                    if (eve.eventID == currentEvent.ID && (TagsEqual(tagID, eve.tagNumber) || TagsEqual(tagID, eve.tagNumber2)))
                    {
                        return eve;
                    }
                }
            }

            return null;
        }
Exemplo n.º 8
0
        public bool TagsEqual(TagId t1, TagId t2)
        {
            if (t1.Value == null || t1.Value.Equals("0") || t1.Value.Equals(""))
                return false;

            if (t2.Value == null || t2.Value.Equals("0") || t2.Value.Equals(""))
                return false;

            if (t1.Value != null && !t1.Value.Equals("0") && !t1.Value.Equals("") && t1.Equals(t2))
                return true;

            return false;
        }
Exemplo n.º 9
0
        private List<CompetitorRace> FindCompetitorRaceByTag(TagId tagID)
        {
            List<CompetitorRace> result = new List<CompetitorRace>();
            if (disambiuationCRDict.ContainsKey(tagID))
            {
                if (disambiuationCRDict[tagID].checkTag(tagID))//CRs tag may have changed!
                {
                    result.Add(disambiuationCRDict[tagID]);
                    return result;
                }
            }

            foreach (CompetitorRace cr in currentRaceList)
            {
                if (cr.checkTag(tagID))
                    result.Add(cr);
                    //return cr;
            }
            
            //return null;
            return result;
        }
Exemplo n.º 10
0
        private EventEntry isCompetitorInEventThreadSafe(TagId tagID)
        {
            EventEntry result = null;
            if (this.InvokeRequired)
            {
                this.Invoke((MethodInvoker)delegate
                {
                    result = IsCompetitorInEvent(tagID);
                });
            }
            else
            {
                result = IsCompetitorInEvent(tagID);
            }

            return result;
        }
Exemplo n.º 11
0
        private void eventEntryPropertyChangedHandler(object sender, PropertyChangedEventArgs e)
        {
            if(sender == null) return;

            this.className = (sender as EventEntry).className;

            //
            this.tagID = (sender as EventEntry).tagNumber;
            this.tagID2 = (sender as EventEntry).tagNumber2;
            this.bikeNumber = (sender as EventEntry).bikeNumber;

            if (this.PropertyChanged == null) return;
            PropertyChangedEventArgs args0 = new PropertyChangedEventArgs("tagID");
            PropertyChanged(this, args0);

            if (this.PropertyChanged == null) return;
            PropertyChangedEventArgs args1 = new PropertyChangedEventArgs("tagID2");
            PropertyChanged(this, args1);

            if (this.PropertyChanged == null) return;
            PropertyChangedEventArgs args2 = new PropertyChangedEventArgs("bikeNumber");
            PropertyChanged(this, args2);

            if (this.PropertyChanged == null) return;
            PropertyChangedEventArgs args3 = new PropertyChangedEventArgs("className");
            PropertyChanged(this, args3);
        }
Exemplo n.º 12
0
        private void GetDataForCompetitor()
        {
            Competitor c = DataManager.Instance.GetCompetitorByID(competitorID);
            if (c != null)
            {
                tagID = c.TagNumber;
                tagID2 = c.TagNumber2;
                bikeNumber = c.BikeNumber;
                firstName = c.FirstName;
                lastName = c.LastName;

                cmp = c;
                c.PropertyChangedEvent += new Competitor.PropertyChanged(c_PropertyChangedEvent);
            }
        }
Exemplo n.º 13
0
        //TODO: rename to ImportCompetitorsCSV
        public bool ImportCompetitorsXLS(String filename, bool append)
        {
            try
            {
                //DataSet ds = new DataSet();
                //string strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
                //    "Data Source=" + System.IO.Path.GetDirectoryName(filename) + ";" + "Extended Properties=\"Text;HDR=Yes;FMT=Delimited\"";
                //using (System.Data.OleDb.OleDbConnection conText = new System.Data.OleDb.OleDbConnection(strConnectionString))
                //{
                //    System.Data.OleDb.OleDbDataAdapter oleb = new System.Data.OleDb.OleDbDataAdapter("SELECT * FROM [" + System.IO.Path.GetFileName(filename) + "]", conText);
                //    oleb.Fill(ds, "whatever");
                //    oleb.Dispose();
                //}

                if(!append)
                    this.competitors.Clear();

                //OleDB has a nasty problem - if it reads a field, say 20, it assumes that it is number, and
                //in the following rows this fields is supposed to be integer
                //the way to enforce certain data types is to have schema file (.ini) in the same directory as the
                //original file; unfortunately it looks like there is no other (nicer) way to achieve this
                //
                //Thus, instead of using OleDB, we use a free library for reading CSV files:
                //http://www.codeproject.com/KB/database/CsvReader.aspx
                //
                using (CsvReader csv = new CsvReader(new StreamReader(filename), true))
                {
                    //int fieldCount = csv.FieldCount;
                    //string[] headers = csv.GetFieldHeaders();

                    csv.MissingFieldAction = MissingFieldAction.ReplaceByNull;

                    while (csv.ReadNextRecord())
                    {
                        String idStr = (csv["ID"] != null) ? csv["ID"].ToString() : "";
                        String lastNameStr = (csv["lastName"] != null) ? csv["lastName"].ToString() : "";
                        String firstNameStr = (csv["firstName"] != null) ? csv["firstName"].ToString() : "";
                        String addressStr = (csv["address"] != null) ? csv["address"].ToString() : "";
                        String phoneStr = (csv["phoneNumber"] != null) ? csv["phoneNumber"].ToString() : "";
                        String dobStr = (csv["dob"] != null) ? csv["dob"].ToString() : "";
                        String ageStr = (csv["age"] != null) ? csv["age"].ToString() : "";
                        String genderStr = (csv["gender"] != null) ? csv["gender"].ToString() : "";
                        String sponsorsStr = (csv["sponsors"] != null) ? csv["sponsors"].ToString() : "";
                        String bikeBrandStr = (csv["bikeBrand"] != null) ? csv["bikeBrand"].ToString() : "";
                        String bikeNumberStr = (csv["compNumber"] != null) ? csv["compNumber"].ToString() : "";
                        String tagNumberStr = (csv["tagNumber"] != null) ? csv["tagNumber"].ToString() : "";
                        String tagNumber2Str = (csv["tagNumber2"] != null) ? csv["tagNumber2"].ToString() : "";

                        //for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        //{
                        //    String idStr = ds.Tables[0].Rows[i]["ID"].ToString();
                        //    String lastNameStr = ds.Tables[0].Rows[i]["lastName"].ToString();
                        //    String firstNameStr = ds.Tables[0].Rows[i]["firstName"].ToString();
                        //    String addressStr = ds.Tables[0].Rows[i]["address"].ToString();
                        //    String phoneStr = ds.Tables[0].Rows[i]["phoneNumber"].ToString();
                        //    String dobStr = ds.Tables[0].Rows[i]["dob"].ToString();
                        //    String ageStr = ds.Tables[0].Rows[i]["age"].ToString();
                        //    String genderStr = ds.Tables[0].Rows[i]["gender"].ToString();
                        //    String sponsorsStr = ds.Tables[0].Rows[i]["sponsors"].ToString();
                        //    String bikeBrandStr = ds.Tables[0].Rows[i]["bikeBrand"].ToString();
                        //    String bikeNumberStr = ds.Tables[0].Rows[i]["bikeNumber"].ToString();
                        //    String tagNumberStr = ds.Tables[0].Rows[i]["tagNumber"].ToString();
                        //    String tagNumber2Str = ds.Tables[0].Rows[i]["tagNumber2"].ToString();

                        String[] addressArr = new String[] { "", "", "", "12345" };
                        try
                        {
                            String[] adrAr = addressStr.Split(new char[] { ';' });
                            if (adrAr[0] != null)
                                addressArr[0] = adrAr[0];
                            if (adrAr[1] != null)
                                addressArr[1] = adrAr[1];
                            if (adrAr[2] != null)
                                addressArr[2] = adrAr[2];
                            if (adrAr[3] != null)
                                addressArr[3] = adrAr[3];
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.StackTrace);
                            DataManager.Log(e.StackTrace);
                        }

                        int cID = 0;
                        String lastName = "";
                        String firstName = "";
                        Address address = new Address("", "", "", 12345);
                        PhoneNumber phoneNumber = new PhoneNumber("");
                        DateTime dob = DateTime.Now;
                        int age = 20;
                        bool gender = true;
                        String sponsors = "";
                        String bikeBrand = "";
                        String bikeNumber = "0";
                        TagId tagNumber = new TagId();
                        TagId tagNumber2 = new TagId();

                        try
                        {
                            try
                            {
                                cID = int.Parse(idStr);
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e.StackTrace);
                                DataManager.Log(e.StackTrace);
                            }
                            lastName = lastNameStr;
                            firstName = firstNameStr;
                            try
                            {
                                address = new Address(addressArr[0].Trim(), addressArr[1].Trim(), addressArr[2].Trim(), int.Parse(addressArr[3].Trim()));
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e.StackTrace);
                                DataManager.Log(e.StackTrace);
                            }
                            phoneNumber = new PhoneNumber(phoneStr);

                            try
                            {
                                dob = DateTime.Parse(dobStr);

                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e.StackTrace);
                                DataManager.Log(e.StackTrace);
                            }

                            try
                            {
                                age = int.Parse(ageStr);
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e.StackTrace);
                                DataManager.Log(e.StackTrace);
                            }
                            gender = genderStr.ToLower().Equals("true") ? true : false;
                            if (genderStr.ToLower().Equals(""))
                                gender = true;
                            sponsors = sponsorsStr;
                            bikeBrand = bikeBrandStr;

                            bikeNumber = bikeNumberStr;
                            //try
                            //{
                            //    bikeNumber = int.Parse(bikeNumberStr);
                            //}
                            //catch (Exception e)
                            //{
                            //    Console.WriteLine(e.StackTrace);
                            //    DataManager.Log(e.StackTrace);
                            //}

                            tagNumber = new TagId(tagNumberStr);
                            tagNumber2 = new TagId(tagNumber2Str);
                        }
                        catch (Exception exc)
                        {
                            Console.WriteLine(exc.StackTrace);
                            DataManager.Log("Exception caught!" + exc.StackTrace);
                        }
                        Competitor c = new Competitor(cID, lastName, firstName, address, phoneNumber,
                            dob, age, gender, sponsors, bikeBrand, bikeNumber, tagNumber, tagNumber2);
                        this.competitors.Add(c);
                    }
                }
            }
            catch (Exception exc)
            {
                return false;
            }

            return true;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Populate the UI controls with the given data. Please note that there is no
        /// error checking, we assume that the data is properly formatted, etc.
        /// </summary>
        public void SetData(String lastName, String firstName, Address address,
            PhoneNumber phoneNumber, DateTime dob, int age, bool gender, String sponsors,
            String bikeBrand, String bikeNumber, TagId tagID, TagId tagID2)
        {
            lastNameTextBox.Text = lastName;
            firstNameTextBox.Text = firstName;
            addressLineTextBox.Text = address.AddressLine;
            cityTextBox.Text = address.City;
            stateComboBox.SelectedValue = address.State;
            if ((address.Zip + "").Length == 5)
                zipTextBox.Text = address.Zip + "";
            else
            {
                if ((address.Zip + "").Length >= 5)
                {
                    zipTextBox.Text = (address.Zip + "").Substring(0, 5);
                    zipTextBoxAdd.Text = (address.Zip + "").Substring(5);
                }
            }
            phoneTextBox.Text = phoneNumber.Number;
            dobSelector.Value = dob;
            ageTextBox.Text = age + "";
            if (gender)
                genderComboBox.SelectedIndex = 0;//male
            else
                genderComboBox.SelectedIndex = 1;

            sponsorsTextBox.Text = sponsors;
            bikeBrandTextBox.Text = bikeBrand;
            bikeNumberTextBox.Text = bikeNumber + "";
            bikeTagTextBox.Text = tagID + "";
            bikeTag2TextBox.Text = tagID2 + "";
        }
Exemplo n.º 15
0
 public void MarkTagAsUsed(TagId tagID)
 {
     try
     {
         /*
         String value = Properties.Settings.Default.tagsDictionary[tagID.Value] as String;
         if (value != null) //put date/time when first used
         {
             if (validTags[tagID.Value] != null && validTags[tagID.Value].Equals(""))
             {
                 Properties.Settings.Default.tagsDictionary[tagID.Value] = DateTime.Now.ToString();//"used";
                 validTags[tagID.Value] = DateTime.Now.ToString(); //"used";
             }
         }
         */
         if (validTags[tagID.Value] != null && validTags[tagID.Value].Equals(""))
         {
             validTags[tagID.Value] = DateTime.Now.ToString();
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         DataManager.Log("Exception caught!" + e.StackTrace);
     }
 }
Exemplo n.º 16
0
 /// <summary>
 /// A no-op implementation of <typeparamref name="TagReadEventArgs.TagMessageDelegate"/> delegate.
 /// </summary>
 /// <param name="sender">Who cares, it is ignored.</param>
 /// <param name="args">Ignored.</param>
 public void IgnoreAddEvent(object sender, TagId tagId)
 {
 }
Exemplo n.º 17
0
        //when a cr's tag id (s) change, try to re-match passings
        //1. if some nullCRs exist, look if their passings can be remapped to cr and remove nullCR
        //2. if passings in cr become unmapped (cr's tag id no longer matches passings'), create null CRs
        //and copy passings there; first check if such nullCR exists already
        public void ResetPassings(CompetitorRace cr)
        {
            //1. Find, whether exising nullCRs' passings can be reassociated with the new cr,
            //and if yes, perform this reassociation
            List<PassingsInfo> toRemove = new List<PassingsInfo>();//possibly removed from nullCRs
            foreach (CompetitorRace cmpRace in competitorRaceList)
            {
                if (!cmpRace.isNull)
                    continue;

                foreach (PassingsInfo pi in cmpRace.passings)
                {
                    if (cr.checkTag(pi.ID))
                    {
                        toRemove.Add(pi);
                    }
                }
            }

            //now we have a list of passings that can be re-associated with cr:
            foreach (PassingsInfo pi in toRemove)
            {
                if (!cr.passings.Contains(pi))
                {
                    pi.competitorID = cr.competitorID;
                    pi.firstName = cr.firstName;
                    pi.lastName = cr.lastName;
                    pi.CompetitorRace = cr;
                    cr.passings.Add(pi);
                }
            }
            //finally, remove those passings from nullCRs
            foreach (CompetitorRace cmpRace in competitorRaceList)
            {
                if (!cmpRace.isNull)
                    continue;

                foreach (PassingsInfo pi in toRemove)
                {
                    if (cmpRace.passings.Contains(pi))
                        cmpRace.passings.Remove(pi);
                }
            }

            //remove nullCRs if their passings info is empty - that means they are not needed any longer
            List<CompetitorRace> nullCRsToRemove = new List<CompetitorRace>();
            foreach (CompetitorRace cmpRace in competitorRaceList)
            {
                if (!cmpRace.isNull)
                    continue;

                if (cmpRace.passings.Count == 0)
                    nullCRsToRemove.Add(cmpRace);
            }

            foreach (CompetitorRace cmpRace in nullCRsToRemove)
            {
                if(competitorRaceList.Contains(cmpRace))
                    competitorRaceList.Remove(cmpRace);
            }

            //2. on the other hand, if cr's tags no longer match its PassingsInfo,
            //create nullCRs for them and copy stuff over

            List<PassingsInfo> toAdd = new List<PassingsInfo>();
            TagId tagID1 = new TagId("-1");
            TagId tagID2 = new TagId("-1");
            foreach (PassingsInfo pi in cr.passings)
            {
                if (!cr.checkTag(pi.ID))
                {
                    toAdd.Add(pi);

                    //if there are two different ids in the tags for cr (which is possible),
                    //have to get both of them
                    if (tagID1.Value.Equals("-1"))
                        tagID1 = pi.ID;
                    else if (tagID1.Value.Equals(pi.ID.Value))
                        continue;
                    else if (tagID2.Value.Equals("-1"))
                        tagID2 = pi.ID;
                    else if (tagID2.Value.Equals(pi.ID.Value))
                        continue;
                }
            }

            if (toAdd.Count == 0)
                return;

            //search for existing nullCRs that may be used
            CompetitorRace nullCR = null;
            CompetitorRace nullCR2 = null;
            //foreach (CompetitorRace cmpRace in competitorRaceList)
            //{
            //    if (!cmpRace.isNull)
            //        continue;

            //    if (cmpRace.tagID.Equals(tagID1))
            //    {
            //        nullCR = cmpRace;
            //    }
            //}

            if (nullCR == null)
            {
                nullCR = new CompetitorRace();
                nullCR.isNull = true;
                nullCR.competitorID = (-1) * DataManager.getNextID();
                nullCR.tagID = tagID1;
                nullCR.tagID2 = tagID1;
                nullCR.bikeNumber = "0";
                nullCR.firstName = "";
                nullCR.lastName = "Unassigned";
                nullCR.raceParent = this;
            }

            if (nullCR2 == null)
            {
                nullCR2 = new CompetitorRace();
                nullCR2.isNull = true;
                nullCR2.competitorID = (-1) * DataManager.getNextID();
                nullCR2.tagID = tagID2;
                nullCR2.tagID2 = tagID2;
                nullCR2.bikeNumber = "0";
                nullCR2.firstName = "";
                nullCR2.lastName = "Unassigned";
                nullCR2.raceParent = this;
            }

            foreach (PassingsInfo pi in toAdd)
            {
                if (!nullCR.passings.Contains(pi) && pi.ID.Equals(nullCR.tagID))
                {
                    nullCR.passings.Add(pi);
                    pi.competitorID = nullCR.competitorID;
                    pi.firstName = nullCR.firstName;
                    pi.lastName = nullCR.lastName;
                    pi.CompetitorRace = nullCR;
                }

                if (!nullCR2.passings.Contains(pi) && pi.ID.Equals(nullCR2.tagID))
                {
                    nullCR2.passings.Add(pi);
                    pi.competitorID = nullCR2.competitorID;
                    pi.firstName = nullCR2.firstName;
                    pi.lastName = nullCR2.lastName;
                    pi.CompetitorRace = nullCR2;
                }

                if (cr.passings.Contains(pi))
                    cr.passings.Remove(pi);
            }

            if (!competitorRaceList.Contains(nullCR) && nullCR.passings.Count > 0)
                competitorRaceList.Add(nullCR);

            if (!competitorRaceList.Contains(nullCR2) && nullCR2.passings.Count > 0)
                competitorRaceList.Add(nullCR2);
        }
Exemplo n.º 18
0
        private CompetitorRace FindNullCR(TagId tagID, TagId tagID2)
        {
            foreach (CompetitorRace cr in competitorRaceList)
            {
                if (cr.checkTag(tagID) && cr.isNull)
                    return cr;

                if (cr.checkTag(tagID2) && cr.isNull)
                    return cr;
            }

            return null;
        }
Exemplo n.º 19
0
        private void c_PropertyChangedEvent(Competitor source)
        {
            if (source == null) return;

            if (!competitor.Equals(source))
            {
                if (this.PropertyChanged == null) return;
                PropertyChangedEventArgs args0 = new PropertyChangedEventArgs("competitor");
                PropertyChanged(this, args0);
            }

            if (competitorID != source.ID)
            {
                competitorID = source.ID;
                if (this.PropertyChanged == null) return;
                PropertyChangedEventArgs args1 = new PropertyChangedEventArgs("competitorID");
                PropertyChanged(this, args1);
            }

            //
            if (!tagNumber.Equals(source.TagNumber) && source.propagateChanges)
            {
                tagNumber = source.TagNumber;
                if (this.PropertyChanged == null) return;
                PropertyChangedEventArgs args2 = new PropertyChangedEventArgs("tagNumber");
                PropertyChanged(this, args2);
            }
            if (!tagNumber2.Equals(source.TagNumber2) && source.propagateChanges)
            {
                tagNumber2 = source.TagNumber2;
                if (this.PropertyChanged == null) return;
                PropertyChangedEventArgs args3 = new PropertyChangedEventArgs("tagNumber2");
                PropertyChanged(this, args3);
            }
            //if (bikeNumber != source.BikeNumber && source.propagateChanges)
            if (bikeNumber != null && !bikeNumber.Equals(source.BikeNumber) && source.propagateChanges)
            {
                bikeNumber = source.BikeNumber;
                if (this.PropertyChanged == null) return;
                PropertyChangedEventArgs args4 = new PropertyChangedEventArgs("bikeNumber");
                PropertyChanged(this, args4);
            }
            if (bikeBrand != null && !bikeBrand.Equals(source.BikeBrand) && source.propagateChanges)
            {
                bikeBrand = source.BikeBrand;
                if (this.PropertyChanged == null) return;
                PropertyChangedEventArgs args5 = new PropertyChangedEventArgs("bikeBrand");
                PropertyChanged(this, args5);
            }
            //

            if (!sponsors.Equals(source.Sponsors))
            {
                sponsors = source.Sponsors;
                if (this.PropertyChanged == null) return;
                PropertyChangedEventArgs args6 = new PropertyChangedEventArgs("sponsors");
                PropertyChanged(this, args6);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Find a competitor with the given tagID.
        /// Please note that both tagID and tagID2 of the competitor object
        /// are checked.
        /// </summary>
        /// <param name="tagID"></param>
        /// <returns>Competitor with the given tag id, or null if not found.</returns>
        public Competitor GetCompetitorByTagID(TagId tagID)
        {
            if (competitors == null) return null;

            foreach(Competitor c in competitors)
            {
                if (c.TagNumber.Equals(tagID) || c.TagNumber2.Equals(tagID))
                    return c;
            }
            return null;
        }
        private void addPassingButton_Click(object sender, EventArgs e)
        {
            if(raceInformationControl.GetCurrentRace() == null)
            {
                MessageBox.Show("Please select a race in the Race Info tab first!");
                return;
            }

            long existingTime = 1;
            int index = -1;
            if (passingsDataGrid.SelectedRows.Count != 0)
            {
                index = passingsDataGrid.SelectedRows[0].Index;
                PassingsInfo pi = (passingsDataGrid.DataSource as BindingList<PassingsInfo>)[index];
                existingTime = pi.Time + 1;//- 1;
            }

            CompetitorRace selectedCR = null;
            if (competitorRaceDataGrid.SelectedRows != null && competitorRaceDataGrid.SelectedRows.Count > 0)
            {
                int crIndex = competitorRaceDataGrid.SelectedRows[0].Index;

                selectedCR = (competitorRaceDataGrid.DataSource as SortableBindingList<CompetitorRace>)[crIndex];
            }

            Form addPassingDialog = new Form();
            addPassingDialog.Text = "Add a new passing";
            Button okButton = new Button();
            Button cancelButton = new Button();
            TextBox tagTextBox = new TextBox();
            Label tagLabel = new Label();
            tagLabel.Text = "TagID";
            okButton.Text = "OK";
            cancelButton.Text = "Cancel";

            okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
            cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;

            addPassingDialog.Width = 400;
            addPassingDialog.Height = 135;
            okButton.SetBounds(30, 70, 125, 22);
            cancelButton.SetBounds(160, 70, 120, 22);
            tagLabel.SetBounds(30, 20, 50, 22);
            tagTextBox.SetBounds(85, 20, 196, 22);

            addPassingDialog.Controls.Add(okButton);
            addPassingDialog.Controls.Add(cancelButton);
            addPassingDialog.Controls.Add(tagTextBox);
            addPassingDialog.Controls.Add(tagLabel);

            addPassingDialog.CancelButton = cancelButton;

            if (addPassingDialog.ShowDialog() == DialogResult.OK)
            {
                TagId tagID = new TagId(tagTextBox.Text);
                TagInfo ti = new TagInfo(tagID, 0, 0, 0, existingTime);
                TagReadEventArgs newTagArgs = new TagReadEventArgs(TagEventType.NewTagDetected, ti);
                if (index != -1) index += 1;
                raceInformationControl.UpdatePassingsGrid(newTagArgs, index);
                raceInformationControl.UpdateRaceStandingsGrid(newTagArgs);

                SelectCompetitorRace(selectedCR);
            }

            addPassingDialog.Dispose();
        }
Exemplo n.º 22
0
        //public double totalRunningTime { get; set; }
        /// <summary>
        /// Returns true if the given TagID is equal to one of the two tags for this
        /// competitor race. Please note that cases with trivial id ("0") are dismissed.
        /// </summary>
        public bool checkTag(TagId t)
        {
            if (t.Value == null || t.Value.Equals("0") || t.Value.Equals(""))
                return false;

            if (tagID.Value != null && !tagID.Value.Equals("0") && !tagID.Value.Equals("") && tagID.Equals(t))
                return true;

            if (tagID2.Value != null && !tagID2.Value.Equals("0") && !tagID2.Value.Equals("") && tagID2.Equals(t))
                return true;

            return false;
        }
Exemplo n.º 23
0
        /// <summary>
        /// Returns all the values from the UI elements.
        /// </summary>
        /// <returns>Returns false if there was a problem retrieving data from the gui components.</returns>
        public bool GetData(
            out int ID, out String lastName, out String firstName, out Address address,
            out PhoneNumber phoneNumber, out DateTime dob, out int age, out bool gender, out String sponsors,
            out String bikeBrand, out String bikeNumber, out TagId tagNumber, out TagId tagNumber2, out String errorMessage, out bool propagateChanges)
        {
            errorMessage = "";
            String errorControlString = "";//changed to inform where was a problem with UI
            try
            {
                //ID = 0;//debug
                propagateChanges = syncChangesCheckBox.Checked;
                ID = DataManager.getNextID();
                lastName = lastNameTextBox.Text;
                firstName = firstNameTextBox.Text;
                errorControlString = "ZIP";
                int zipInt = 0;
                try
                {
                    zipInt = int.Parse(zipTextBox.Text + zipTextBoxAdd.Text);
                }
                catch {}
                address = new Address(addressLineTextBox.Text, cityTextBox.Text, stateComboBox.Text, zipInt);
                errorControlString = "Phone number";
                phoneNumber = new PhoneNumber(phoneTextBox.Text);
                dob = dobSelector.Value;
                errorControlString = "Age";
                age = 20;
                try
                {
                    age = int.Parse(ageTextBox.Text);
                }
                catch {}
                errorControlString = "Gender";
                gender = (genderComboBox.Text == "Male") ? true : false;
                if (genderComboBox.SelectedIndex == -1)
                    throw new Exception("Gender not selected!");
                sponsors = sponsorsTextBox.Text;
                bikeBrand = bikeBrandTextBox.Text;
                errorControlString = "Bike Number";
                //bikeNumber = "0";
                bikeNumber = bikeNumberTextBox.Text;
                //try
                //{
                //    bikeNumber = int.Parse(bikeNumberTextBox.Text);
                //}
                //catch { }
                tagNumber = new TagId(bikeTagTextBox.Text);
                tagNumber2 = new TagId(bikeTag2TextBox.Text);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception caught!" + e.StackTrace);
                DataManager.Log("Exception Caught!" + e.StackTrace);

                //populate with some default values; out keyword enforces us
                //to put at least something in these values

                propagateChanges = false;
                ID = 0;
                lastName = "";
                firstName = "";
                address = new Address("", "", "", 12345);
                phoneNumber = new PhoneNumber("");
                dob = DateTime.Now;
                age = 20;
                gender = true;
                sponsors = "";
                bikeBrand = "";
                bikeNumber = "0";
                tagNumber = new TagId();
                tagNumber2 = new TagId();

                errorMessage = "Sorry, there was a problem with field " + errorControlString + ".";

                return false;
            }

            return true;
        }