protected void btnAdd_Click(object sender, EventArgs e) { OperationResult objOperationResult = new OperationResult(); typeofeepDto objtypeofeepDto = new typeofeepDto(); HistoryBL oHistoryBL = new HistoryBL(); if (Session["v_TypeofEEPId"] == null) { objtypeofeepDto.i_TypeofEEPId = int.Parse(ddlEpps.SelectedValue.ToString()); objtypeofeepDto.v_HistoryId = Session["v_HistoryId"].ToString(); objtypeofeepDto.r_Percentage = txtPorcentaje11.Text == ""? (float?)null :int.Parse(txtPorcentaje11.Text); oHistoryBL.AddTypeOfEEPP(ref objOperationResult, objtypeofeepDto, ((ClientSession)Session["objClientSession"]).GetAsList()); Session["v_TypeofEEPId"] = null; } else { objtypeofeepDto.v_TypeofEEPId = Session["v_TypeofEEPId"].ToString(); objtypeofeepDto.i_TypeofEEPId = int.Parse(ddlEpps.SelectedValue.ToString()); objtypeofeepDto.v_HistoryId = Session["v_HistoryId"].ToString(); objtypeofeepDto.r_Percentage = int.Parse(txtPorcentaje11.Text); oHistoryBL.UpdateTypeOfEEPP(ref objOperationResult, objtypeofeepDto, ((ClientSession)Session["objClientSession"]).GetAsList()); } ddlEpps.SelectedValue = "-1"; txtPorcentaje11.Text = ""; ActualizarGrilla(); }
private void btnSave_Click(object sender, EventArgs e) { OperationResult objOperationResult = new OperationResult(); _workstationdangersListDto = new List <workstationdangersDto>(); _typeofeepListDto = new List <typeofeepDto>(); _workstationdangersListDtoDelete = new List <workstationdangersDto>(); _typeofeepListDtoDelete = new List <typeofeepDto>(); _typeofeepListUpdate = new List <typeofeepDto>(); _workstationdangersListDtoUpdate = new List <workstationdangersDto>(); HistoryBL objHistoryBL = new HistoryBL(); if (ultraValidator1.Validate(true, false).IsValid) { if (txtOrganization.Text.Trim() == string.Empty) { MessageBox.Show("Por favor ingrese un nombre apropiado para Organización.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (txtTypeActivity.Text.Trim() == string.Empty) { MessageBox.Show("Por favor ingrese un nombre apropiado para Tipo de Actividad.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (txtOccupation.Text.Trim() == string.Empty) { MessageBox.Show("Por favor ingrese un nombre apropiado para Puesto de Trabajo.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //if (txtGeographicalHeight.Text.Trim() == string.Empty) //{ // MessageBox.Show("Por favor ingrese un nombre apropiado para Altura Geográfica", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; //} if (_Mode == "New") { _objhistoryDto = new historyDto(); _objhistoryDto.v_PersonId = _PacientId; _objhistoryDto.d_StartDate = dtpDateTimeStar.Value.Date; _objhistoryDto.d_EndDate = dptDateTimeEnd.Value.Date; _objhistoryDto.v_Organization = txtOrganization.Text; _objhistoryDto.v_TypeActivity = txtTypeActivity.Text; _objhistoryDto.v_workstation = txtOccupation.Text; _objhistoryDto.i_TrabajoActual = chkPuestoActual.Checked == true? 1 :0; _objhistoryDto.i_TypeOperationId = int.Parse(ddlTypeOperationId.SelectedValue.ToString()); _objhistoryDto.i_GeografixcaHeight = txtGeographicalHeight.Text == "" ? 0 : int.Parse(txtGeographicalHeight.Text.ToString()); _HistoryId = objHistoryBL.AddHistory(ref objOperationResult, _TempWorkstationDangersList, _TempTypeOfEEPList, _objhistoryDto, Globals.ClientSession.GetAsList()); } else if (_Mode == "Edit") { _objhistoryDto.v_PersonId = _PacientId; _objhistoryDto.d_StartDate = dtpDateTimeStar.Value.Date; _objhistoryDto.d_EndDate = dptDateTimeEnd.Value.Date; _objhistoryDto.v_Organization = txtOrganization.Text; _objhistoryDto.v_TypeActivity = txtTypeActivity.Text; _objhistoryDto.v_workstation = txtOccupation.Text; _objhistoryDto.i_TrabajoActual = chkPuestoActual.Checked == true ? 1 : 0; _objhistoryDto.i_TypeOperationId = int.Parse(ddlTypeOperationId.SelectedValue.ToString()); _objhistoryDto.i_GeografixcaHeight = txtGeographicalHeight.Text == "" ? 0 : int.Parse(txtGeographicalHeight.Text.ToString()); //Temporal Peligros foreach (var item in _TempWorkstationDangersList) { //Add if (item.i_RecordType == (int)RecordType.Temporal && item.i_RecordStatus == (int)RecordStatus.Agregado) { workstationdangersDto workstationdangersDto = new workstationdangersDto(); workstationdangersDto.i_DangerId = item.i_DangerId; workstationdangersDto.v_TimeOfExposureToNoise = item.v_TimeOfExposureToNoise; workstationdangersDto.i_NoiseLevel = item.i_NoiseLevel; workstationdangersDto.i_NoiseSource = item.i_NoiseSource; _workstationdangersListDto.Add(workstationdangersDto); } // Update if (item.i_RecordType == (int)RecordType.NoTemporal && (item.i_RecordStatus == (int)RecordStatus.Modificado || item.i_RecordStatus == (int)RecordStatus.Grabado)) { workstationdangersDto workstationdangersDto = new workstationdangersDto(); workstationdangersDto.v_WorkstationDangersId = item.v_WorkstationDangersId; workstationdangersDto.i_DangerId = item.i_DangerId; workstationdangersDto.v_TimeOfExposureToNoise = item.v_TimeOfExposureToNoise; workstationdangersDto.i_NoiseLevel = item.i_NoiseLevel; workstationdangersDto.i_NoiseSource = item.i_NoiseSource; _workstationdangersListDtoUpdate.Add(workstationdangersDto); } //Delete if (item.i_RecordType == (int)RecordType.NoTemporal && item.i_RecordStatus == (int)RecordStatus.EliminadoLogico) { workstationdangersDto workstationdangersDto = new workstationdangersDto(); workstationdangersDto.v_WorkstationDangersId = item.v_WorkstationDangersId; workstationdangersDto.i_DangerId = item.i_DangerId; _workstationdangersListDtoDelete.Add(workstationdangersDto); } } //Temporal EPP foreach (var item in _TempTypeOfEEPList) { //Add if (item.i_RecordType == (int)RecordType.Temporal && item.i_RecordStatus == (int)RecordStatus.Agregado) { typeofeepDto typeofeepDto = new typeofeepDto(); typeofeepDto.i_TypeofEEPId = item.i_TypeofEEPId; typeofeepDto.r_Percentage = item.r_Percentage; _typeofeepListDto.Add(typeofeepDto); } // Update if (item.i_RecordType == (int)RecordType.NoTemporal && (item.i_RecordStatus == (int)RecordStatus.Modificado || item.i_RecordStatus == (int)RecordStatus.Grabado)) { typeofeepDto typeofeepDto = new typeofeepDto(); typeofeepDto.v_TypeofEEPId = item.v_TypeofEEPId; typeofeepDto.r_Percentage = item.r_Percentage; _typeofeepListUpdate.Add(typeofeepDto); } //Delete if (item.i_RecordType == (int)RecordType.NoTemporal && item.i_RecordStatus == (int)RecordStatus.EliminadoLogico) { typeofeepDto typeofeepDto = new typeofeepDto(); typeofeepDto.v_TypeofEEPId = item.v_TypeofEEPId; //typeofeepDto.i_TypeofEEPId = item.i_TypeofEEPId; _typeofeepListDtoDelete.Add(typeofeepDto); } } _objHistoryBL.UpdateHistory(ref objOperationResult, _workstationdangersListDto, _workstationdangersListDtoDelete, _workstationdangersListDtoUpdate, _typeofeepListDto, _typeofeepListUpdate, _typeofeepListDtoDelete, _objhistoryDto, Globals.ClientSession.GetAsList()); } //// Analizar el resultado de la operación if (objOperationResult.Success == 1) // Operación sin error { this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else // Operación con error { MessageBox.Show("Error en operación:" + System.Environment.NewLine + objOperationResult.ExceptionMessage, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); // Se queda en el formulario. } } else { MessageBox.Show("Por favor corrija la información ingresada. Vea los indicadores de error.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }