public rolcuotadetalleDto GetRolCuotaDetalle(ref OperationResult pobjOperationResult, string pstrRolCuotaDetalleId) { //mon.IsActive = true; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); rolcuotadetalleDto objDtoEntity = null; var objEntity = (from a in dbContext.rolcuotadetalle where a.v_RolCuotaDetalleId == pstrRolCuotaDetalleId select a).FirstOrDefault(); if (objEntity != null) { objDtoEntity = rolcuotadetalleAssembler.ToDTO(objEntity); } pobjOperationResult.Success = 1; return(objDtoEntity); } catch (Exception ex) { pobjOperationResult.Success = 0; pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex); return(null); } }
public void AddRolCuotaDetalle(ref OperationResult pobjOperationResult, rolcuotadetalleDto pobjDtoEntity, List <string> ClientSession) { //mon.IsActive = true; string NewId = "(No generado)"; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); rolcuotadetalle objEntity = rolcuotadetalleAssembler.ToEntity(pobjDtoEntity); objEntity.d_InsertDate = DateTime.Now; objEntity.i_InsertUserId = Int32.Parse(ClientSession[2]); objEntity.i_IsDeleted = 0; // Autogeneramos el Pk de la tabla int intNodeId = int.Parse(ClientSession[0]); NewId = Common.Utils.GetNewId(intNodeId, Utils.GetNextSecuentialId(intNodeId, 202), "RA");; objEntity.v_RolCuotaDetalleId = NewId; dbContext.AddTorolcuotadetalle(objEntity); dbContext.SaveChanges(); pobjOperationResult.Success = 1; // Llenar entidad Log //LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "ÁREA", "v_RolCuotaDetalleId=" + NewId.ToString(), Success.Ok, null); return; } catch (Exception ex) { pobjOperationResult.Success = 0; pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex); // Llenar entidad Log //LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "ÁREA", "v_RolCuotaDetalleId=" + NewId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage); return; } }
private void btnGrabar_Click(object sender, EventArgs e) { OperationResult objOperationResult = new OperationResult(); RolCuotaBL oRolCuotaBL = new RolCuotaBL(); RolCuotaDetalleBL oRolCuotaDetalleBL = new RolCuotaDetalleBL(); rolcuotaDto orolcuotaDto = new rolcuotaDto(); if (uvCuota.Validate(true, false).IsValid) { if (_TempRolCuotaDetalleList == null) { MessageBox.Show("No se permite mientras la lista esté vacía", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (_TempRolCuotaDetalleList.Count == 0) { MessageBox.Show("No se permite mientras la lista esté vacía", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //Cabecera orolcuotaDto.i_RolId = int.Parse(cbRolVenta.SelectedValue.ToString()); string RolCuotaId = oRolCuotaBL.AddRolCuota(ref objOperationResult, orolcuotaDto, Globals.ClientSession.GetAsList()); //Detalle foreach (var item in _TempRolCuotaDetalleList) { rolcuotadetalleDto orolcuotadetalleDto = new rolcuotadetalleDto(); orolcuotadetalleDto.v_IdProducto = item.v_IdProducto; orolcuotadetalleDto.v_ProductoNombre = item.v_ProductoNombre; orolcuotadetalleDto.v_RolCuotaId = RolCuotaId; orolcuotadetalleDto.i_Cuota = item.i_Cuota; oRolCuotaDetalleBL.AddRolCuotaDetalle(ref objOperationResult, orolcuotadetalleDto, Globals.ClientSession.GetAsList()); } if (objOperationResult.Success == 1) { MessageBox.Show("Se grabó correctamente", "INFORMACIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else// Operación con error { MessageBox.Show(objOperationResult.ErrorMessage, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void UpdateRolCuotaDetalle(ref OperationResult pobjOperationResult, rolcuotadetalleDto pobjDtoEntity, List <string> ClientSession) { //mon.IsActive = true; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); // Obtener la entidad fuente var objEntitySource = (from a in dbContext.rolcuotadetalle where a.v_RolCuotaDetalleId == pobjDtoEntity.v_RolCuotaDetalleId select a).FirstOrDefault(); // Crear la entidad con los datos actualizados pobjDtoEntity.d_UpdateDate = DateTime.Now; pobjDtoEntity.i_UpdateUserId = Int32.Parse(ClientSession[2]); rolcuotadetalle objEntity = rolcuotadetalleAssembler.ToEntity(pobjDtoEntity); // Copiar los valores desde la entidad actualizada a la Entidad Fuente dbContext.rolcuotadetalle.ApplyCurrentValues(objEntity); // Guardar los cambios dbContext.SaveChanges(); pobjOperationResult.Success = 1; // Llenar entidad Log //LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "ÁREA", "v_RolCuotaDetalleId=" + objEntity.v_RolCuotaDetalleId.ToString(), Success.Ok, null); return; } catch (Exception ex) { pobjOperationResult.Success = 0; pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex); // Llenar entidad Log //LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "ÁREA", "v_RolCuotaDetalleId=" + pobjDtoEntity.v_RolCuotaDetalleId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage); return; } }