Пример #1
0
        public static void GenerateDriverData(Database db, int count, string path)
        {
            var rnd = new Random();

            using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write))
                using (var sw = new StreamWriter(fs))
                {
                    for (int i = 0; i < count; ++i)
                    {
                        var r = new DriverRecord();

                        r.Id              = i;
                        r.Name            = rnd.NextEnumValueString <Names>();
                        r.Surname         = rnd.NextEnumValueString <Surnames>();
                        r.ValidUntil      = DateTime.Today.AddDays(rnd.Next(300));
                        r.AllowedToDrive  = true;
                        r.InfractionCount = rnd.Next(2);

                        sw.WriteLine(r.ToString());

                        //Console.WriteLine(r.ToString());

                        db.AddOrUpdateDriver(r);
                    }
                }
        }
Пример #2
0
        public MainForm()
        {
            InitializeComponent();
            database = new Database(Path.Combine(Application.StartupPath, dataBaseFileName), true);

            pgdCar.SelectedObject    = selectedCar = new CarRecord();
            pgdDriver.SelectedObject = selectedDriver = new DriverRecord();

            propertyGridTest.SelectedObject = selectedTestData = new TestClass();
        }
Пример #3
0
        void UpdateDriver(DriverRecord driver)
        {
            if (driver == null)
            {
                ShowError("Driver not found.");
                return;
            }

            selectedDriver           = driver;
            pgdDriver.SelectedObject = selectedDriver;
        }
        private bool CheckRecordsAreValid(List <string> colRecords, List <IRecord> records)
        {
            var recordsValid = false;

            recordsValid = colRecords.All(recordRow =>
            {
                var isTypeValid = false;
                var rowCols     = recordRow.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                if (rowCols.Length == _expectedDriverHeadingTypeMapping.Keys.Count)
                {
                    var newRecord = new DriverRecord();
                    for (int i = 0; i < rowCols.Length; i++)
                    {
                        var colInfo        = _expectedDriverHeadingTypeMapping.ElementAt(i).Value;
                        var rowColPosition = colInfo.ColPosition;
                        var rowColsType    = colInfo.ColType;

                        if (rowColsType == typeof(int))
                        {
                            isTypeValid = int.TryParse(rowCols[rowColPosition], out int number);
                            if (!isTypeValid)
                            {
                                return(false);
                            }
                        }

                        newRecord.UpdateAppropriateCol(_expectedDriverHeadingTypeMapping.Keys.ElementAt(i), rowCols[rowColPosition]);
                    }
                    records.Add(newRecord);
                    return(isTypeValid);
                }
                return(false);
            });


            return(recordsValid);
        }