private void FillTable()
        {
            CreateColumnsTable();

            PolicyList policyList = PolicyList.getInstance();
            DataTable  dt         = policyList.ToDataTable(_account);

            foreach (DataRow row in dt.Rows)
            {
                int idPolicy;
                int.TryParse(row.ItemArray[0].ToString(), out idPolicy);

                Policy policy = policyList.getItem(idPolicy);

                if (_account.IsPolicyKaskoAndPayment2())
                {
                    dgvPolicy.Rows.Add(row.ItemArray[0], row.ItemArray[7], row.ItemArray[3], row.ItemArray[12]);
                }
                else
                {
                    dgvPolicy.Rows.Add(row.ItemArray[0], row.ItemArray[7], row.ItemArray[3], row.ItemArray[8]);
                }
            }

            FormatDGV();

            tbSum.Text = _account.Sum.ToString();

            ChangeEnableComboBoxes();
        }
Exemple #2
0
        private void FillTable()
        {
            CreateColumnsTable();

            PolicyList policyList = PolicyList.getInstance();
            DataTable  dt         = policyList.ToDataTable(_policyType, _idOwner, _paymentNumber);

            foreach (DataRow row in dt.Rows)
            {
                int idPolicy;
                int.TryParse(row.ItemArray[0].ToString(), out idPolicy);

                Policy policy = policyList.getItem(idPolicy);

                if (_account.IsPolicyKaskoAndPayment2())
                {
                    dgvPolicy.Rows.Add(policy.IsInList(_account), idPolicy, row.ItemArray[7], row.ItemArray[3],
                                       row.ItemArray[12]);
                }
                else
                {
                    dgvPolicy.Rows.Add(policy.IsInList(_account), idPolicy, row.ItemArray[7], row.ItemArray[3], row.ItemArray[8]);
                }
            }
        }
Exemple #3
0
        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)
                });
            }
        }
        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();
        }
Exemple #5
0
        public bool CanAgree()
        {
            PolicyList policyList = PolicyList.getInstance();
            DataTable  dt         = policyList.ToDataTable(this);

            return((_agreed == 0) && (dt.Rows.Count > 0));
        }
Exemple #6
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();
                }
            }
        }
Exemple #7
0
        private void GotoPagePolicy(Account account)
        {
            savedPosition = new Point(_dgvCar.SelectedCells[0].RowIndex, _dgvCar.SelectedCells[0].ColumnIndex);
            mainStatus.Set(Status.Policy);
            PolicyList policyList = PolicyList.getInstance();
            DataTable  dt         = policyList.ToDataTable(account);

            btnBack.Visible = true;
            loadCars(dt);
        }
        private void btnDelPolicy_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Удалить полис из согласования?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                int idPolicy = Convert.ToInt32(dgvPolicy.Rows[dgvPolicy.SelectedCells[0].RowIndex].Cells[0].Value);

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

                FillTable();
            }
        }
Exemple #9
0
        private int GetIDCar()
        {
            PolicyList policyList = PolicyList.getInstance();
            DataTable  dt         = policyList.ToDataTable(this);

            int idCar = 1;

            if (dt.Rows.Count > 0)
            {
                int.TryParse(dt.Rows[0].ItemArray[1].ToString(), out idCar);
            }

            return(idCar);
        }
Exemple #10
0
        private void SetFormatPolicy()
        {
            SetColumnHeaderText("Pay", "Оплата, руб");
            SetColumnHeaderText("LimitCost", "Страховая стоимость/ Лимит ответственности, руб");
            SetColumnHeaderText("Pay2", "Оплата (2 платеж), руб");

            SetCellFormat("Pay", "N2");
            SetCellFormat("LimitCost", "N0");
            SetCellFormat("Pay2", "N2");

            SetRightAligment("Pay");
            SetRightAligment("LimitCost");
            SetRightAligment("Pay2");

            PolicyList policyList = PolicyList.getInstance();

            foreach (DataGridViewRow row in _dgv.Rows)
            {
                int id;
                int.TryParse(row.Cells[0].Value.ToString(), out id);

                Policy policy = policyList.getItem(id);

                if (policy.File != string.Empty)
                {
                    row.Cells["Номер полиса"].Style.BackColor = Color.MediumPurple;
                }

                if ((policy.Type == PolicyType.КАСКО) && (policy.IsAgreed(2)))
                {
                    row.Cells["Pay2"].Style.BackColor = Color.MediumPurple;
                }

                if (policy.IsAgreed(1))
                {
                    row.Cells["Pay"].Style.BackColor = Color.MediumPurple;
                }

                if (policy.DateEnd < DateTime.Today)
                {
                    row.DefaultCellStyle.BackColor = BBColors.bbGray5;
                }

                if (policy.File != string.Empty)
                {
                    row.Cells["Тип полиса"].Style.BackColor = BBColors.bbGreen3;
                }
            }
        }
        private void FormatDGV()
        {
            PolicyList policyList = PolicyList.getInstance();

            foreach (DataGridViewRow row in dgvPolicy.Rows)
            {
                int    idPolicy = Convert.ToInt32(row.Cells[0].Value);
                Policy policy   = policyList.getItem(idPolicy);

                if (policy.File != string.Empty)
                {
                    row.Cells[1].Style.BackColor = Color.Purple;
                }
            }
        }
Exemple #12
0
        public override void Save()
        {
            if (ID == 0)
            {
                PolicyList.getInstance().Add(this);

                execSave();
            }

            DeleteFile(File);

            File       = WorkWithFiles.fileCopyByID(File, "cars", Car.ID, "Policy", _number);
            _fileBegin = File;

            execSave();
        }
Exemple #13
0
        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 void CreatePolicyTable()
        {
            const int indexBegin = 6;
            var       date       = DateTime.Today.AddMonths(1);

            _excelDoc = openDocumentExcel("Таблица страхования");

            var myDate = new MyDateTime(date.ToShortDateString());

            _excelDoc.setValue(2, 1, "Страхуем в " + myDate.MonthToStringPrepositive() + " " + myDate.Year + " г.");

            var policyList = PolicyList.getInstance();
            var list       = policyList.GetPolicyList(date);
            var listCar    = policyList.GetCarListByPolicyList(list);

            var diagCardList = DiagCardList.getInstance();

            var rowIndex = indexBegin;

            foreach (var car in listCar)
            {
                _excelDoc.setValue(rowIndex, 2, car.Grz);
                _excelDoc.setValue(rowIndex, 3, car.Mark.Name);
                _excelDoc.setValue(rowIndex, 4, car.info.Model);
                _excelDoc.setValue(rowIndex, 5, car.vin);
                _excelDoc.setValue(rowIndex, 6, car.Year);
                _excelDoc.setValue(rowIndex, 7, GetPolicyBeginDate(list, car, PolicyType.ОСАГО));
                _excelDoc.setValue(rowIndex, 8, GetPolicyBeginDate(list, car, PolicyType.КАСКО));
                _excelDoc.setValue(rowIndex, 9, car.info.Owner);
                _excelDoc.setValue(rowIndex, 10, car.info.Owner);
                _excelDoc.setValue(rowIndex, 11, car.info.Owner);

                var diagCard = diagCardList.getItem(car);

                if (diagCard != null)
                {
                    _excelDoc.setValue(rowIndex, 12, diagCard.Date.ToShortDateString());
                    _excelDoc.setValue(rowIndex, 13, diagCard.Number);
                }

                rowIndex++;
            }

            _excelDoc.Show();
        }
Exemple #15
0
        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());
        }
Exemple #16
0
        public void BindWithPolicy(int idPolicy, int payment)
        {
            if (IsNotSaved())
            {
                Save();
            }

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

            if (IsPolicyKaskoAndPayment2())
            {
                policy.SetAccountID(ID, payment);
            }
            else
            {
                policy.SetAccountID(ID, payment);
            }
        }
        private void FillTable()
        {
            CreateColumnsTable();

            PolicyList policyList = PolicyList.getInstance();
            DataTable  dt         = policyList.ToDataTable(_account);

            foreach (DataRow row in dt.Rows)
            {
                dgvPolicy.Rows.Add(row.ItemArray[0], row.ItemArray[7], row.ItemArray[3],
                                   _account.IsPolicyKaskoAndPayment2() ? row.ItemArray[12] : row.ItemArray[8]);
            }

            FormatDgv();

            tbSum.Text = _account.Sum.ToString();

            ChangeEnableComboBoxes();
        }
Exemple #18
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dgvPolicy.Rows)
            {
                bool check;
                bool.TryParse(row.Cells["check"].Value.ToString(), out check);

                if (check)
                {
                    int idPolicy;
                    int.TryParse(row.Cells["idPolicy"].Value.ToString(), out idPolicy);

                    _account.BindWithPolicy(idPolicy, _paymentNumber);
                }
            }

            PolicyList policyList = PolicyList.getInstance();

            policyList.ReLoad();
        }
        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();
                }
            }
        }
        public void SendNotification()
        {
            if (DateTime.Today.Day != SEND_DAY)
            {
                return;
            }

            PolicyList           policyList = PolicyList.getInstance();
            IEnumerable <Policy> list       = policyList.GetPolicyEnds();

            if (list.Any())
            {
                Driver driversTo = GetDriverForSending();

                string mailText = CreateMail(list);

                EMail email = new EMail();

                email.SendNotification(driversTo, mailText);
            }
        }
        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);
        }