public JsonResult MapAjax() { lock (DriverLock) { DateTime now = DateTime.Now; bool changed = false; DriverList drivers = new DriverList(db.Drivers); foreach (BaseStation station in db.BaseStations.ToList()) { changed = station.Update(now, drivers) || changed; } foreach (Driver driver in db.Drivers.ToList()) { changed = driver.Update(now) || changed; if (driver.Route.Count == 0) { db.Drivers.Remove(driver); changed = true; } } if (changed) { db.SaveChanges(); } var response = new { baseStations = db.BaseStations.ToList(), drivers = db.Drivers.ToList() }; return(Json(response, JsonRequestBehavior.AllowGet)); } }
public FormWayBillDaily(MainDGV dgv) { InitializeComponent(); list = new List <Car>(); fuelList = FuelList.getInstance(); foreach (DataGridViewCell cell in dgv.SelectedCells) { string fio = dgv.GetFIO(cell.RowIndex); DriverList dl = DriverList.getInstance(); driverCurrent = dl.getItemByFullFIO(fio); int idCar = dgv.GetCarID(cell.RowIndex); CarList carList = CarList.getInstance(); Car car = carList.getItem(idCar); list.Add(car); lbCars.Items.Add(car); } btnNext.Enabled = list.Count > 1; index = 0; lbCar.Text = "Выбранный автомобиль: " + list[index].ToString(); }
private List <INotification> GetListNotExist() { DriverList driverList = DriverList.getInstance(); List <Driver> listDriver = driverList.ToList().Where(item => (!item.Fired && !item.Decret && !item.NotificationStop && item.IsDriver)).ToList(); List <INotification> list = _list.ToList(); List <Driver> listNotExist = (from itemDriver in listDriver join itemMC in list on itemDriver.ID equals itemMC.Driver.ID into table1 from itemRes in table1.DefaultIfEmpty() where itemRes == null select itemDriver).ToList(); List <INotification> listNotification = new List <INotification>(); foreach (Driver item in listNotExist) { if (list.First() is MedicalCert) { listNotification.Add(new MedicalCert(item)); } else if (list.First() is DriverLicense) { listNotification.Add(new DriverLicense(item)); } } return(listNotification); }
private void fillFields(DataRow row) { int id; int.TryParse(row.ItemArray[0].ToString(), out id); ID = id; int idDriver; int.TryParse(row.ItemArray[1].ToString(), out idDriver); Driver = DriverList.getInstance().getItem(idDriver); LastName = row.ItemArray[2].ToString(); FirstName = row.ItemArray[3].ToString(); SecondName = row.ItemArray[4].ToString(); _number = row.ItemArray[5].ToString(); GiveOrg = row.ItemArray[6].ToString(); DateTime giveDate; DateTime.TryParse(row.ItemArray[7].ToString(), out giveDate); GiveDate = giveDate; Address = row.ItemArray[8].ToString(); File = row.ItemArray[9].ToString(); _fileBegin = File; }
private void fillFields(DataRow row) { ID = Convert.ToInt32(row.ItemArray[0]); int idFuelCard; int.TryParse(row.ItemArray[1].ToString(), out idFuelCard); FuelCard = FuelCardList.getInstance().getItem(idFuelCard); int idDriver; int.TryParse(row.ItemArray[2].ToString(), out idDriver); Driver = DriverList.getInstance().getItem(idDriver); DateTime dateBegin; DateTime.TryParse(row.ItemArray[3].ToString(), out dateBegin); DateBegin = dateBegin; DateTime dateEnd; if (DateTime.TryParse(row.ItemArray[4].ToString(), out dateEnd)) { DateEnd = dateEnd; } }
public static void MemoryImage(DriverList driverList) { OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + "//translate.accdb"); OleDbCommand command = new OleDbCommand(); //command.CommandText = "insert into TB_DriverList values(@User_ChineseName,@User_EnglishName,@Department_ChineseName,@Department_EnglishName,@Job,@Sex,@Birthdy,@Identification_Type,@Identification_Number,@Employer,@TELEPHONE,@Photo,@CensusRegister,@CurrentResidence)"; command.CommandText = "insert into TB_DriverList (User_ChineseName,User_EnglishName,Department_ChineseName,Department_EnglishName,Job,Sex,Birthdy,Identification_Type,Identification_Number,Employer,TELEPHONE,Photo,CensusRegister,CurrentResidence) values(@User_ChineseName,@User_EnglishName,@Department_ChineseName,@Department_EnglishName,@Job,@Sex,@Birthdy,@Identification_Type,@Identification_Number,@Employer,@TELEPHONE,@Photo,@CensusRegister,@CurrentResidence)"; command.Parameters.AddWithValue("@User_ChineseName", driverList.User_EnglishName); command.Parameters.AddWithValue("@User_EnglishName", driverList.Department_EnglishName); command.Parameters.AddWithValue("@Department_ChineseName", driverList.Department_ChineseName); command.Parameters.AddWithValue("@Department_EnglishName", driverList.Department_EnglishName); command.Parameters.AddWithValue("@Job", driverList.Job); command.Parameters.AddWithValue("@Sex", driverList.Sex); command.Parameters.AddWithValue("@Birthdy", driverList.Birthdy); command.Parameters.AddWithValue("@Identification_Type", driverList.Identification_Type); command.Parameters.AddWithValue("@Identification_Number", driverList.Identification_Number); command.Parameters.AddWithValue("@Employer", driverList.Employer); command.Parameters.AddWithValue("@TELEPHONE", driverList.Employer); command.Parameters.AddWithValue("@Photo", driverList.Photo); command.Parameters.AddWithValue("@CensusRegister", driverList.CensusRegister); command.Parameters.AddWithValue("@CurrentResidence", driverList.CensusRegister); command.Connection = conn; conn.Open(); int i = command.ExecuteNonQuery(); conn.Close(); command = null; }
private void btnSave_Click(object sender, EventArgs e) { if (_workWithForm.IsEditMode()) { _invoice.DriverFromID = cbDriverFrom.SelectedValue.ToString(); _invoice.DriverToID = cbDriverTo.SelectedValue.ToString(); _invoice.RegionFromID = cbRegionFrom.SelectedValue.ToString(); _invoice.RegionToID = cbRegionTo.SelectedValue.ToString(); _invoice.Date = dtpDate.Value; _invoice.DateMove = mtbDateMove.Text; TextBox tbFile = ucFile.Controls["tbFile"] as TextBox; _invoice.File = tbFile.Text; _invoice.Save(); if (_check.Checked) { DriverList driverList = DriverList.getInstance(); Driver driver = driverList.getItem(Convert.ToInt32(cbDriverFrom.SelectedValue.ToString())); driver.IsDriver = false; driver.Save(); } DialogResult = System.Windows.Forms.DialogResult.OK; } else { _workWithForm.SetEditMode(true); } }
public FuelCardDriver(FuelCard fuelCard) { FuelCard = fuelCard; DateBegin = DateTime.Today; Driver = DriverList.getInstance().getItem(1); IsNotUse = false; }
//НЕПРАВИЛЬНО!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //По 2 раза отправляются письма, тем, у кого нет справки (кого нет в list2) private List <INotification> GetListOverdue(DateTime date) { var list = _list.ToList(); /* select driver_fio, max(MedicalCert_dateEnd) from [dbo].[MedicalCert] mc * join Driver d on d.driver_id = mc.driver_id * where MedicalCert_dateEnd < date//'2017-10-24' * group by driver_fio * order by driver_fio */ var temp = (from item in list group item by item.Driver.Id into t orderby t.Key select t.OrderByDescending(y => y.DateEnd).FirstOrDefault()).ToList(); /* тут будет несколько прошлогодних справок */ //var list1 = (list.Where(item => (item.DateEnd < date))).ToList(); var list2 = (list.Where(item => (item.DateEnd >= date))).ToList(); DriverList driverList = DriverList.getInstance(); return((from item1 in temp join item2 in list2 on item1.Driver.Id equals item2.Driver.Id into table1 from item3 in table1.DefaultIfEmpty() where item3 == null && (!driverList.getItem(item1.Driver.Id).NotificationStop) select item1).ToList()); }
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); }
private IEnumerable <INotification> GetListWithoutFile() { var driverList = DriverList.getInstance(); var listDriver = driverList.ToList() .Where(item => (!item.Fired && !item.Decret && !item.NotificationStop && item.IsDriver)).ToList(); var list = _list.ToList(); var listExist = (from itemMc in list join itemDriver in listDriver on itemMc.Driver.Id equals itemDriver.Id into table1 from itemRes in table1.DefaultIfEmpty() where itemRes != null select itemMc).ToList(); var listNotification = new List <INotification>(); foreach (IActual item in listExist) { if (item.IsDateActual() && !item.IsHaveFile()) { if (list.First() is MedicalCert) { listNotification.Add(item as MedicalCert); } else if (list.First() is DriverLicense) { listNotification.Add(item as DriverLicense); } } } return(listNotification); }
private List <INotification> GetListNotExist() { var driverList = DriverList.getInstance(); var listDriver = driverList.ToList() .Where(item => (!item.Fired && !item.Decret && !item.NotificationStop && item.IsDriver)).ToList(); var list = _list.ToList(); var driversWithoutActualDocuments = (from itemDriver in listDriver join itemMc in list on itemDriver.Id equals itemMc.Driver.Id into table1 from itemRes in table1.DefaultIfEmpty() where itemRes == null select itemDriver).ToList(); var listNotification = new List <INotification>(); foreach (var driver in driversWithoutActualDocuments) { if (list.First() is MedicalCert) { listNotification.Add(new MedicalCert(driver)); } else if (list.First() is DriverLicense) { listNotification.Add(new DriverLicense(driver)); } } return(listNotification); }
private void fillFields(DataRow row) { ID = Convert.ToInt32(row.ItemArray[0]); int idDriver; int.TryParse(row.ItemArray[1].ToString(), out idDriver); Driver = DriverList.getInstance().getItem(idDriver); Number = row.ItemArray[2].ToString(); DateTime dateBegin; DateTime.TryParse(row.ItemArray[3].ToString(), out dateBegin); DateBegin = dateBegin; DateTime dateEnd; DateTime.TryParse(row.ItemArray[4].ToString(), out dateEnd); DateEnd = dateEnd; File = row.ItemArray[5].ToString(); _fileBegin = File; int.TryParse(row.ItemArray[6].ToString(), out _notificationSent); }
public DriverCar(DataRow row) { int idCar; int.TryParse(row.ItemArray[0].ToString(), out idCar); Car = CarList.getInstance().getItem(idCar); if (idCar == 191) { idCar = 191; } int idDriver; int.TryParse(row.ItemArray[1].ToString(), out idDriver); Driver = DriverList.getInstance().getItem(idDriver); DateTime.TryParse(row.ItemArray[2].ToString(), out dateBegin); DateTime.TryParse(row.ItemArray[3].ToString(), out dateEnd); int number; int.TryParse(row.ItemArray[4].ToString(), out number); Number = number; dateEnd = dateEnd.Date; }
private CreateDocument CreateWayBill(Car car, DateTime date, int idInvoice = 0) { CreateDocument waybill = new CreateDocument(car); Driver driver = null; if (idInvoice != 0) { InvoiceList invoiceList = InvoiceList.getInstance(); Invoice invoice = invoiceList.getItem(idInvoice); DriverList driverList = DriverList.getInstance(); driver = driverList.getItem(Convert.ToInt32(invoice.DriverToID)); } waybill.CreateWaybill(date, driver); try { if (_type == WayBillType.Day) { waybill.AddRouteInWayBill(date, Fields.All); } } catch (NullReferenceException ex) { MessageBox.Show(ex.Message, "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Information); waybill.Exit(); throw; } return(waybill); }
internal void SendNotification(Driver driver, string message, bool addTransportToCopy = true, List <string> fileNames = null) { _subject = "Уведомление"; _body = message; string[] copyEmails = null; if (addTransportToCopy) { Driver transportEmployee = DriverList.getInstance().GetDriverListByRole(RolesList.Editor).First(); copyEmails = new string[] { transportEmployee.email }; } var listAttachment = new List <Attachment>(); if (fileNames != null) { fileNames.ForEach(item => listAttachment.Add(new Attachment(item))); } Send(new List <Driver> { driver }, copyEmails, listAttachment); LogManager.Logger.Debug(message); }
private void fillFields(DataRow row) { int id; int.TryParse(row.ItemArray[0].ToString(), out id); ID = id; int idCar; int.TryParse(row.ItemArray[1].ToString(), out idCar); Car = CarList.getInstance().getItem(idCar); int idDriver; int.TryParse(row.ItemArray[2].ToString(), out idDriver); Driver = DriverList.getInstance().getItem(idDriver); DateTime dateBegin; DateTime.TryParse(row.ItemArray[3].ToString(), out dateBegin); DateBegin = dateBegin; DateTime dateEnd; DateTime.TryParse(row.ItemArray[4].ToString(), out dateEnd); DateEnd = dateEnd; }
private void btnSave_Click(object sender, EventArgs e) { if (_workWithForm.IsEditMode()) { int idDriver; int.TryParse(cbDriver.SelectedValue.ToString(), out idDriver); _fuelCardDriver.Driver = DriverList.getInstance().getItem(idDriver); _fuelCardDriver.DateBegin = dtpDateBegin.Value; if (chbNotUse.Checked) { if ((!_fuelCardDriver.IsNotUse) && (chbNotUse.Checked)) { FuelCard fuelCard = _fuelCardDriver.FuelCard; FuelCardDriver fuelCardDriver = fuelCard.CreateFuelCardDriver(); fuelCardDriver.Save(); } _fuelCardDriver.DateEnd = dtpDateEnd.Value.Date; } else { _fuelCardDriver.IsNotUse = false; } _fuelCardDriver.Save(); DialogResult = System.Windows.Forms.DialogResult.OK; } else { _workWithForm.SetEditMode(true); } }
public override void Save() { DriverList driverList = DriverList.getInstance(); string dateBirthSql = string.Empty; if (DateBirth != string.Empty) { dateBirthSql = string.Concat(_dateBirth.Year.ToString(), "-", _dateBirth.Month.ToString(), "-", _dateBirth.Day.ToString()); } string dateStopNotificationSql = string.Empty; if (DateStopNotification.Year != 1) { dateStopNotificationSql = string.Concat(DateStopNotification.Year.ToString(), "-", DateStopNotification.Month.ToString(), "-", DateStopNotification.Day.ToString()); } int id; int.TryParse(Provider.Insert("Driver", Id, GetName(NameType.Full), Region.Id, dateBirthSql, _mobile, email, _fired, _expSince, PositionID, DeptID, Login, OwnerID, suppyAddress, SexIndex, _decret, dateStopNotificationSql, _number, _isDriver, _from1C), out id); Id = id; driverList.Add(this); }
private void SetFormatDriver() { DriverList driverList = DriverList.getInstance(); foreach (DataGridViewRow row in _dgv.Rows) { if ((row.Cells["Скан водительского удостоверения"].Value.ToString() == "нет") || (row.Cells["Скан медицинской справки"].Value.ToString() == "нет")) { row.DefaultCellStyle.BackColor = Color.LightYellow; } int idDriver = 0; int.TryParse(row.Cells[0].Value.ToString(), out idDriver); Driver driver = driverList.getItem(idDriver); if (driver.Fired) { row.DefaultCellStyle.ForeColor = Color.Red; } if (((driver.OwnerID < 3) && (string.IsNullOrEmpty(driver.Number))) || (driver.Decret)) { row.DefaultCellStyle.ForeColor = Color.Blue; } if (driver.OwnerID > 2) { row.DefaultCellStyle.ForeColor = BBColors.bbGreen1; } } }
public EMail() { Driver driver = User.getDriver(); DriverList driverList = DriverList.getInstance(); Driver employeeTransport = driverList.GetDriverListByRole(RolesList.Editor).First(); _authorEmail = driver == null ? employeeTransport == null ? ROBOT_EMAIL : employeeTransport.email : driver.email; }
private void LoadDictionary() { DriverList driverList = DriverList.getInstance(); cbDriver.DataSource = driverList.ToDataTable(_fuelCardDriver.Driver.ID != 0); cbDriver.DisplayMember = "ФИО"; cbDriver.ValueMember = "id"; }
public EMail() { var driver = User.GetDriver(); var driverList = DriverList.getInstance(); var employeeTransport = driverList.GetDriverListByRole(RolesList.Editor).First(); _authorEmail = driver == null ? employeeTransport == null ? RobotEmail : employeeTransport.email : driver.email; }
public Tabel(string number, DateTime date) { Driver = DriverList.getInstance().getItemByNumber(number); Date = date; Comment = string.Empty; provider = Provider.GetProvider(); }
private void setDataSourceDriver(ComboBox combo) { DriverList driverList = DriverList.getInstance(); combo.DataSource = driverList.ToDataTable(_invoice.Id != 0); combo.DisplayMember = "ФИО"; combo.ValueMember = "id"; }
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 loadData() { loadDictionary(cbRegion, "Region"); DriverList driverList = DriverList.getInstance(); fillCommonFields(); fillExtraFields(); }
public void ClearStopIfNeed() { DriverList driverList = DriverList.getInstance(); List <Driver> listDriver = driverList.ToList().Where(item => (item.NotificationStop && item.DateStopNotification == DateTime.Today)).ToList(); foreach (Driver driver in listDriver) { driver.DateStopNotification = new DateTime(1, 1, 1); } }
private void changeDataSourceDriverTo() { if (isRegionToNotNull()) { Region region = getRegion(); DriverList driverList = DriverList.getInstance(); cbDriverTo.DataSource = driverList.ToDataTableByRegion(region, _invoice.Id != 0); cbDriverTo.DisplayMember = "ФИО"; cbDriverTo.ValueMember = "id"; } }
/// <summary> /// 编辑司机数据 /// </summary> /// <param name="Id"></param> public void UpdateDriver(DriverList driverList) { string sql = "update TB_DriverList set "; if (!string.IsNullOrEmpty(driverList.User_ChineseName) || driverList.User_ChineseName != "") { sql += "User_ChineseName='" + driverList.User_ChineseName + "'"; } if (!string.IsNullOrEmpty(driverList.User_EnglishName) || driverList.User_EnglishName != "") { sql += ",User_EnglishName='" + driverList.User_EnglishName + "'"; } if (!string.IsNullOrEmpty(driverList.Department_ChineseName) || driverList.Department_ChineseName != "") { sql += ",Department_ChineseName='" + driverList.Department_ChineseName + "'"; } if (!string.IsNullOrEmpty(driverList.Department_EnglishName) || driverList.Department_EnglishName != "") { sql += ",Department_EnglishName='" + driverList.Department_EnglishName + "'"; } if (!string.IsNullOrEmpty(driverList.Job) || driverList.Job != "") { sql += ",Job='" + driverList.Job + "'"; } if (!string.IsNullOrEmpty(driverList.Sex) || driverList.Sex != "") { sql += ",Sex='" + driverList.Sex + "'"; } if (!string.IsNullOrEmpty(driverList.Birthdy) || driverList.Birthdy != "") { sql += ",Birthdy='" + driverList.Birthdy + "'"; } if (!string.IsNullOrEmpty(driverList.Identification_Type) || driverList.Identification_Type != "") { sql += ",Identification_Type='" + driverList.Identification_Type + "'"; } if (!string.IsNullOrEmpty(driverList.Identification_Number) || driverList.Identification_Number != "") { sql += ",Identification_Number='" + driverList.Identification_Number + "'"; } if (!string.IsNullOrEmpty(driverList.Employer) || driverList.Employer != "") { sql += ",Employer='" + driverList.Employer + "'"; } if (!string.IsNullOrEmpty(driverList.Telephone) || driverList.Telephone != "") { sql += ",TELEPHONE='" + driverList.Telephone + "'"; } sql += " where id=" + driverList.Id + ""; AccessHelper.SQLExecute(sql); }
public DriverGrid() { InitializeComponent(); Sorting += new DataGridSortingEventHandler(SortHandler); DataContextChanged += new DependencyPropertyChangedEventHandler(DataChanged); Listener.DriverHandlers.Add(this as DriverInfoUpdateHandler); Listener.SessionHandlers.Add(this as SessionInfoUpdateHandler); DriverList dl = new DriverList(); this.DataContext = dl; l = new Listener(); listenerThread = new Thread(l.listen); listenerThread.Name = "Listener"; listenerThread.IsBackground = true; listenerThread.Start(); }