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); } }
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(); } }