private async void btnAgregar_Click(object sender, RoutedEventArgs e) { try { String cont = ""; if (txtContrato.Text != null) { cont = txtContrato.Text; } else { await this.ShowMessageAsync(null, "Ingrese el numero de contrato"); } String crea = ""; if (txtCreacion.Text != null) { crea = txtCreacion.Text; } else { await this.ShowMessageAsync(null, "Ingrese la fecha de creacion del contrato"); } String ter = ""; if (txtTermino.Text != null) { ter = txtTermino.Text; } else { await this.ShowMessageAsync(null, "Ingrese la fecha de termino del contrato"); } String fein = ""; if (txtFeIni.Text != null) { fein = txtFeIni.Text; } else { await this.ShowMessageAsync(null, "Ingrese la fecha de inicio del evento"); } String fete = ""; if (txtFeTer.Text != null) { fete = txtFeTer.Text; } else { await this.ShowMessageAsync(null, "Ingrese la fecha de termino del evento"); } String total = ""; if (txtMonto != null) { total = txtMonto.Text; } String obs = ""; if (txtObs != null) { obs = txtObs.Text; } else { await this.ShowMessageAsync(null, "Ingrese una observacion"); } String nom = ""; if (txtNombre != null) { nom = txtNombre.Text; } else { await this.ShowMessageAsync(null, "Ingrese un nombre"); } Valorizador valor = new Valorizador(); double valorBass = ((BibliotecaClase.ModalidadServicio)cboxModalidades.SelectedItem).ValorBase; //variable para valorizar string numero = txtContrato.Text; DateTime _creacion = Convert.ToDateTime(txtCreacion.Text); DateTime _termino = Convert.ToDateTime(txtTermino.Text); string rutcli = ((BibliotecaClase.Cliente)cboRutAso.SelectedItem).Rut; string idModalidad = ((BibliotecaClase.ModalidadServicio)cboxModalidades.SelectedItem).IdModalidad; int idTipoEvento = ((BibliotecaClase.ModalidadServicio)cboxModalidades.SelectedItem).IdTipoEvento; DateTime _fechahorainicio = Convert.ToDateTime(txtFeIni.Text); DateTime _fechahoratermino = Convert.ToDateTime(txtFeTer.Text); int Asistentes = Convert.ToInt32(txtAsistentes.Text); int PerAdicional = Convert.ToInt32(txtPersonalAdic.Text); bool _vigente = false; float monto = float.Parse(txtMonto.Text); string _observaciones = txtObs.Text; if ((string.IsNullOrEmpty(txtContrato.Text) != true && string.IsNullOrEmpty(txtPersonalAdic.Text) != true && string.IsNullOrEmpty(txtMonto.Text) != true && string.IsNullOrEmpty(txtObs.Text) != true && string.IsNullOrEmpty(txtFeIni.Text) != true && string.IsNullOrEmpty(txtFeTer.Text) != true && string.IsNullOrEmpty(txtTermino.Text) != true) && string.IsNullOrEmpty(txtNombre.Text) != true && string.IsNullOrEmpty(txtCreacion.Text) != true && string.IsNullOrEmpty(txtTermino.Text) != true) { BibliotecaClase.Contrato con = new BibliotecaClase.Contrato() { _numero = numero, _creacion = _creacion, _termino = _termino, RutCliente = rutcli, idModalidad = idModalidad, idTipoEvento = idTipoEvento, _fechahorainicio = _fechahorainicio, _fechahoratermino = _fechahoratermino, asistentes = Asistentes, personalAdicional = PerAdicional, Realizado = _vigente, ValorTotalContrato = monto, Observaciones = _observaciones, }; BibliotecaClase.Contrato noesdao = new BibliotecaClase.Contrato(); bool resp = noesdao.ActualizarContrato(con); await this.ShowMessageAsync(null, resp? "Modificado Correctamente" : "Ups! Ha ocurrido un pequeñito error"); } } catch (ArgumentException ex) { MessageBox.Show(ex.Message); } catch (Exception x) { Logger.Mensaje(x.Message); await this.ShowMessageAsync(null, "Error de ingreso de datos"); MessageBox.Show(x.Message); } }
private async void btnActualizar_Click(object sender, RoutedEventArgs e) { try { //FCA Valorizador valor = new Valorizador(); double valorBass = ((BibliotecaClase.ModalidadServicio)cboxModalidades.SelectedItem).ValorBase; //variable para valorizar string numero = txtContrato.Text; DateTime _creacion = Convert.ToDateTime(txtCreacion.Text); DateTime _termino = Convert.ToDateTime(txtTermino.Text); string rutcli = ((BibliotecaClase.ClientesParacBox)cboRutAso.SelectedItem).rutDeMiCli; string idModalidad = ((BibliotecaClase.ModalidadServicio)cboxModalidades.SelectedItem).IdModalidad; int idTipoEvento = ((BibliotecaClase.ModalidadServicio)cboxModalidades.SelectedItem).IdTipoEvento; DateTime _fechahorainicio = Convert.ToDateTime(txtFIn.Text); DateTime _fechahoratermino = Convert.ToDateTime(txtTerEven.Text); int Asistentes = Convert.ToInt32(txtAsistentes.Text); int PerAdicional = Convert.ToInt32(txtPersonalAdic.Text); bool _vigente = false; float monto = valor.ValorContrato(valorBass, PerAdicional, Asistentes); string _observaciones = txtObs.Text; if ((string.IsNullOrEmpty(txtContrato.Text) != true && string.IsNullOrEmpty(txtPersonalAdic.Text) != true && string.IsNullOrEmpty(txtMonto.Text) != true && string.IsNullOrEmpty(txtObs.Text) != true && string.IsNullOrEmpty(txtFIn.Text) != true && string.IsNullOrEmpty(txtTerEven.Text) != true && string.IsNullOrEmpty(txtTermino.Text) != true) && string.IsNullOrEmpty(txtCreacion.Text) != true && string.IsNullOrEmpty(txtTermino.Text) != true) { BibliotecaClase.Contrato con = new BibliotecaClase.Contrato() { _numero = numero, _creacion = _creacion, _termino = _termino, RutCliente = rutcli, idModalidad = idModalidad, idTipoEvento = idTipoEvento, _fechahorainicio = _fechahorainicio, _fechahoratermino = _fechahoratermino, asistentes = Asistentes, personalAdicional = PerAdicional, Realizado = _vigente, ValorTotalContrato = monto, Observaciones = _observaciones, }; BibliotecaClase.Contrato noesdao = new BibliotecaClase.Contrato(); bool resp = noesdao.ActualizarContrato(con); await this.ShowMessageAsync(null, resp? "Modificado" : "No se ha podido Modificar"); } } catch (ArgumentException ex) { MessageBox.Show(ex.Message); } catch (Exception x) { Logger.Mensaje(x.Message); await this.ShowMessageAsync(null, "Error de ingreso de datos"); MessageBox.Show(x.Message); } }