Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        private ToolStripMenuItem CreateShowActFuelCard()
        {
            ToolStripMenuItem item = CreateItem("Акт передачи топливной карты");

            item.Click += delegate
            {
                Car car = _dgvMain.GetCar();
                if (car == null)
                {
                    MessageBox.Show("Для формирования акта выберите ячейку в таблице", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    InvoiceList invoiceList = InvoiceList.getInstance();
                    Invoice     invoice     = invoiceList.getItem(_dgvMain.GetID());
                    if (invoice == null)
                    {
                        MessageBox.Show("Для формирования акта необходимо перейти на страницу \"Перемещения\"", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    CreateDocument doc = new CreateDocument(car, invoice);
                    doc.ShowActFuelCard();
                }
            };
            return(item);
        }
Ejemplo n.º 3
0
        internal override object[] getRow()
        {
            MileageList mileageList = MileageList.getInstance();
            Mileage     mileage     = mileageList.getItem(this);
            InvoiceList invoiceList = InvoiceList.getInstance();
            Invoice     invoice     = invoiceList.getItem(this);

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

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

            Regions regions    = Regions.getInstance();
            string  regionName = (invoice == null) ? regions.getItem(_idRegionUsing) : regions.getItem(Convert.ToInt32(invoice.RegionToID));

            int      mileageInt  = 0;
            DateTime mileageDate = DateTime.Today;

            if (mileage != null)
            {
                int.TryParse(mileage.Count, out mileageInt);
                mileageDate = mileage.MonthToString();
            }

            return(new object[] { ID, ID, BBNumber, Grz, Mark.Name, info.Model, vin, regionName,
                                  info.Driver.GetName(NameType.Full), pts.Number, sts.Number, Year, mileageInt,
                                  mileageDate, info.Owner, info.Guarantee, GetStatus() });
        }
Ejemplo n.º 4
0
        private string getNextNumber()
        {
            InvoiceList invoiceList = InvoiceList.getInstance();
            int         number      = invoiceList.GetNextNumber();

            return(number.ToString());
        }
Ejemplo n.º 5
0
        internal override object[] getRow()
        {
            Driver driver = getDriver();

            ViolationTypes violationType = ViolationTypes.getInstance();

            InvoiceList invoiceList = InvoiceList.getInstance();
            Invoice     invoice     = invoiceList.getItem(Car);
            Regions     regions     = Regions.getInstance();
            string      regionName  = (invoice == null) ? regions.getItem(Convert.ToInt32(Car.regionUsingID)) : regions.getItem(Convert.ToInt32(invoice.RegionToID));

            return(new object[] { ID, Car.ID, Car.BBNumber, Car.Grz, regionName, Date, driver.GetName(NameType.Full), Number, DatePay,
                                  violationType.getItem(_idViolationType), _sum });
        }
Ejemplo n.º 6
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();
        }
Ejemplo n.º 7
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());
        }
Ejemplo n.º 8
0
        private void fillNewInvoice()
        {
            InvoiceList invoiceList = InvoiceList.getInstance();
            Invoice     invoice     = invoiceList.getItem(Car);

            if (invoice == null)
            {
                int.TryParse(Car.regionUsingID.ToString(), out _idRegionFrom);
                _idDriverFrom = DEFAULT_DRIVER_MEDIATOR;
                int.TryParse(Car.regionUsingID.ToString(), out _idRegionTo);
                int.TryParse(Car.driverID.ToString(), out _idDriverTo);
            }
            else
            {
                _idRegionFrom = invoice._idRegionTo;
                _idDriverFrom = invoice._idDriverTo;
                _idRegionTo   = 0;
                _idDriverTo   = 0;
            }
        }
Ejemplo n.º 9
0
        internal override object[] getRow()
        {
            InvoiceList invoiceList = InvoiceList.getInstance();
            Invoice     invoice     = invoiceList.getItem(Car);

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

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

            int idRegion = 0;

            int.TryParse(Car.regionUsingID.ToString(), out idRegion);

            Regions regions    = Regions.getInstance();
            string  regionName = (invoice == null) ? regions.getItem(idRegion) : regions.getItem(Convert.ToInt32(invoice.RegionToID));

            return(new object[] { ID, ID, Car.BBNumber, Car.Grz, regionName, _date, comm, pts.Number, sts.Number, Car.GetStatus() });
        }
Ejemplo n.º 10
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();
                }
            }
        }
Ejemplo n.º 11
0
        private void SetFormatInvoice()
        {
            InvoiceList invoiceList = InvoiceList.getInstance();

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

                Invoice invoice = invoiceList.getItem(id);

                if (invoice.DateMove != string.Empty)
                {
                    row.Cells["Дата передачи"].Style.BackColor = Color.MediumPurple;
                }


                if (invoice.File != string.Empty)
                {
                    row.Cells["№ накладной"].Style.BackColor = Color.MediumPurple;
                }
            }
        }
Ejemplo n.º 12
0
        private CreateDocument createDocument(DataGridViewCell cell)
        {
            int carID = _dgvMain.GetCarID(cell.RowIndex);

            if (carID == 0)
            {
                return(null);
            }

            CarList carList = CarList.getInstance();
            Car     car     = carList.getItem(carID);

            Invoice invoice = null;

            if (_mainStatus.Get() == Status.Invoice)
            {
                int invoiceID = _dgvMain.GetID(cell.RowIndex);

                InvoiceList invoiceList = InvoiceList.getInstance();
                invoice = invoiceList.getItem(invoiceID);
            }

            return(new CreateDocument(car, invoice));
        }
Ejemplo n.º 13
0
        /* Старое извещение
         * public void showNotice(DTP dtp)
         * {
         *  _excelDoc = openDocumentExcel("Извещение о страховом случае");
         *
         *  Owners owners = Owners.getInstance();
         *
         *  _excelDoc.setValue(7, 4, owners.getItem(Convert.ToInt32(_car.ownerID)));
         *  _excelDoc.setValue(8, 5, "а/я 34, 196128");
         *  _excelDoc.setValue(9, 6, "320-40-04");
         *
         *  DriverCarList driverCarList = DriverCarList.getInstance();
         *  Driver driver = driverCarList.GetDriver(_car, dtp.Date);
         *
         *  PassportList passportList = PassportList.getInstance();
         *  Passport passport = passportList.getLastPassport(driver);
         *
         *  if (passport.Number != string.Empty)
         *  {
         *      string number = passport.Number;
         *      string[] numbers = number.Split(' ');
         *
         *      _excelDoc.setValue(11, 2, numbers[0]);
         *      _excelDoc.setValue(11, 5, numbers[1]);
         *
         *      _excelDoc.setValue(12, 2, passport.GiveOrg);
         *      _excelDoc.setValue(13, 3, passport.GiveDate.ToShortDateString());
         *  }
         *
         *  PolicyList policyList = PolicyList.getInstance();
         *  Policy policy = policyList.getItem(_car, PolicyType.КАСКО);
         *  _excelDoc.setValue(15, 5, policy.Number);
         *
         *  _excelDoc.setValue(17, 5, string.Concat(_car.Mark.Name, " ", _car.info.Model));
         *  _excelDoc.setValue(19, 5, _car.Grz);
         *  _excelDoc.setValue(21, 5, _car.vin);
         *
         *  _excelDoc.setValue(23, 5, dtp.Date.ToShortDateString());
         *
         *  _excelDoc.setValue(28, 1, driver.GetName(NameType.Full));
         *
         *  Regions regions = Regions.getInstance();
         *
         *  _excelDoc.setValue(30, 2, regions.getItem(Convert.ToInt32(dtp.IDRegion)));
         *  _excelDoc.setValue(32, 13, dtp.Damage);
         *  _excelDoc.setValue(34, 1, 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();
         * }
         *
         */

        public void CreateWaybill(DateTime date, Driver driver = null)
        {
            date = new DateTime(date.Year, date.Month, 1);

            if (driver == null)
            {
                var driverCarList = DriverCarList.getInstance();
                driver = driverCarList.GetDriver(_car, date);

                if (driver == null)
                {
                    driver = driverCarList.GetDriver(_car);
                    var invoiceList = InvoiceList.getInstance();
                    var invoice     = invoiceList.getItem(_car);

                    if (!string.IsNullOrEmpty(invoice?.DateMove))
                    {
                        DateTime.TryParse(invoice.DateMove, out DateTime dateMove);
                        if (dateMove.Year == date.Year && dateMove.Month == date.Month)
                        {
                            date = new DateTime(date.Year, date.Month, dateMove.Day);
                        }
                    }
                }
            }

            _excelDoc = openDocumentExcel("Путевой лист");

            _excelDoc.setValue(4, 28, _car.BBNumber);

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

            _excelDoc.setValue(4, 39, driver.Id + "/01/" + myDate.MonthSlashYear());
            _excelDoc.setValue(6, 15, myDate.DaysRange);
            _excelDoc.setValue(6, 19, myDate.MonthToStringNominative());
            _excelDoc.setValue(6, 32, date.Year.ToString());

            _excelDoc.setValue(29, 35, _car.info.Grade.EngineType.ShortName);

            var mml = new MileageMonthList(_car.Id, date.Year + "-" + date.Month + "-01");

            /* Из файла Татьяны Мироновой пробег за месяц */
            _excelDoc.setValue(19, 39, mml.PSN);
            _excelDoc.setValue(33, 41, mml.Gas);
            _excelDoc.setValue(35, 41, mml.GasBegin);
            _excelDoc.setValue(36, 41, mml.GasEnd);
            _excelDoc.setValue(37, 41, mml.GasNorm);
            _excelDoc.setValue(38, 41, mml.GasNorm);
            _excelDoc.setValue(43, 39, mml.PSK);
            _excelDoc.setValue(41, 59, mml.Mileage);

            var owners = Owners.getInstance();
            var owner  = owners.getItem(1);

            _excelDoc.setValue(8, 8, owner);

            _excelDoc.setValue(10, 11, string.Concat(_car.Mark.Name, " ", _car.info.Model));
            _excelDoc.setValue(11, 17, _car.Grz);

            _excelDoc.setValue(12, 6, driver.GetName(NameType.Full));
            _excelDoc.setValue(44, 16, driver.GetName(NameType.Short));
            _excelDoc.setValue(26, 40, driver.GetName(NameType.Short));

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

            _excelDoc.setValue(14, 10, driverLicense.Number);

            _excelDoc.setValue(20, 9, owner);

            string suppyAddressName;

            if (driver.suppyAddress != string.Empty)
            {
                suppyAddressName = driver.suppyAddress;
            }
            else
            {
                var suppyAddressList = SuppyAddressList.getInstance();
                var suppyAddress     = suppyAddressList.getItemByRegion(driver.Region.Id);

                if (suppyAddress != null)
                {
                    suppyAddressName = suppyAddress.ToString();
                }
                else
                {
                    var passportList = PassportList.getInstance();
                    var passport     = passportList.getLastPassport(driver);
                    suppyAddressName = passport.Address;
                }
            }

            var suppyAddressName2 = string.Empty;

            if (suppyAddressName.Length > 40)
            {
                for (var i = 30; i < suppyAddressName.Length; i++)
                {
                    if (suppyAddressName[i] == ' ')
                    {
                        suppyAddressName2 = suppyAddressName.Substring(i, suppyAddressName.Length - i);
                        suppyAddressName  = suppyAddressName.Substring(0, i);
                    }
                }
            }

            _excelDoc.setValue(25, 8, suppyAddressName);
            _excelDoc.setValue(26, 1, suppyAddressName2);

            string mechanicName;

            var employeesList = EmployeesList.getInstance();
            var accountant    = employeesList.getItem(driver.Region, "Бухгалтер Б.Браун");

            if (driver.IsOne)
            {
                mechanicName = driver.GetName(NameType.Short);
            }
            else
            {
                var mechanic = employeesList.getItem(driver.Region, "Механик", true);
                mechanicName = mechanic == null
          ? driver.GetName(NameType.Short)
          : mechanic.Name;
            }

            var dispatcher     = employeesList.getItem(driver.Region, "Диспечер-нарядчик");
            var dispatcherName = dispatcher.Name;

            _excelDoc.setValue(22, 40, mechanicName);
            _excelDoc.setValue(44, 40, mechanicName);

            _excelDoc.setValue(31, 18, dispatcherName);
            _excelDoc.setValue(35, 18, dispatcherName);

            _excelDoc.setValue(43, 72, accountant.Name);
        }