private async void btnGuardar_Click(object sender, EventArgs e) { try { motivoTraslado = new MotivoTraslado(); motivoTraslado.nombre = txtMotivo.Text; motivoTraslado.estado = chkActivo.Checked ? 1 : 0; Response response = await guiaRemisionModel.guardarMTraslado(motivoTraslado); if (response.id > 0) { MessageBox.Show(response.msj, "guardar", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show(response.msj, "guardar", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "btnGuardar_Click", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public async Task <IActionResult> Edit(string id, MotivoTraslado motivoTraslado) { try { if (!string.IsNullOrEmpty(id)) { var response = await apiServicio.EditarAsync(id, motivoTraslado, new Uri(WebApp.BaseAddressRM), "api/MotivoTraslado"); if (response.IsSuccess) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), EntityID = string.Format("{0} : {1}", "Sistema", id), LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), Message = "Se ha actualizado un registro sistema", UserName = "******" }); return(this.Redireccionar($"{Mensaje.Informacion}|{Mensaje.Satisfactorio}")); } ViewData["Error"] = response.Message; return(View(motivoTraslado)); } return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.RegistroNoExiste}")); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Editando un Motivo de Traslado", ExceptionTrace = ex.Message, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.ErrorEditar}")); } }
//mtraslado/guardar public async Task <Response> guardarMTraslado(MotivoTraslado param) { try { // localhost:8080/admeli/xcore2/xcore/services.php/mtraslado/guardar return(await webService.POST <MotivoTraslado, Response>("mtraslado", "guardar", param)); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> Create(MotivoTraslado motivoTraslado) { try { var response = await apiServicio.InsertarAsync(motivoTraslado, new Uri(WebApp.BaseAddressRM), "api/MotivoTraslado/InsertarMotivoTraslado"); if (response.IsSuccess) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), ExceptionTrace = null, Message = "Se ha creado un Motivo de Traslado", UserName = "******", LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), EntityID = string.Format("{0} {1}", "Motivo de Traslado:", motivoTraslado.IdMotivoTraslado) }); return(this.Redireccionar($"{Mensaje.Informacion}|{Mensaje.Satisfactorio}")); } ViewData["Error"] = response.Message; return(View(motivoTraslado)); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Creando Motivo de Traslado", ExceptionTrace = ex.Message, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.ErrorCrear}")); } }
private async void guardar_Click(object sender, EventArgs e) { Bloqueo.bloquear(this, true); if (!validarCampos()) { Bloqueo.bloquear(this, false); return; } guiaRemisionGuardar.correlativo = txtCorrelativo.Text; guiaRemisionGuardar.destino = ubicacionGeograficaDestino != null ? ubicacionGeograficaDestino.idUbicacionGeografica: currentguiaRemision.destino; guiaRemisionGuardar.direccionDestino = txtDireccionDestino.Text; guiaRemisionGuardar.direccionOrigen = txtDirreccionOrigen.Text; int estado = 0; switch (cbxEstado.Text) { case "Pendiente": estado = 3; break; case "Revisado": estado = 2; break; case "Enviado": estado = 1; break; } guiaRemisionGuardar.estado = estado; guiaRemisionGuardar.idEmpresaTransporte = (int)cbxETransporte.SelectedValue; guiaRemisionGuardar.idMotivoTraslado = (int)cbxMotivo.SelectedValue; guiaRemisionGuardar.idTipoDocumento = 9;// guia remision guiaRemisionGuardar.licenciaDeConducir = txtLicConducir.Text; guiaRemisionGuardar.marcaYPlaca = txtMarca.Text; guiaRemisionGuardar.observacion = txtObservacion.Text; guiaRemisionGuardar.origen = ubicacionGeograficaOrigen != null ? ubicacionGeograficaOrigen.idUbicacionGeografica : currentguiaRemision.origen; guiaRemisionGuardar.serie = txtSerie.Text; // datos para modifcar guia remision guiaRemisionGuardar.idGuiaRemision = currentguiaRemision != null? currentguiaRemision.idGuiaRemision:0; guiaRemisionGuardar.fecha = currentguiaRemision != null ? currentguiaRemision.fecha.date: guiaRemisionGuardar.fecha; // hallamos el ETransporte EmpresaTransporte empresaTransporte = listEmpresaTransporte.Find(x => x.idEmpresaTransporte == (int)cbxETransporte.SelectedValue); MotivoTraslado motivo = listMotivoTraslado.Find(x => x.idMotivoTraslado == (int)cbxMotivo.SelectedValue); guiaRemisionGuardar.razonSocial = empresaTransporte.razonSocial; guiaRemisionGuardar.nombre = motivo.nombre; guiaRemisionGuardar.idNotaSalida = currentNotaSalida != null ? currentNotaSalida.idNotaSalida : currentguiaRemision.idNotaSalida; guiaRemisionGuardar.motivo = txtMotivo.Text; guiaRemisionGuardar.numeroDocumento = txtNroDocumento.Text; guiaRemisionGuardar.idAlmacen = currentNotaSalida != null ? currentNotaSalida.idAlmacen : currentguiaRemision.idAlmacen; int numert = 0; foreach (DetalleNotaSalida detalle in listDetalleNotaSalida) { detalle.idGuiaRemision = currentguiaRemision != null ? currentguiaRemision.idGuiaRemision : 0; ListDetallesGuiaRemision.Add("id" + numert, detalle); numert++; } notaSalidaGuardarRemision.IdNotaSalida = currentNotaSalida != null ? currentNotaSalida.idNotaSalida : currentguiaRemision.idNotaSalida; almacenGuardarRemision.IdAlmacen = currentNotaSalida != null ? currentNotaSalida.idAlmacen : currentguiaRemision.idAlmacen; listObjetos.Add(guiaRemisionGuardar); listObjetos.Add(ListDetallesGuiaRemision); listObjetos.Add(notaSalidaGuardarRemision); listObjetos.Add(almacenGuardarRemision); try { ResponseNotaGuardar responseNotaGuardar = null; Response response = null; if (nuevo) { responseNotaGuardar = await guiaRemisionModel.guardar(listObjetos); guardar.Enabled = false; } else { responseNotaGuardar = new ResponseNotaGuardar(); response = await guiaRemisionModel.modificar(listObjetos); responseNotaGuardar.id = response.id; responseNotaGuardar.msj = response.msj; } if (responseNotaGuardar.id > 0) { MessageBox.Show(responseNotaGuardar.msj + " correctamente", "guardar", MessageBoxButtons.OK, MessageBoxIcon.Information); ListDetallesGuiaRemision.Clear(); guardar.Enabled = false; Bloqueo.bloquear(this, false); this.Close(); } else { MessageBox.Show(responseNotaGuardar.msj, "guardar", MessageBoxButtons.OK, MessageBoxIcon.Warning); Bloqueo.bloquear(this, false); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Response Nota Guardar", MessageBoxButtons.OK, MessageBoxIcon.Warning); Bloqueo.bloquear(this, false); } }