private void btnSave_Click(object sender, EventArgs e)
        {
            if (_workWithForm.IsEditMode())
            {
                int idDriver;
                int.TryParse(cbDriver.SelectedValue.ToString(), out idDriver);
                _fuelCardDriver.Driver    = DriverList.getInstance().getItem(idDriver);
                _fuelCardDriver.DateBegin = dtpDateBegin.Value;

                if (chbNotUse.Checked)
                {
                    if ((!_fuelCardDriver.IsNotUse) && (chbNotUse.Checked))
                    {
                        FuelCard       fuelCard       = _fuelCardDriver.FuelCard;
                        FuelCardDriver fuelCardDriver = fuelCard.CreateFuelCardDriver();
                        fuelCardDriver.Save();
                    }

                    _fuelCardDriver.DateEnd = dtpDateEnd.Value.Date;
                }
                else
                {
                    _fuelCardDriver.IsNotUse = false;
                }

                _fuelCardDriver.Save();

                DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            else
            {
                _workWithForm.SetEditMode(true);
            }
        }
Esempio n. 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Save();

            try
            {
                ShowAddEditFuelCardDriver(_fuelCard.CreateFuelCardDriver());
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Ошибка", "Топливная карта не сохранена", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }