Exemplo n.º 1
0
        internal override object[] getRow()
        {
            Regions regions = Regions.getInstance();

            DriverList driverList = DriverList.getInstance();

            Driver driverFrom = driverList.getItem(_idDriverFrom);
            Driver driverTo   = driverList.getItem(_idDriverTo);

            return(new object[] { ID, Car.ID, Car.BBNumber, Car.Grz, Number, regions.getItem(_idRegionFrom), driverFrom.GetName(NameType.Full),
                                  regions.getItem(_idRegionTo), driverTo.GetName(NameType.Full), Date, _dateMove });
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (_workWithForm.IsEditMode())
            {
                _invoice.DriverFromID = cbDriverFrom.SelectedValue.ToString();
                _invoice.DriverToID   = cbDriverTo.SelectedValue.ToString();
                _invoice.RegionFromID = cbRegionFrom.SelectedValue.ToString();
                _invoice.RegionToID   = cbRegionTo.SelectedValue.ToString();
                _invoice.Date         = dtpDate.Value;
                _invoice.DateMove     = mtbDateMove.Text;

                TextBox tbFile = ucFile.Controls["tbFile"] as TextBox;
                _invoice.File = tbFile.Text;

                _invoice.Save();

                if (_check.Checked)
                {
                    DriverList driverList = DriverList.getInstance();
                    Driver     driver     = driverList.getItem(Convert.ToInt32(cbDriverFrom.SelectedValue.ToString()));
                    driver.IsDriver = false;
                    driver.Save();
                }

                DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            else
            {
                _workWithForm.SetEditMode(true);
            }
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        private ToolStripMenuItem CreateDeleteDriver()
        {
            ToolStripMenuItem item = CreateItem("Удалить водителя");

            item.Click += delegate
            {
                if (MessageBox.Show("Вы действительно хотите удалить водителя из списка?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    DriverList    driverList    = DriverList.getInstance();
                    Driver        driver        = driverList.getItem(_dgvMain.GetID());
                    DriverCarList driverCarList = DriverCarList.getInstance();

                    if (driverCarList.IsDriverHaveCar(driver))
                    {
                        MessageBox.Show("За водителем закреплён автомобиль, удаление невозможно", "Удаление", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        driver.IsDriver = false;
                        driver.Save();
                        _mainStatus.Set(_mainStatus.Get());
                    }
                }
            };
            return(item);
        }
Exemplo n.º 5
0
        //НЕПРАВИЛЬНО!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        //По 2 раза отправляются письма, тем, у кого нет справки (кого нет в list2)
        private List <INotification> GetListOverdue(DateTime date)
        {
            var list = _list.ToList();

            /* select driver_fio, max(MedicalCert_dateEnd) from [dbo].[MedicalCert] mc
             * join Driver d on d.driver_id = mc.driver_id
             * where MedicalCert_dateEnd < date//'2017-10-24'
             * group by driver_fio
             * order by driver_fio
             */

            var temp = (from item in list
                        group item by item.Driver.Id
                        into t
                        orderby t.Key
                        select t.OrderByDescending(y => y.DateEnd).FirstOrDefault()).ToList();

            /* тут будет несколько прошлогодних справок */
            //var list1 = (list.Where(item => (item.DateEnd < date))).ToList();
            var list2 = (list.Where(item => (item.DateEnd >= date))).ToList();


            DriverList driverList = DriverList.getInstance();

            return((from item1 in temp
                    join item2 in list2 on item1.Driver.Id equals item2.Driver.Id into table1
                    from item3 in table1.DefaultIfEmpty()
                    where item3 == null && (!driverList.getItem(item1.Driver.Id).NotificationStop)
                    select item1).ToList());
        }
Exemplo n.º 6
0
        private void SetFormatDriver()
        {
            DriverList driverList = DriverList.getInstance();

            foreach (DataGridViewRow row in _dgv.Rows)
            {
                if ((row.Cells["Скан водительского удостоверения"].Value.ToString() == "нет") ||
                    (row.Cells["Скан медицинской справки"].Value.ToString() == "нет"))
                {
                    row.DefaultCellStyle.BackColor = Color.LightYellow;
                }

                int idDriver = 0;
                int.TryParse(row.Cells[0].Value.ToString(), out idDriver);
                Driver driver = driverList.getItem(idDriver);

                if (driver.Fired)
                {
                    row.DefaultCellStyle.ForeColor = Color.Red;
                }

                if (((driver.OwnerID < 3) && (string.IsNullOrEmpty(driver.Number))) || (driver.Decret))
                {
                    row.DefaultCellStyle.ForeColor = Color.Blue;
                }

                if (driver.OwnerID > 2)
                {
                    row.DefaultCellStyle.ForeColor = BBColors.bbGreen1;
                }
            }
        }
Exemplo n.º 7
0
        public void ShowInvoice()
        {
            _excelDoc = openDocumentExcel("Накладная");

            _excelDoc.setValue(7, 2, _car.info.Owner);

            _excelDoc.setValue(16, 82, _invoice.Number);
            _excelDoc.setValue(16, 98, _invoice.Date.ToShortDateString());

            string fullNameAuto = string.Concat("Автомобиль ", _car.Mark.Name, " ", _car.info.Model, ", ", _car.Grz);

            _excelDoc.setValue(22, 10, fullNameAuto);
            _excelDoc.setValue(22, 53, _car.dateGet.ToShortDateString());

            var grades = GradeList.getInstance();

            var grade = grades.getItem(Convert.ToInt32(_car.GradeID));

            var ptsList = PTSList.getInstance();
            var pts     = ptsList.getItem(_car);

            var fullDetailAuto = string.Concat("VIN ", _car.vin, ", Двигатель ", _car.eNumber, ", № кузова ",
                                               _car.bodyNumber, ", Год выпуска ", _car.Year, " г., Паспорт ",
                                               pts.Number, " от ", pts.Date.ToShortDateString(), ", мощность двигателя ", grade.EPower, " л.с.");

            _excelDoc.setValue(47, 2, fullDetailAuto);

            Driver driver1 = _driverList.getItem(Convert.ToInt32(_invoice.DriverFromID));
            Driver driver2 = _driverList.getItem(Convert.ToInt32(_invoice.DriverToID));

            _excelDoc.setValue(9, 10, driver1.Dept);
            _excelDoc.setValue(56, 11, driver1.Position);
            _excelDoc.setValue(56, 63, driver1.GetName(NameType.Full));

            _excelDoc.setValue(11, 13, driver2.Dept);
            _excelDoc.setValue(60, 11, driver2.Position);
            _excelDoc.setValue(60, 63, driver2.GetName(NameType.Full));

            _excelDoc.Show();
        }
Exemplo n.º 8
0
        private void formatDGV()
        {
            _dgvDrivers.Columns[0].Visible = false;
            ResizeDGV();

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

                Driver driver = driverList.getItem(idDriver);

                LicenseList   licenseList = LicenseList.getInstance();
                DriverLicense license     = licenseList.getItem(driver);

                MedicalCertList medicalCertList = MedicalCertList.getInstance();
                MedicalCert     medicalCert     = medicalCertList.getItem(driver);

                if (!license.IsActual() || !medicalCert.IsActual())
                {
                    row.DefaultCellStyle.BackColor = Color.LightYellow;
                }

                if (driver.Fired)
                {
                    row.DefaultCellStyle.ForeColor = Color.Red;
                }

                if (((driver.OwnerID < 3) && (string.IsNullOrEmpty(driver.Number))) || (driver.Decret))
                {
                    row.DefaultCellStyle.ForeColor = Color.Blue;
                }

                if (driver.OwnerID > 2)
                {
                    row.DefaultCellStyle.ForeColor = BBColors.bbGreen1;
                }
            }
        }
Exemplo n.º 9
0
        private void DoubleClickDriver(Point point)
        {
            if (_dgvMain.GetID() == 0)
            {
                return;
            }

            DriverList     driverList    = DriverList.getInstance();
            Driver_AddEdit driverAddEdit = new Driver_AddEdit(driverList.getItem(_dgvMain.GetID()));

            if (driverAddEdit.ShowDialog() == DialogResult.OK)
            {
                loadCars();
            }
        }
Exemplo n.º 10
0
        public static bool Login()
        {
            string login = WindowsIdentity.GetCurrent().Name.Replace("\\", "-");

            String[] s2 = login.Split('-');
            login = s2[1];
            //login = "******";
            //login = "******";
            //login = "******";
            //login = "******";
            DriverList driverList = DriverList.getInstance();

            _driver = driverList.getItem(login);

            return((_driver != null) && (User.GetRole() != RolesList.Employee));
        }
Exemplo n.º 11
0
        private void cbDriverTo_SelectedIndexChanged(object sender, EventArgs e)
        {
            DriverList driverList = DriverList.getInstance();

            if (cbDriverTo.SelectedValue == null)
            {
                return;
            }

            int idDriver;

            if (int.TryParse(cbDriverTo.SelectedValue.ToString(), out idDriver))
            {
                Driver driver = driverList.getItem(idDriver);
                cbRegionTo.SelectedValue = driver.Region.Id;
            }
        }
Exemplo n.º 12
0
        private void cbDriver_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbDriver.SelectedValue == null)
            {
                lbLogin.Text = string.Empty;
            }
            else
            {
                DriverList driverList = DriverList.getInstance();

                int idDriver;
                int.TryParse(cbDriver.SelectedValue.ToString(), out idDriver);

                Driver driver = driverList.getItem(idDriver);
                lbLogin.Text = driver.Login;
            }
        }
Exemplo n.º 13
0
        public WayBillDay(DataRow row)
        {
            ID = Convert.ToInt32(row[0]);

            int idCar;

            int.TryParse(row[1].ToString(), out idCar);
            CarList carList = CarList.getInstance();

            _car = carList.getItem(idCar);

            int idDriver;

            int.TryParse(row[2].ToString(), out idDriver);
            DriverList driverList = DriverList.getInstance();

            _driver = driverList.getItem(idDriver);

            DateTime.TryParse(row[3].ToString(), out _date);
        }
Exemplo n.º 14
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            Driver driver;

            if (cbFio.DataSource != null)
            {
                DriverList driverList = DriverList.getInstance();
                driver = driverList.getItem(Convert.ToInt32(cbFio.SelectedValue));
            }
            else
            {
                driver        = new Driver();
                driver.From1C = false;
            }

            driver.OwnerID = (rbBraun.Checked) ? 1 : (rbGematek.Checked) ? 2 : 3;

            Driver_AddEdit dAE = new Driver_AddEdit(driver);

            dAE.ShowDialog();
        }