Пример #1
0
        protected override bool ValidarForm()
        {
            var esValido = base.ValidarForm();

            if (CbxCambiarClave.IsChecked)
            {
                if (string.IsNullOrEmpty(TxtPassword.Text))
                {
                    FormErrorProvider.SetError(TxtPassword, "Debe ingresar una clave");
                    esValido = false;
                }

                if (string.IsNullOrEmpty(TxtConfirmarPassword.Text))
                {
                    FormErrorProvider.SetError(TxtConfirmarPassword, "Debe confirmar la clave");
                    esValido = false;
                }

                if (TxtPassword.Text != TxtConfirmarPassword.Text)
                {
                    FormErrorProvider.SetError(TxtPassword, Resources.ErrorMessagePasswordsDiferentes);
                    FormErrorProvider.SetError(TxtConfirmarPassword, Resources.ErrorMessagePasswordsDiferentes);
                    esValido = false;
                }
            }

            return(esValido);
        }
Пример #2
0
        private void OkDialogButton_Click(object sender, EventArgs e)
        {
            try
            {
                string err = FormErrorProvider.GetError(UnionIntervalTextBox);
                if (!string.IsNullOrEmpty(err))
                {
                    throw new Exception(err);
                }

                if (NameComboBox.SelectedIndex == -1)
                {
                    Settings.SerialPort.PortNameValue = string.Empty;
                }
                else
                {
                    Settings.SerialPort.PortNameValue = (string)NameComboBox.Items[NameComboBox.SelectedIndex];
                }

                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                Program.ShowError(ex.Message);
            }
        }
Пример #3
0
        private void UnionIntervalTextBox_Validated(object sender, EventArgs e)
        {
            int v = Settings.UnionInterval;

            if (int.TryParse(UnionIntervalTextBox.Text, out v))
            {
                if (v < 1)
                {
                    throw new Exception("Чило должно быть больше нуля!");
                }
                Settings.UnionInterval = v;
                FormErrorProvider.SetError(UnionIntervalTextBox, null);
            }
            else
            {
                FormErrorProvider.SetError(UnionIntervalTextBox, string.Format("'{0}' не является целым числом!", UnionIntervalTextBox.Text));
            }
        }
Пример #4
0
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            var esValido = this.ValidarForm();

            if (FormErrorProvider.GetError(dtpDate) != "")
            {
                esValido = false;
            }

            if (!esValido)
            {
                this.DialogResult = DialogResult.None;
            }
            else
            {
                using (var service = _serviceFactory.Create <ISiloEmptyingService>())
                {
                    var validDate = service.VerifyDate(_batch.Id, dtpDate.Value.ToZeroTime(), _emptyingId);
                    if (!validDate)
                    {
                        this.FormErrorProvider.SetError(dtpDate, "Ya existe un vaciamiento de silo registrado para la fecha ingresada");
                        this.DialogResult = DialogResult.None;
                    }
                    else
                    {
                        if (_emptyingId == Guid.Empty)
                        {
                            var siloEmptying = GetSiloEmptyingCreate();
                            service.Create(siloEmptying);

                            OnSiloEmptyingCreated(siloEmptying);
                        }
                        else
                        {
                            GetSiloEmptyingEdit();
                            service.Edit(_siloEmptying);
                            OnSiloEmptyingCreated(_siloEmptying);
                        }
                        this.Close();
                    }
                }
            }
        }
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            var esValido = this.ValidarForm();

            if (FormErrorProvider.GetError(dtpStartDate) != "")
            {
                esValido = false;
            }

            if (!esValido)
            {
                this.DialogResult = DialogResult.None;
            }
            else
            {
                if (_batchMedicineId == Guid.Empty)
                {
                    var batchVaccinenModel = GetBatchMedicineCreate();
                    var batchVaccine       = batchVaccinenModel.ToBatchMedicine();

                    using (var service = _serviceFactory.Create <IBatchMedicineService>())
                    {
                        service.Create(batchVaccine);
                    }

                    OnBatchMedicineCreated(batchVaccine);
                }
                else
                {
                    GetBatchMedicineEdit();
                    using (var service = _serviceFactory.Create <IBatchMedicineService>())
                    {
                        service.Edit(_batchMedicine);
                    }

                    OnBatchMedicineCreated(_batchMedicine);
                }

                this.Close();
            }
        }