public void AgregarNota() { NotaISSQL ntgw = new NotaISSQL(); NotaIS nota = new NotaIS(); nota.IdAlmacen = Almacen.ElementAt(0).IdAlmacen; // Logica de Referencia de documento if (SelectedOrden!=null || SelectedGuia!=null || SelectedDevolucion!=null || SelectedSolicitud !=null) { // si hay documento de referencia colocar id; nota.IdDoc = TxtDocId; } else { //Si no existe documento de referencia colocar 0 nota.IdDoc = 0; } if (String.IsNullOrEmpty(SelectedMotivo)) { _windowManager.ShowDialog(new AlertViewModel(_windowManager, "No se pudo guardar")); return; } nota.IdMotivo = DataObjects.Almacen.MotivoSQL.BuscarMotivo(SelectedMotivo).Id; nota.IdResponsable = Responsable.ElementAt(0).IdUsuario; nota.Observaciones = Observaciones; nota.Tipo = 1; nota.LstProducto = this.LstProductos; nota.IdNota = ntgw.AgregarNota(nota); if (nota.IdNota > 0) { ProductoxTiendaSQL ptgw = new ProductoxTiendaSQL(); ProductoSQL pgw = new ProductoSQL(); List<ProductoCant> list = ntgw.BuscarNotas(nota.IdNota); if (u.IdTienda != 0) ptgw.ActualizarStockEntrada(list, u.IdTienda); else pgw.ActualizarStockEntrada(list); //Actualizar Documentos de Referencia para darlos por Terminados! :) if (SelectedOrden != null) { guardarOrden(list); } if (SelectedGuia != null) { CambiarEstadoGuia(SelectedGuia); } if (SelectedDevolucion != null) { CambiarEstadoDevolucion(SelectedDevolucion); } if (SelectedSolicitud != null) { CambiarEstadoSolicitud(SelectedSolicitud); } _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Nota Creada")); //1: Agregar, 2: Editar, 3: Eliminar, 4: Recuperar, 5: Desactivar DataObjects.Seguridad.LogSQL.RegistrarActividad("Registrar Nota de Ingreso", nota.IdNota.ToString(), 1); } else { _windowManager.ShowDialog(new AlertViewModel(_windowManager, "No se pudo guardar")); } }