Esempio n. 1
0
        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();
                }
            }
        }
Esempio n. 2
0
        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();
            }
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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();
                }
            }
        }
Esempio n. 5
0
        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;
        }
Esempio n. 6
0
        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();
            }
        }
Esempio n. 7
0
        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();
            }
        }
Esempio n. 8
0
        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);
            }
        }
Esempio n. 9
0
        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();
                }
            }
        }
Esempio n. 10
0
        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);
            }
        }