Example #1
0
        private void DoubleClickPolicy(Point point)
        {
            if (_dgvMain.GetID() == 0)
            {
                return;
            }

            PolicyList policyList = PolicyList.getInstance();
            Policy     policy     = policyList.getItem(_dgvMain.GetID());

            string columnName = _dgvCar.Columns[point.X].HeaderText;

            if ((_dgvCar.Columns[point.X].HeaderText == "Номер полиса") && (!string.IsNullOrEmpty(policy.File)))
            {
                WorkWithFiles.OpenFile(policy.File);
            }
            else if (DGVSpecialColumn.CanFiltredPolicy(columnName)
                     ) // (labelList.Where(item => item.Text == columnName).Count() == 1)
            {
                _myFilter.SetFilterValue(string.Concat(columnName, ":"), point);
            }
            else
            {
                Policy_AddEdit policyAE = new Policy_AddEdit(policy);
                if (policyAE.ShowDialog() == DialogResult.OK)
                {
                    loadCars();
                }
            }
        }
Example #2
0
        private void DoubleClickSale(Point point)
        {
            Car car = _dgvMain.GetCar();

            if (car == null)
            {
                return;
            }

            PTSList ptsList = PTSList.getInstance();
            PTS     pts     = ptsList.getItem(car);

            STSList stsList = STSList.getInstance();
            STS     sts     = stsList.getItem(car);

            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
            {
                CarSaleList carSaleList = CarSaleList.getInstance();
                CarSale     carSale     = carSaleList.getItem(car.Id);

                Car_Sale carSaleForm = new Car_Sale(carSale);
                if (carSaleForm.ShowDialog() == DialogResult.OK)
                {
                    loadCars();
                }
            }
        }
Example #3
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();
                }
            }
        }
Example #4
0
        private void DoubleClickAccount(Point point)
        {
            try
            {
                if (_dgvMain.GetID() == 0)
                {
                    return;
                }

                AccountList accountListList = AccountList.GetInstance();
                Account     account         = accountListList.getItem(_dgvMain.GetID());

                if ((_dgvCar.Columns[point.X].HeaderText == "Файл") && (!string.IsNullOrEmpty(account.File)))
                {
                    WorkWithFiles.OpenFile(account.File);
                }
                else if (_dgvCar.Columns[point.X].HeaderText == "Номер счёта")
                {
                    GotoPagePolicy(account);
                }
                else if ((_dgvCar.Columns[point.X].HeaderText == "Согласование") && (account.CanAgree()))
                {
                    if (account.File == string.Empty)
                    {
                        throw new NotImplementedException("Для согласования необходимо прикрепить скан копию счёта");
                    }
                    else if ((User.GetRole() == RolesList.Boss) || (User.GetRole() == RolesList.Adminstrator))
                    {
                        account.Agree();
                        loadCars();
                    }
                    else
                    {
                        throw new AccessViolationException("Вы не имеете прав на выполнение этой операции");
                    }
                }
                else
                {
                    Account_AddEdit accountAE = new Account_AddEdit(account);
                    if (accountAE.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);
            }
        }
Example #5
0
        private void driverLicenseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DTP dtp = _dtpList.getItem(Convert.ToInt32(_dgvDTP.Rows[_dgvDTP.SelectedCells[0].RowIndex].Cells[0].Value));

            Driver driver = _driverCarList.GetDriver(dtp.Car, dtp.Date);

            LicenseList   licencesList  = LicenseList.getInstance();
            DriverLicense driverLicense = licencesList.getItem(driver);

            WorkWithFiles.OpenFile(driverLicense.File);
        }
Example #6
0
 private void sTSToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         WorkWithFiles.OpenFile(_sts.File);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void tryOpenFile(string fileName)
 {
     try
     {
         WorkWithFiles.OpenFile(fileName);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
 private void tryOpenFile(string file)
 {
     try
     {
         WorkWithFiles.OpenFile(file);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Не найден файл", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Example #9
0
        private void pic_Click(object sender, EventArgs e)
        {
            PictureBox pic = sender as PictureBox;

            if ((pic.Name == "picPTS") && (!string.IsNullOrEmpty(_pts.File)))
            {
                WorkWithFiles.OpenFile(_pts.File);
            }
            else if ((pic.Name == "picSTS") && (!string.IsNullOrEmpty(_sts.File)))
            {
                WorkWithFiles.OpenFile(_sts.File);
            }
        }
Example #10
0
        private void kaskoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Policy policy = _policyList.getItem(_car, PolicyType.КАСКО);

                WorkWithFiles.OpenFile(policy.File);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #11
0
        private void _dgvInvoice_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int idInvoice = Convert.ToInt32(_dgvInvoice.Rows[_dgvInvoice.SelectedCells[0].RowIndex].Cells[0].Value);

            Invoice invoice = _invoiceList.getItem(idInvoice);

            if ((e.ColumnIndex == 4) && (invoice.File != string.Empty))
            {
                WorkWithFiles.OpenFile(invoice.File);
            }
            else if (openAddEditDialog(invoice))
            {
                loadInvoice();
            }
        }
Example #12
0
        private void _dgvPolicy_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int idPolicy = Convert.ToInt32(_dgvPolicy.Rows[e.RowIndex].Cells[0].Value);

            Policy policy = _policyList.getItem(idPolicy);

            if ((e.ColumnIndex == 4) && (policy.File != string.Empty))
            {
                WorkWithFiles.OpenFile(policy.File);
            }
            else
            {
                Policy_AddEdit pAE = new Policy_AddEdit(policy);
                pAE.ShowDialog();

                loadPolicy();
            }
        }
        private void dgvPolicy_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int idPolicy = Convert.ToInt32(dgvPolicy.Rows[dgvPolicy.SelectedCells[0].RowIndex].Cells[0].Value);

            PolicyList policyList = PolicyList.getInstance();
            Policy     policy     = policyList.getItem(idPolicy);

            if ((e.ColumnIndex == 1) && (policy.File != string.Empty))
            {
                WorkWithFiles.OpenFile(policy.File);
            }
            else
            {
                Policy_AddEdit policyAE = new Policy_AddEdit(policy);
                if (policyAE.ShowDialog() == DialogResult.OK)
                {
                    FillTable();
                }
            }
        }
Example #14
0
        private void _dgvDiagCard_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int idDiagCard = Convert.ToInt32(_dgvDiagCard.Rows[e.RowIndex].Cells[0].Value);

            DiagCard diagCard = _diagCardList.getItem(idDiagCard);


            if ((e.ColumnIndex == 4) && (diagCard.File != string.Empty))
            {
                WorkWithFiles.OpenFile(diagCard.File);
            }
            else
            {
                DiagCard_AddEdit diagcardAE = new DiagCard_AddEdit(diagCard);

                if (diagcardAE.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    loadDiagCard();
                }
            }
        }
        private void dgvInstractions_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (isCellNoHeader(e.RowIndex))
            {
                int         idInstraction = Convert.ToInt32(dgvInstractions.Rows[e.RowIndex].Cells[0].Value);
                Instraction instraction   = instractionList.getItem(idInstraction);

                if ((dgvInstractions.Columns[e.ColumnIndex].HeaderText == "Номер") && (instraction.File != string.Empty))
                {
                    WorkWithFiles.OpenFile(instraction.File);
                }
                else
                {
                    Instraction_AddEdit instAE = new Instraction_AddEdit(instraction);
                    if (instAE.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        LoadData();
                    }
                }
            }
        }
        private ToolStripMenuItem CreateShowSTS()
        {
            ToolStripMenuItem item = CreateItem("Свидетельство о регистрации ТС");

            item.Click += delegate
            {
                Car car = _dgvMain.GetCar();
                if (car == null)
                {
                    return;
                }

                STSList stsList = STSList.getInstance();
                STS     sts     = stsList.getItem(car);

                if (!string.IsNullOrEmpty(sts.File))
                {
                    WorkWithFiles.OpenFile(sts.File);
                }
            };
            return(item);
        }
        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);
        }
Example #18
0
        private void DoubleClickInvoice(Point point)
        {
            if (_dgvMain.GetID() == 0)
            {
                return;
            }

            InvoiceList invoiceList = InvoiceList.getInstance();
            Invoice     invoice     = invoiceList.getItem(_dgvMain.GetID());

            if ((_dgvCar.Columns[point.X].HeaderText == "№ накладной") && (!string.IsNullOrEmpty(invoice.File)))
            {
                WorkWithFiles.OpenFile(invoice.File);
            }
            else
            {
                if (InvoiceDialog.Open(invoice))
                {
                    loadCars();
                }
            }
        }
        private ToolStripMenuItem CreateShowPolicyKasko()
        {
            ToolStripMenuItem item = CreateItem("Полис Каско");

            item.Click += delegate
            {
                Car car = _dgvMain.GetCar();
                if (car == null)
                {
                    return;
                }

                PolicyList policyList = PolicyList.getInstance();
                Policy     kasko      = policyList.getItem(car, PolicyType.КАСКО);

                if (!string.IsNullOrEmpty(kasko.File))
                {
                    WorkWithFiles.OpenFile(kasko.File);
                }
            };
            return(item);
        }
Example #20
0
        private void DoubleClickDiagCard(Point point)
        {
            if (_dgvMain.GetID() == 0)
            {
                return;
            }

            DiagCardList diagCardList = DiagCardList.getInstance();
            DiagCard     diagCard     = diagCardList.getItem(_dgvMain.GetID());

            if ((_dgvCar.Columns[point.X].HeaderText == "№ ДК") && (!string.IsNullOrEmpty(diagCard.File)))
            {
                WorkWithFiles.OpenFile(diagCard.File);
            }
            else
            {
                DiagCard_AddEdit diagCardAE = new DiagCard_AddEdit(diagCard);
                if (diagCardAE.ShowDialog() == DialogResult.OK)
                {
                    loadCars();
                }
            }
        }
Example #21
0
        private void _dgvFile_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (isCellNoHeader(e.RowIndex))
            {
                int idDTPFile;
                int.TryParse(_dgvFile.Rows[e.RowIndex].Cells[0].Value.ToString(), out idDTPFile);

                DTPFile dtpFile = _dtpFileList.getItem(idDTPFile);

                if ((e.ColumnIndex == 2) && (dtpFile.File != string.Empty))
                {
                    WorkWithFiles.OpenFile(dtpFile.File);
                }
                else
                {
                    DTPFile_AddEdit dtpFAE = new DTPFile_AddEdit(dtpFile);
                    if (dtpFAE.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        FillDgv();
                    }
                }
            }
        }
Example #22
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();
                }
            }
        }
Example #23
0
        private void dgvCarDoc_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (isCellNoHeader(e.RowIndex))
            {
                int idCarDoc = Convert.ToInt32(dgvCarDoc.Rows[e.RowIndex].Cells[0].Value);

                CarDocList carDocList = CarDocList.getInstance();
                CarDoc     carDoc     = carDocList.getItem(idCarDoc);

                if (e.ColumnIndex == 2)
                {
                    WorkWithFiles.OpenFile(carDoc.File);
                }
                else
                {
                    CarDoc_AddEdit carDocAE = new CarDoc_AddEdit(carDoc);
                    if (carDocAE.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        loadCarDoc();
                    }
                }
            }
        }
Example #24
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);
            }
        }
Example #25
0
        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);
            }
        }
 private void btnShow_Click(object sender, EventArgs e)
 {
     WorkWithFiles.OpenFile(tbFile.Text);
 }