Пример #1
0
        private void btnSaveEdit_Click(object sender, EventArgs e)
        {
            if (dateChanged)
            {
                int result = DateTime.Compare(Convert.ToDateTime(dateTimePickerEnd.Value), Convert.ToDateTime(lblBeginDate.Text));

                if (result == -1 || result == 0)
                {
                    MessageBox.Show("Uneseni datum završetka ispada: " + dateTimePickerEnd.Value + " je raniji ili jednak datumu početka ispada. Unesite novi datum završetka ispada!");
                }
                else
                {
                    _failure.EndOfFailure          = dateTimePickerEnd.Value;
                    _failure.AdditionalDescription = textBoxAdditionalDescription.Text;
                    _failureRepository.UpdateFailure(_failure);

                    UserControlActiveFailures.Instance.RefreshList();
                    UserControlHistoryOfFailures.Instance.RefreshList();
                }
            }
            else
            {
                _failure.AdditionalDescription = textBoxAdditionalDescription.Text;
                _failureRepository.UpdateFailureWithoutDate(_failure);

                UserControlActiveFailures.Instance.RefreshList();
                UserControlHistoryOfFailures.Instance.RefreshList();
            }
        }
        private void btnSaveEdit_Click(object sender, EventArgs e)
        {
            if (dateChanged)
            {
                _failure.Id = Int32.Parse(lblFailure.Text);
                string typeOfFailure = lblTypeOfFailure.Text;
                _failure.Id_TypeOfFailure = _failureRepository.GetTypeOfFailureIdByString(typeOfFailure);
                string username = lblUsername.Text;
                _failure.Id_Username = _failureRepository.GetUserIdByString(username);
                string city = lblCity.Text;
                _failure.Id_City               = _failureRepository.GetCityIdByString(city);
                _failure.BeginOfFailure        = dateTimePickerBegin.Value;
                _failure.EndOfFailure          = dateTimePickerEnd.Value;
                _failure.AdditionalDescription = textBoxAdditionalDescription.Text;

                _failureRepository.UpdateFailure(_failure);
            }
            else
            {
                _failure.Id = Int32.Parse(lblFailure.Text);
                string typeOfFailure = lblTypeOfFailure.Text;
                _failure.Id_TypeOfFailure = _failureRepository.GetTypeOfFailureIdByString(typeOfFailure);
                string username = lblUsername.Text;
                _failure.Id_Username = _failureRepository.GetUserIdByString(username);
                string city = lblCity.Text;
                _failure.Id_City               = _failureRepository.GetCityIdByString(city);
                _failure.BeginOfFailure        = dateTimePickerBegin.Value;
                _failure.AdditionalDescription = textBoxAdditionalDescription.Text;

                _failureRepository.UpdateFailureWithoutDate(_failure);
            }
        }