private void btnRegister_Click(object sender, EventArgs e) { if (this.contractVehicle == null) { MessageBox.Show("Please select a Vehicle"); } else { VehicleMileage vm = new VehicleMileage(); int tmp = 0; bool bTmp = false; bTmp = int.TryParse(this.txtMileage.Text, out tmp); if (bTmp) { vm.Mileage = tmp; } else { vm.Mileage = 0; } vm.MileageDate = this.datePicker1.Value; vm.Info = ""; bool bTmp2 = VehicleMileage.saveMileages(vm, contractVehicle.VehiId); if (bTmp2) { contractVehicle.Mileages.Add(vm); this.dgvMileages.DataSource = this.loadMileage(contractVehicle); } else { MessageBox.Show("Not OK"); } } }
private void readFile() { var csvRows = File.ReadAllLines(filePath); foreach (string r in csvRows) { if (r.Length > 0) { string[] fileds = r.Split(new string[] { separator }, StringSplitOptions.None); System.Console.WriteLine(fileds[0]); //vin System.Console.WriteLine(fileds[1]); //date System.Console.WriteLine(fileds[2]); //mileage List <ContractVehicle> cvList = new List <ContractVehicle>(); cvList = ContractVehicle.getByVIN(fileds[0]); if (cvList != null && cvList.Count > 0) { this.contractVehicle = cvList[0]; VehicleMileage vm = new VehicleMileage(); int tmp = 0; bool bTmp = false; bTmp = int.TryParse(fileds[2], out tmp); if (bTmp) { vm.Mileage = tmp; } else { vm.Mileage = 0; } DateTime myDate = new DateTime(); bool bTmp2 = false; bTmp2 = DateTime.TryParse(fileds[1], System.Globalization.CultureInfo.GetCultureInfo(myCulture), System.Globalization.DateTimeStyles.None, out myDate); if (bTmp2) { vm.MileageDate = myDate; } vm.Info = ""; VehicleMileage.saveMileages(vm, contractVehicle.VehiId); } } } }