private void DoubleClickViolation(Point point) { if (_dgvMain.GetID() == 0) { return; } ViolationList violationList = ViolationList.getInstance(); Violation violation = violationList.getItem(_dgvMain.GetID()); if ((_dgvCar.Columns[point.X].HeaderText == "№ постановления") && (!string.IsNullOrEmpty(violation.File))) { WorkWithFiles.openFile(violation.File); } else if ((_dgvCar.Columns[point.X].HeaderText == "Дата оплаты") && (!string.IsNullOrEmpty(violation.FilePay))) { WorkWithFiles.openFile(violation.FilePay); } else { Violation_AddEdit vAE = new Violation_AddEdit(violation); if (vAE.ShowDialog() == DialogResult.OK) { loadCars(); } } }
private void btnAddViolation_Click(object sender, EventArgs e) { Violation violation = _car.createViolation(); Violation_AddEdit vAE = new Violation_AddEdit(violation); if (vAE.ShowDialog() == System.Windows.Forms.DialogResult.OK) { violationList.Add(violation); loadViolation(); } }
private ToolStripMenuItem CreateNewViolation() { ToolStripMenuItem item = CreateItem("Новое нарушение ПДД"); item.Click += delegate { Car car = _dgvMain.GetCar(); if (car == null) { return; } Violation violation = new Violation(car); Violation_AddEdit vAE = new Violation_AddEdit(violation); vAE.ShowDialog(); }; return(item); }
private void _dgvViolation_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { int idViolation = Convert.ToInt32(_dgvViolation.Rows[e.RowIndex].Cells[0].Value); Violation violation = violationList.getItem(idViolation); if ((e.ColumnIndex == 6) && (violation.File != string.Empty)) { WorkWithFiles.openFile(violation.File); } else if ((e.ColumnIndex == 7) && (violation.FilePay != string.Empty)) { WorkWithFiles.openFile(violation.FilePay); } else { Violation_AddEdit vAE = new Violation_AddEdit(violation); if (vAE.ShowDialog() == System.Windows.Forms.DialogResult.OK) { loadViolation(); } } }
private ToolStripMenuItem CreateNewViolation() { ToolStripMenuItem item = CreateItem("Новое нарушение ПДД"); item.Click += delegate { Car car = _dgvMain.GetCar(); if (car == null) return; Violation violation = new Violation(car); Violation_AddEdit vAE = new Violation_AddEdit(violation); vAE.ShowDialog(); }; return item; }
private void _dgvViolation_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { int idViolation = Convert.ToInt32(_dgvViolation.Rows[e.RowIndex].Cells[0].Value); Violation violation = violationList.getItem(idViolation); if ((e.ColumnIndex == 6) && (violation.File != string.Empty)) WorkWithFiles.openFile(violation.File); else if ((e.ColumnIndex == 7) && (violation.FilePay != string.Empty)) WorkWithFiles.openFile(violation.FilePay); else { Violation_AddEdit vAE = new Violation_AddEdit(violation); if (vAE.ShowDialog() == System.Windows.Forms.DialogResult.OK) loadViolation(); } }
private void DoubleClickAccountViolation(Point point) { try { int id = _dgvMain.GetID(); if (id == 0) { return; } Violation violation = ViolationList.getInstance().getItem(id); string columnName = _dgvCar.Columns[point.X].HeaderText; if (((_dgvCar.Columns[point.X].HeaderText == "№ постановления") || (_dgvCar.Columns[point.X].HeaderText == "Сумма штрафа")) && (!string.IsNullOrEmpty(violation.File))) { WorkWithFiles.openFile(violation.File); } else if ((_dgvCar.Columns[point.X].HeaderText == "Согласование") && (!violation.Agreed)) { if (violation.File == string.Empty) { throw new NotImplementedException("Для согласования необходимо прикрепить скан копию счёта"); } else if ((User.GetRole() == RolesList.Boss) || (User.GetRole() == RolesList.Adminstrator)) { violation.Agree(); loadCars(); } else { throw new AccessViolationException("Вы не имеете прав на выполнение этой операции"); } } else if (DGVSpecialColumn.CanInclude(columnName)) { _myFilter.SetFilterValue(string.Concat(columnName, ":"), point); } else { Violation_AddEdit violationAE = new Violation_AddEdit(violation); if (violationAE.ShowDialog() == DialogResult.OK) { loadCars(); } } } catch (NotImplementedException ex) { MessageBox.Show(ex.Message, "Ошибка отправки", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (NullReferenceException ex) { MessageBox.Show(ex.Message, "Ошибка отправки", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (AccessViolationException ex) { MessageBox.Show(ex.Message, "Ошибка доступа", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void DoubleClickViolation(Point point) { if (_dgvMain.GetID() == 0) return; ViolationList violationList = ViolationList.getInstance(); Violation violation = violationList.getItem(_dgvMain.GetID()); if ((_dgvCar.Columns[point.X].HeaderText == "№ постановления") && (!string.IsNullOrEmpty(violation.File))) WorkWithFiles.openFile(violation.File); else if ((_dgvCar.Columns[point.X].HeaderText == "Дата оплаты") && (!string.IsNullOrEmpty(violation.FilePay))) WorkWithFiles.openFile(violation.FilePay); else { Violation_AddEdit vAE = new Violation_AddEdit(violation); if (vAE.ShowDialog() == DialogResult.OK) { loadCars(); } } }
private void DoubleClickAccountViolation(Point point) { try { int id = _dgvMain.GetID(); if (id == 0) return; Violation violation = ViolationList.getInstance().getItem(id); string columnName = _dgvCar.Columns[point.X].HeaderText; if (((_dgvCar.Columns[point.X].HeaderText == "№ постановления") || (_dgvCar.Columns[point.X].HeaderText == "Сумма штрафа")) && (!string.IsNullOrEmpty(violation.File))) WorkWithFiles.openFile(violation.File); else if ((_dgvCar.Columns[point.X].HeaderText == "Согласование") && (!violation.Agreed)) { if (violation.File == string.Empty) throw new NotImplementedException("Для согласования необходимо прикрепить скан копию счёта"); else if ((User.GetRole() == RolesList.Boss) || (User.GetRole() == RolesList.Adminstrator)) { violation.Agree(); loadCars(); } else throw new AccessViolationException("Вы не имеете прав на выполнение этой операции"); } else if (DGVSpecialColumn.CanInclude(columnName)) _myFilter.SetFilterValue(string.Concat(columnName, ":"), point); else { Violation_AddEdit violationAE = new Violation_AddEdit(violation); if (violationAE.ShowDialog() == DialogResult.OK) { loadCars(); } } } catch (NotImplementedException ex) { MessageBox.Show(ex.Message, "Ошибка отправки", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (NullReferenceException ex) { MessageBox.Show(ex.Message, "Ошибка отправки", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (AccessViolationException ex) { MessageBox.Show(ex.Message, "Ошибка доступа", MessageBoxButtons.OK, MessageBoxIcon.Error); } }