public Driver getDriver() { DriverCarList driverCarList = DriverCarList.getInstance(); Driver driver = driverCarList.GetDriver(Car, Date); return(driver ?? new Driver()); }
private ToolStripMenuItem CreateDeleteDriver() { ToolStripMenuItem item = CreateItem("Удалить водителя"); item.Click += delegate { if (MessageBox.Show("Вы действительно хотите удалить водителя из списка?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { DriverList driverList = DriverList.getInstance(); Driver driver = driverList.getItem(_dgvMain.GetID()); DriverCarList driverCarList = DriverCarList.getInstance(); if (driverCarList.IsDriverHaveCar(driver)) { MessageBox.Show("За водителем закреплён автомобиль, удаление невозможно", "Удаление", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { driver.IsDriver = false; driver.Save(); _mainStatus.Set(_mainStatus.Get()); } } }; return(item); }
internal override object[] GetRow() { MedicalCertList medicalCertList = MedicalCertList.getInstance(); MedicalCert medicalCert = medicalCertList.getItem(this); string medicalCertStatus = ((medicalCert == null) || (!medicalCert.IsActual())) ? "нет" : "есть"; LicenseList licenseList = LicenseList.getInstance(); DriverLicense license = licenseList.getItem(this); string licenseStatus = ((license == null) || (!license.IsActual())) ? "нет" : "есть"; DriverCarList driverCarList = DriverCarList.getInstance(); Car car = driverCarList.GetCar(this); return(new object[] { Id, 0, GetName(NameType.Full), licenseStatus, medicalCertStatus, (car == null) ? "нет автомобиля" : car.ToString(), Region.Name, CompanyName, Status }); }
public void sendMailPolicy(Car car, PolicyType type) { PolicyList policyList = PolicyList.getInstance(); Policy policy = policyList.getItem(car, type); if (string.IsNullOrEmpty(policy.File)) { throw new Exception("Не найден файл полиса"); } else { _subject = "Полис " + type.ToString(); CreateBodyPolicy(type); DriverCarList driverCarList = DriverCarList.getInstance(); Driver driver = driverCarList.GetDriver(car); Send(new List <Driver> { driver }, new string[] { _authorEmail }, new List <Attachment>() { new Attachment(policy.File) }); } }
private Dictionary <int, Driver> GetDriversDictionary() { DriverCarList driverCarList = DriverCarList.getInstance(); //TODO: EF?? TabelList tabelList = TabelList.GetInstance(); Dictionary <int, Driver> drivers = new Dictionary <int, Driver>(); for (int day = 1; day <= _date.AddMonths(1).AddDays(-1).Day; day++) { DateTime curDate = new DateTime(_date.Year, _date.Month, day); Driver driver = driverCarList.GetDriver(_car, curDate); List <int> days = tabelList.GetDays(driver, curDate); if (days.Count == 0) { break; } //throw new NullReferenceException("Нет табельных листов на выбранный месяц для водителя " + driver.GetName(NameType.Short)); if (!days.Exists(item => item == day)) { continue; } drivers.Add(day, driver); } return(drivers); }
public void ShowNotice(DTP dtp) { _excelDoc = openDocumentExcel("Извещение о страховом случае"); var owners = Owners.getInstance(); _excelDoc.setValue(6, 5, owners.getItem(Convert.ToInt32(_car.ownerID))); //страхователь _excelDoc.setValue(7, 6, "а/я 34, 196128"); //почтовый адрес _excelDoc.setValue(8, 7, "320-40-04"); //телефон var driverCarList = DriverCarList.getInstance(); var driver = driverCarList.GetDriver(_car, dtp.Date); var passportList = PassportList.getInstance(); var passport = passportList.getLastPassport(driver); if (passport.Number != string.Empty) { var number = passport.Number; var numbers = number.Split(' '); _excelDoc.setValue(10, 3, numbers[0]); //серия _excelDoc.setValue(10, 6, numbers[1]); //номер _excelDoc.setValue(11, 3, passport.GiveOrg); //кем выдан _excelDoc.setValue(12, 4, passport.GiveDate.ToShortDateString()); //дата выдачи } var policyList = PolicyList.getInstance(); var policy = policyList.getItem(_car, PolicyType.КАСКО); _excelDoc.setValue(14, 6, policy.Number); //полис _excelDoc.setValue(16, 6, string.Concat(_car.Mark.Name, " ", _car.info.Model)); //марка а/м _excelDoc.setValue(18, 6, _car.Grz); //рег номер а/м _excelDoc.setValue(20, 6, _car.vin); //вин _excelDoc.setValue(22, 6, dtp.Date.ToShortDateString()); //дата дтп _excelDoc.setValue(27, 2, driver.GetName(NameType.Full)); //водитель фио var regions = Regions.getInstance(); _excelDoc.setValue(29, 3, regions.getItem(Convert.ToInt32(dtp.IDRegion))); //город _excelDoc.setValue(31, 14, dtp.Damage); //повреждения _excelDoc.setValue(33, 2, dtp.Facts); //обстоятельства происшествия //SsDTP ssDTP = SsDTPList.getInstance().getItem(_car.Mark); //_excelDoc.setValue(63, 11, ssDTP.ServiceStantion); //DateTime date = DateTime.Today; //MyDateTime myDate = new MyDateTime(date.ToShortDateString()); //_excelDoc.setValue(71, 3, string.Concat("« ", date.Day.ToString(), " »")); //_excelDoc.setValue(71, 4, myDate.MonthToStringGenitive()); //_excelDoc.setValue(71, 8, date.Year.ToString().Substring(2, 2)); _excelDoc.Show(); }
internal object[] getCulpit() { DriverCarList driverCarList = DriverCarList.getInstance(); Driver driver = driverCarList.GetDriver(Car, Date); return(new object[] { 4, driver.GetName(NameType.Full) }); }
private WordDoc CreateProxyOnSTO() { WordDoc wordDoc = openDocumentWord("Доверенность на предоставление интересов на СТО"); DriverCarList driverCarList = DriverCarList.getInstance(); Driver driver = (_invoice == null) ? driverCarList.GetDriver(_car) : driverList.getItem(Convert.ToInt32(_invoice.DriverToID)); MyDateTime myDate = new MyDateTime(DateTime.Today.ToShortDateString()); wordDoc.setValue("текущая дата", myDate.ToLongString()); String fio = String.Empty; if (driver != null) { fio = driver.GetName(NameType.Full); } wordDoc.setValue("ФИО регионального представителя", fio); PassportList passportList = PassportList.getInstance(); Passport passport = null; if (driver != null) { passport = passportList.getLastPassport(driver); } string passportToString = "нет данных"; if (passport != null) { passportToString = string.Concat(passport.Number, ", выдан ", passport.GiveDate.ToShortDateString(), ", ", passport.GiveOrg, ", Адрес: ", passport.Address); } wordDoc.setValue("паспорт регионального представителя", passportToString); string fullNameAuto = string.Concat(_car.Mark.Name, " ", _car.info.Model); wordDoc.setValue("Название марки автомобиля", fullNameAuto); wordDoc.setValue("VIN-автомобиля", _car.vin); wordDoc.setValue("Модель и марка двигателя автомобиля", _car.eNumber); wordDoc.setValue("Номер кузова автомобиля", _car.bodyNumber); wordDoc.setValue("Год выпуска автомобиля", _car.Year); wordDoc.setValue("Цвет автомобиля", _car.info.Color); PTSList ptsList = PTSList.getInstance(); PTS pts = ptsList.getItem(_car); string ptsName = string.Concat(pts.Number, ", выдан ", pts.Date.ToShortDateString(), " ", pts.GiveOrg); wordDoc.setValue("ПТС автомобиля", ptsName); wordDoc.setValue("ГРЗ автомобиля", _car.Grz); wordDoc.setValue("текущий год", DateTime.Today.Year.ToString()); return(wordDoc); }
private void ReadFile(string filename) { try { using (var excelDoc = new ExcelDoc(filename)) { try { excelDoc.SetList("Расходы по а-м"); var grz = (excelDoc.getValue("B4") != null) ? excelDoc.getValue("B4").ToString() : string.Empty; var car = GetCar(grz); if (car == null) { var driverFio = (excelDoc.getValue("B5") != null) ? excelDoc.getValue("B5").ToString() : string.Empty; var driverList = DriverList.getInstance(); var driver = driverList.getItemByFIO(driverFio); if (driver != null) { var driverCarList = DriverCarList.getInstance(); car = driverCarList.GetCar(driver); } if (car == null) { _mileageReportList.Add(new MileageReport(null, string.Concat("Не найден автомобиль: ", grz, " сотрудник: ", driverFio, ". Файл: ", filename))); } } if (car != null) { string value = excelDoc.getValue("C8") != null?excelDoc.getValue("C8").ToString() : string.Empty; SetMileage(car, value); } } catch (IndexOutOfRangeException) { _mileageReportList.Add(new MileageReport(null, string.Concat("Ошибка при чтении файла: ", filename))); } catch (OverflowException) { _mileageReportList.Add(new MileageReport(null, string.Concat("Указан слишком большой пробег в файле: ", filename))); } } } catch { _mileageReportList.Add(new MileageReport(null, string.Concat("Ошибка при чтении файла: ", filename))); } }
private void FillCar() { DriverCarList driverCarList = DriverCarList.getInstance(); Car car = driverCarList.GetCar(_driver); if (car != null) { carInfo.Text = car.ToString(); } }
private void DriverCar_Load(object sender, EventArgs e) { DriverCarList driverCarList = DriverCarList.getInstance(); dgvDriverCar.DataSource = driverCarList.ToDataTableCar(_driver); dgvDriverCar.Columns[0].Visible = false; dgvDriverCar.Columns[1].Visible = false; dgvDriverCar.Columns[8].Visible = false; dgvDriverCar.Columns[9].Visible = false; }
public static string Send(Car car, PolicyType type) { var mail = new EMail(); mail.SendMailPolicy(car, type); var driverCarList = DriverCarList.getInstance(); var driver = driverCarList.GetDriver(car); return(string.Concat("Полис ", type.ToString(), " отправлен на адрес ", driver.email)); }
internal Driver GetDriver() { int idCar = GetIDCar(); CarList carList = CarList.getInstance(); Car car = carList.getItem(idCar); DriverCarList driverCarList = DriverCarList.getInstance(); return(driverCarList.GetDriver(car)); }
public Car_AddEdit(Car car) { InitializeComponent(); _car = car; diagCardList = DiagCardList.getInstance(); driverCarList = DriverCarList.getInstance(); driverList = DriverList.getInstance(); dtpList = DTPList.getInstance(); invoiceList = InvoiceList.getInstance(); mileageList = MileageList.getInstance(); policyList = PolicyList.getInstance(); repairList = RepairList.getInstance(); violationList = ViolationList.getInstance(); shipPartList = ShipPartList.getInstance(); }
public DialogResult ShowDialog(Car car) { _car = car; InitializeComponent(); _diagCardList = DiagCardList.getInstance(); _driverCarList = DriverCarList.getInstance(); _driverList = DriverList.getInstance(); _dtpList = DTPList.getInstance(); _invoiceList = InvoiceList.getInstance(); _mileageList = MileageList.getInstance(); _policyList = PolicyList.getInstance(); _repairList = RepairList.getInstance(); _violationList = ViolationList.getInstance(); _shipPartList = ShipPartList.getInstance(); return(ShowDialog()); }
private void btnDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("Вы действительно хотите удалить водителя из списка?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { int idDriver; int.TryParse(_dgvDrivers.Rows[_dgvDrivers.CurrentCell.RowIndex].Cells[0].Value.ToString(), out idDriver); Driver driver = driverList.getItem(idDriver); DriverCarList driverCarList = DriverCarList.getInstance(); if (driverCarList.IsDriverHaveCar(driver)) { MessageBox.Show("За водителем закреплён автомобиль, удаление невозможно", "Удаление", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { driver.IsDriver = false; driver.Save(); loadDrivers(); } } }
private ToolStripMenuItem CreateShowDriverLicense() { ToolStripMenuItem item = CreateItem("Водительское удостоверение"); item.Click += delegate { if (_dgvMain.GetID() == 0) { return; } DateTime date = DateTime.Today; if (_mainStatus.Get() == Status.DTP) { DTPList dtpList = DTPList.getInstance(); DTP dtp = dtpList.getItem(_dgvMain.GetID()); date = dtp.Date; } Car car = _dgvMain.GetCar(); if (car == null) { return; } DriverCarList driverCarList = DriverCarList.getInstance(); Driver driver = driverCarList.GetDriver(car, date); LicenseList licencesList = LicenseList.getInstance(); DriverLicense driverLicense = licencesList.getItem(driver); if ((driverLicense != null) && (!string.IsNullOrEmpty(driverLicense.File))) { WorkWithFiles.openFile(driverLicense.File); } }; return(item); }
private List <Driver> GetDrivers() { List <Driver> drivers = new List <Driver>(); DriverCarList driverCarList = DriverCarList.getInstance(); CarList carList = CarList.getInstance(); foreach (DataGridViewCell cell in _dgvMain.SelectedCells) { if (cell.Visible) { Car car = carList.getItem(_dgvMain.GetCarID(cell.RowIndex)); Driver driver = driverCarList.GetDriver(car); if (CanAddToList(drivers, driver.email)) { drivers.Add(driver); } } } return(drivers); }
/* Старое извещение * public void showNotice(DTP dtp) * { * _excelDoc = openDocumentExcel("Извещение о страховом случае"); * * Owners owners = Owners.getInstance(); * * _excelDoc.setValue(7, 4, owners.getItem(Convert.ToInt32(_car.ownerID))); * _excelDoc.setValue(8, 5, "а/я 34, 196128"); * _excelDoc.setValue(9, 6, "320-40-04"); * * DriverCarList driverCarList = DriverCarList.getInstance(); * Driver driver = driverCarList.GetDriver(_car, dtp.Date); * * PassportList passportList = PassportList.getInstance(); * Passport passport = passportList.getLastPassport(driver); * * if (passport.Number != string.Empty) * { * string number = passport.Number; * string[] numbers = number.Split(' '); * * _excelDoc.setValue(11, 2, numbers[0]); * _excelDoc.setValue(11, 5, numbers[1]); * * _excelDoc.setValue(12, 2, passport.GiveOrg); * _excelDoc.setValue(13, 3, passport.GiveDate.ToShortDateString()); * } * * PolicyList policyList = PolicyList.getInstance(); * Policy policy = policyList.getItem(_car, PolicyType.КАСКО); * _excelDoc.setValue(15, 5, policy.Number); * * _excelDoc.setValue(17, 5, string.Concat(_car.Mark.Name, " ", _car.info.Model)); * _excelDoc.setValue(19, 5, _car.Grz); * _excelDoc.setValue(21, 5, _car.vin); * * _excelDoc.setValue(23, 5, dtp.Date.ToShortDateString()); * * _excelDoc.setValue(28, 1, driver.GetName(NameType.Full)); * * Regions regions = Regions.getInstance(); * * _excelDoc.setValue(30, 2, regions.getItem(Convert.ToInt32(dtp.IDRegion))); * _excelDoc.setValue(32, 13, dtp.Damage); * _excelDoc.setValue(34, 1, dtp.Facts); * * SsDTP ssDTP = SsDTPList.getInstance().getItem(_car.Mark); * * _excelDoc.setValue(63, 11, ssDTP.ServiceStantion); * * DateTime date = DateTime.Today; * MyDateTime myDate = new MyDateTime(date.ToShortDateString()); * * _excelDoc.setValue(71, 3, string.Concat("« ", date.Day.ToString(), " »")); * _excelDoc.setValue(71, 4, myDate.MonthToStringGenitive()); * _excelDoc.setValue(71, 8, date.Year.ToString().Substring(2, 2)); * * _excelDoc.Show(); * } * */ public void CreateWaybill(DateTime date, Driver driver = null) { date = new DateTime(date.Year, date.Month, 1); if (driver == null) { var driverCarList = DriverCarList.getInstance(); driver = driverCarList.GetDriver(_car, date); if (driver == null) { driver = driverCarList.GetDriver(_car); var invoiceList = InvoiceList.getInstance(); var invoice = invoiceList.getItem(_car); if (!string.IsNullOrEmpty(invoice?.DateMove)) { DateTime.TryParse(invoice.DateMove, out DateTime dateMove); if (dateMove.Year == date.Year && dateMove.Month == date.Month) { date = new DateTime(date.Year, date.Month, dateMove.Day); } } } } _excelDoc = openDocumentExcel("Путевой лист"); _excelDoc.setValue(4, 28, _car.BBNumber); var myDate = new MyDateTime(date.ToShortDateString()); _excelDoc.setValue(4, 39, driver.Id + "/01/" + myDate.MonthSlashYear()); _excelDoc.setValue(6, 15, myDate.DaysRange); _excelDoc.setValue(6, 19, myDate.MonthToStringNominative()); _excelDoc.setValue(6, 32, date.Year.ToString()); _excelDoc.setValue(29, 35, _car.info.Grade.EngineType.ShortName); var mml = new MileageMonthList(_car.Id, date.Year + "-" + date.Month + "-01"); /* Из файла Татьяны Мироновой пробег за месяц */ _excelDoc.setValue(19, 39, mml.PSN); _excelDoc.setValue(33, 41, mml.Gas); _excelDoc.setValue(35, 41, mml.GasBegin); _excelDoc.setValue(36, 41, mml.GasEnd); _excelDoc.setValue(37, 41, mml.GasNorm); _excelDoc.setValue(38, 41, mml.GasNorm); _excelDoc.setValue(43, 39, mml.PSK); _excelDoc.setValue(41, 59, mml.Mileage); var owners = Owners.getInstance(); var owner = owners.getItem(1); _excelDoc.setValue(8, 8, owner); _excelDoc.setValue(10, 11, string.Concat(_car.Mark.Name, " ", _car.info.Model)); _excelDoc.setValue(11, 17, _car.Grz); _excelDoc.setValue(12, 6, driver.GetName(NameType.Full)); _excelDoc.setValue(44, 16, driver.GetName(NameType.Short)); _excelDoc.setValue(26, 40, driver.GetName(NameType.Short)); var licencesList = LicenseList.getInstance(); var driverLicense = licencesList.getItem(driver); _excelDoc.setValue(14, 10, driverLicense.Number); _excelDoc.setValue(20, 9, owner); string suppyAddressName; if (driver.suppyAddress != string.Empty) { suppyAddressName = driver.suppyAddress; } else { var suppyAddressList = SuppyAddressList.getInstance(); var suppyAddress = suppyAddressList.getItemByRegion(driver.Region.Id); if (suppyAddress != null) { suppyAddressName = suppyAddress.ToString(); } else { var passportList = PassportList.getInstance(); var passport = passportList.getLastPassport(driver); suppyAddressName = passport.Address; } } var suppyAddressName2 = string.Empty; if (suppyAddressName.Length > 40) { for (var i = 30; i < suppyAddressName.Length; i++) { if (suppyAddressName[i] == ' ') { suppyAddressName2 = suppyAddressName.Substring(i, suppyAddressName.Length - i); suppyAddressName = suppyAddressName.Substring(0, i); } } } _excelDoc.setValue(25, 8, suppyAddressName); _excelDoc.setValue(26, 1, suppyAddressName2); string mechanicName; var employeesList = EmployeesList.getInstance(); var accountant = employeesList.getItem(driver.Region, "Бухгалтер Б.Браун"); if (driver.IsOne) { mechanicName = driver.GetName(NameType.Short); } else { var mechanic = employeesList.getItem(driver.Region, "Механик", true); mechanicName = mechanic == null ? driver.GetName(NameType.Short) : mechanic.Name; } var dispatcher = employeesList.getItem(driver.Region, "Диспечер-нарядчик"); var dispatcherName = dispatcher.Name; _excelDoc.setValue(22, 40, mechanicName); _excelDoc.setValue(44, 40, mechanicName); _excelDoc.setValue(31, 18, dispatcherName); _excelDoc.setValue(35, 18, dispatcherName); _excelDoc.setValue(43, 72, accountant.Name); }
private void DoubleClickDefault(Point point) { Car car = _dgvMain.GetCar(); if (car == null) { return; } /*TODO: Столяровой доступ к информации про водителя и основную о машине */ if (User.getDriver().UserRole == RolesList.AccountantWayBill && _dgvCar.Columns[point.X].HeaderText != "Водитель") { OpenCarAddEdit(car); return; } PTSList ptsList = PTSList.getInstance(); PTS pts = ptsList.getItem(car); STSList stsList = STSList.getInstance(); STS sts = stsList.getItem(car); string columnName = _dgvCar.Columns[point.X].HeaderText; if (_dgvCar.Columns[point.X].HeaderText == "VIN") { formCarInfo formcarInfo = new formCarInfo(car); formcarInfo.ShowDialog(); } else if (_dgvCar.Columns[point.X].HeaderText == "Водитель") { if (isCellNoHeader(point.X)) { DriverCarList driverCarList = DriverCarList.getInstance(); Driver driver = driverCarList.GetDriver(car); if (driver == null) { return; } DriverList driverList = DriverList.getInstance(); Driver_AddEdit dAE = new Driver_AddEdit(driver); if (dAE.ShowDialog() == DialogResult.OK) { loadCars(); } } } else if ((_dgvCar.Columns[point.X].HeaderText == "№ ПТС") && (!string.IsNullOrEmpty(pts.File))) { WorkWithFiles.openFile(pts.File); } else if ((_dgvCar.Columns[point.X].HeaderText == "№ СТС") && (!string.IsNullOrEmpty(sts.File))) { WorkWithFiles.openFile(sts.File); } else if (DGVSpecialColumn.CanFiltredActual(columnName)) { _myFilter.SetFilterValue(string.Concat(columnName, ":"), point); } else { OpenCarAddEdit(car); } }
public Driver GetDriver() { DriverCarList driverCarList = DriverCarList.getInstance(); return(driverCarList.GetDriver(Car, Date)); }