private void CopyFields() { if (!_driver.From1C) { _driver.Fio = tbFio.Text; int idRegion; int.TryParse(cbRegion.SelectedValue.ToString(), out idRegion); RegionList regionList = RegionList.getInstance(); Region region = regionList.getItem(idRegion); _driver.Region = region; _driver.CompanyName = tbCompany.Text; _driver.Position = tbPosition.Text; _driver.Dept = tbDept.Text; _driver.SexIndex = (rbMan.Checked) ? 0 : 1; _driver.Fired = chbFired.Checked; _driver.Decret = chbDecret.Checked; _driver.DateBirth = mtbDateBirth.Text; _driver.Login = tbLogin.Text; _driver.Number = tbNumber.Text; } _driver.email = tbEmail.Text; _driver.ExpSince = tbExpSince.Text; _driver.Mobile = mtbMobile.Text; _driver.suppyAddress = tbSuppyAddress.Text; _driver.DateStopNotification = (chbNotificationStop.Checked) ? dtpStopNotificationDate.Value : new DateTime(1, 1, 1); _driver.IsDriver = true; }
private Region getRegion() { int idRegion = 0; int.TryParse(cbRegionTo.SelectedValue.ToString(), out idRegion); RegionList regionList = RegionList.getInstance(); return(regionList.getItem(idRegion)); }
private Region getRegion() { int idRegion = 0; int.TryParse(_dgvEmployees.Rows[_dgvEmployees.SelectedCells[0].RowIndex].Cells[0].Value.ToString(), out idRegion); RegionList regionList = RegionList.getInstance(); return(regionList.getItem(idRegion)); }
private void fillFields(DataRow row) { int idRegion; int.TryParse(row.ItemArray[0].ToString(), out idRegion); RegionList regionList = RegionList.getInstance(); Region = regionList.getItem(idRegion); int.TryParse(row.ItemArray[1].ToString(), out idEmployeesName); int.TryParse(row.ItemArray[2].ToString(), out idDriver); }
private void btnSave_Click(object sender, EventArgs e) { if (_workWithForm.IsEditMode()) { RegionList regionList = RegionList.getInstance(); int idRegion; int.TryParse(cbRegion.SelectedValue.ToString(), out idRegion); _employees.Region = regionList.getItem(idRegion); _employees.IdEmployeesName = cbEmployeesName.SelectedValue.ToString(); _employees.IdDriver = cbDriver.SelectedValue.ToString(); _employees.Save(); DialogResult = System.Windows.Forms.DialogResult.OK; } else { _workWithForm.SetEditMode(true); } }
public void StartImport() { string[] files = Directory.GetFiles(FilePath, "*.txt"); foreach (var file in files) { string[] lines = File.ReadAllLines(file); for (int i = 1; i < lines.Count(); i++) { string[] fields = lines[i].Split(';'); DriverList driverList = DriverList.getInstance(); Driver driver = driverList.getItemByNumber(fields[1]); if (driver == null) { driver = new Driver(); } driver.Fio = fields[0]; driver.Number = fields[1]; driver.Sex = fields[2]; string regionName = fields[3]; RegionList regionList = RegionList.getInstance(); Region region = regionList.getItem(regionName); if (region == null) { region = new Region(fields[3]); region.Save(); region = regionList.getItem(regionName); } driver.Region = region; driver.CompanyName = fields[4]; driver.Dept = fields[5]; driver.Position = fields[6]; driver.DateBirth = fields[7]; driver.Login = fields[9]; driver.email = fields[10]; driver.Decret = ((fields[15] == "Временно не работает") || (fields[15] == "В декретном отпуске")); driver.Fired = (!string.IsNullOrEmpty(fields[15]) && (fields[15].Split(' ')[0] == "Уволен")); driver.Save(); if (!string.IsNullOrEmpty(fields[11])) { string passportNumber = fields[11].Replace(" ", ""); if (passportNumber.Length == 0) { continue; } PassportList passportList = PassportList.getInstance(); Passport passport = passportList.GetPassport(driver, passportNumber); passport.Number = passportNumber; string[] fio = fields[0].Split(' '); passport.LastName = fio[0]; passport.FirstName = fio[1]; passport.SecondName = fio[2]; DateTime date; DateTime.TryParse(fields[12], out date); passport.GiveDate = date; passport.GiveOrg = fields[13]; passport.Address = fields[14]; passport.Save(); } } File.Move(file, FilePath + @"\processed\" + DateTime.Today.ToShortDateString() + " " + Path.GetFileName(file)); } }