public componentfieldsDto GetComponentFields(ref OperationResult pobjOperationResult, string pstrComponentFieldId, string pstrComponentId) { //mon.IsActive = true; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); componentfieldsDto objDtoEntity = null; var objEntity = (from a in dbContext.componentfields where a.v_ComponentFieldId == pstrComponentFieldId && a.v_ComponentId == pstrComponentId select a).FirstOrDefault(); if (objEntity != null) { objDtoEntity = componentfieldsAssembler.ToDTO(objEntity); } pobjOperationResult.Success = 1; return(objDtoEntity); } catch (Exception ex) { pobjOperationResult.Success = 0; pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex); return(null); } }
public bool UpdateComponentFields(ref OperationResult pobjOperationResult, componentfieldsDto pobjDtoEntity, string pstrTextLableOld, string pstrTextLableNew, List <string> ClientSession) { //mon.IsActive = true; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); if (pstrTextLableOld.ToUpper().Trim() != pstrTextLableNew.ToUpper().Trim()) { var query1 = (from a in dbContext.componentfield join b in dbContext.componentfields on a.v_ComponentFieldId equals b.v_ComponentFieldId where a.v_TextLabel.ToUpper() == pstrTextLableNew.ToUpper() && b.v_ComponentId == pobjDtoEntity.v_ComponentId && b.v_Group == pobjDtoEntity.v_Group select a).ToList(); if (query1.Count > 0) { pobjOperationResult.ErrorMessage = "Nombre del componente duplicado"; return(false); } } // Obtener la entidad fuente var objEntitySource = (from a in dbContext.componentfields where a.v_ComponentFieldId == pobjDtoEntity.v_ComponentFieldId && a.v_ComponentId == pobjDtoEntity.v_ComponentId select a).FirstOrDefault(); // Crear la entidad con los datos actualizados pobjDtoEntity.d_UpdateDate = DateTime.Now; pobjDtoEntity.i_UpdateUserId = Int32.Parse(ClientSession[2]); componentfields objEntity = componentfieldsAssembler.ToEntity(pobjDtoEntity); // Copiar los valores desde la entidad actualizada a la Entidad Fuente dbContext.componentfields.ApplyCurrentValues(objEntity); // Guardar los cambios dbContext.SaveChanges(); pobjOperationResult.Success = 1; // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "CAMPOS DEL COMPONENTE", "v_ComponentId=" + objEntity.v_ComponentId + "v_ComponentFieldId= " + objEntity.v_ComponentFieldId, Success.Ok, null); return(true); } 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, "CAMPOS DEL COMPONENTE", "v_ComponentId= No generado ,v_ComponentFieldId= No generado ", Success.Failed, pobjOperationResult.ExceptionMessage); return(false); } }
private void frmMedicalExamFieldEdicion_Load(object sender, EventArgs e) { OperationResult objOperationResult = new OperationResult(); // Establecer el filtro inicial para los datos _TempSearchComponentFieldsList = new List <SearchComponentFieldsList>(); _TempSearchComponentFieldsList = _objMedicalExamFieldsBL.FillComponentFieldList(ref objOperationResult); txtLabel.Select(); txtLabel.DisplayMember = "Nombre"; txtLabel.ValueMember = "Nombre"; txtLabel.DataSource = _TempSearchComponentFieldsList; txtLabel.AutoCompleteMode = Infragistics.Win.AutoCompleteMode.Suggest; txtLabel.AutoSuggestFilterMode = Infragistics.Win.AutoSuggestFilterMode.Contains; this.txtLabel.DropDownWidth = 750; //this.txtLabel.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns; txtLabel.DisplayLayout.Bands[0].Columns[0].Width = 290; txtLabel.DisplayLayout.Bands[0].Columns[1].Width = 250; txtLabel.DisplayLayout.Bands[0].Columns[2].Width = 190; strFilterExpression = null; //Llenado de combos Utils.LoadDropDownList(ddlGroupId, "Value1", "Id", BLL.Utils.GetSystemParameterForCombo(ref objOperationResult, 112, null), DropDownListAction.Select); Utils.LoadDropDownList(ddlUniMedId, "Value1", "Id", BLL.Utils.GetDataHierarchyForCombo(ref objOperationResult, 105, null), DropDownListAction.Select); Utils.LoadDropDownList(ddlGroup, "Value1", "", BLL.Utils.GetMedicalExamGrupo(ref objOperationResult, _MedicalExamId)); Utils.LoadDropDownList(ddlComponentId, "Value1", "Id", BLL.Utils.GetComponents(ref objOperationResult), DropDownListAction.Select); Utils.LoadDropDownList(ddlFieldAndId, "Value1", "Id", BLL.Utils.GetFieldsByComponent(ref objOperationResult, "-1", "Total"), DropDownListAction.Select); //Cargar SearchComponentFieldsList Temporalmente if (_Mode == "New") { // Additional logic here. grdDataMedicalExamFieldValue.Enabled = false; } else if (_Mode == "Edit") { grdDataMedicalExamFieldValue.Enabled = true; // Get the Entity Data _objmedicalexamfieldDto = new componentfieldDto(); _objmedicalexamfieldDto = _objMedicalExamFieldsBL.GetMedicalExamFields(ref objOperationResult, _MedicalExamFliedId); _objmedicalexamfieldsDto = _objMedicalExamFieldsBL.GetComponentFields(ref objOperationResult, _MedicalExamFliedId, _MedicalExamId); txtLabel.Text = _objmedicalexamfieldDto.v_TextLabel; _TextLabelOld = _objmedicalexamfieldDto.v_TextLabel; txtAbbreviation.Text = _objmedicalexamfieldDto.v_abbreviation; unLabelWidth.Value = _objmedicalexamfieldDto.i_LabelWidth; unValidateValue1.Text = _objmedicalexamfieldDto.r_ValidateValue1.ToString(); unValidateValue2.Text = _objmedicalexamfieldDto.r_ValidateValue2.ToString(); unMaxLenght.Text = _objmedicalexamfieldDto.i_MaxLenght.ToString(); if (_objmedicalexamfieldDto.i_IsRequired == 1) { rbYesRequired.Checked = true; } else { rbYesRequired.Checked = false; } if (_objmedicalexamfieldDto.i_IsCalculate == 1) { rbYesIsCalculate.Checked = true; } else { rbYesIsCalculate.Checked = false; } unGroupId.Text = _objmedicalexamfieldDto.i_GroupId.ToString(); txtColumn.Text = _objmedicalexamfieldDto.i_Column.ToString(); ddlGroup.Text = _objmedicalexamfieldsDto.v_Group; _DefaultText = _objmedicalexamfieldDto.v_DefaultText; ddlGroupId.SelectedValue = _objmedicalexamfieldDto.i_ControlId.ToString(); ddlUniMedId.SelectedValue = _objmedicalexamfieldDto.i_MeasurementUnitId.ToString(); unItemId.Text = _objmedicalexamfieldDto.i_ItemId.ToString(); unControlWidth.Value = _objmedicalexamfieldDto.i_WidthControl; unHeightControl.Value = _objmedicalexamfieldDto.i_HeightControl; unOrder.Value = _objmedicalexamfieldDto.i_Order; txtFormula.Text = _objmedicalexamfieldDto.v_Formula; unValidateValue1.Text = _objmedicalexamfieldDto.r_ValidateValue1.ToString(); unValidateValue2.Text = _objmedicalexamfieldDto.r_ValidateValue2.ToString(); if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 1) //Cadena Textual { unGroupId.Enabled = false; unItemId.Enabled = false; unMaxLenght.Enabled = true; objTextBox.Text = _DefaultText; } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 2) // Cadena Multimedia { unGroupId.Enabled = false; unItemId.Enabled = false; unMaxLenght.Enabled = true; objTextBox.Text = _DefaultText; } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 3) // Número Entero { unGroupId.Enabled = false; unItemId.Enabled = false; unMaxLenght.Text = "1"; unMaxLenght.Enabled = false; une.Value = _DefaultText; } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 4) // Número Decimal { unGroupId.Enabled = false; unItemId.Enabled = false; unMaxLenght.Text = "1"; unMaxLenght.Enabled = false; une.Value = _DefaultText; } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 5) // Check { unGroupId.Enabled = false; unItemId.Enabled = false; unMaxLenght.Text = "1"; unMaxLenght.Enabled = false; if (_DefaultText == "1") { chk.Checked = true; } else { chk.Checked = false; } } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 6) // Radio Button { unGroupId.Enabled = false; unItemId.Enabled = false; unMaxLenght.Text = "1"; unMaxLenght.Enabled = false; //if (_objmedicalexamfieldsDto.v_DefaultText == "1") //{ // rb1.Checked = true; //} //else //{ // rb2.Checked = true; //} } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 7) // Sino Combo { Utils.LoadDropDownList(combo, "Value1", "Id", BLL.Utils.GetSystemParameterForCombo(ref objOperationResult, 111, null), DropDownListAction.Select); combo.SelectedValue = _DefaultText; unGroupId.Enabled = false; unItemId.Enabled = false; unMaxLenght.Text = "1"; unMaxLenght.Enabled = false; } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 9) // Lista { combo.SelectedValue = _DefaultText; unMaxLenght.Text = "1"; unMaxLenght.Enabled = false; } BindGridMedicalExamFieldValues(_MedicalExamFliedId); } }
private void btnOK_Click(object sender, EventArgs e) { OperationResult objOperationResult = new OperationResult(); //string pstrFilterEpression; if (ddlGroupId.SelectedValue.ToString() == ((int)ControlType.NumeroDecimal).ToString()) { #region Validacion if (ultraValidator1.Validate(true, false).IsValid) { if (unValidateValue1.Text == "") { MessageBox.Show("Por favor ingrese un valor apropiado para Valor 1.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (unValidateValue2.Text == "") { MessageBox.Show("Por favor ingrese un valor apropiado para Valor 2.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } #endregion } if (uvMedicalExamField.Validate(true, false).IsValid) { #region Validacion if (txtLabel.Text.Trim() == "") { MessageBox.Show("Por favor ingrese un nombre apropiado para el Nombre Label.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBox.Show("¿Está seguro de agregar / modificar la Campos al examen?.", "Pregunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } #endregion if (_Mode == "New") { _objmedicalexamfieldDto = new componentfieldDto(); _objmedicalexamfieldsDto = new componentfieldsDto(); //Populate the entity //_objmedicalexamfieldDto.v_ComponentId = MedicalExamId; int indice = txtLabel.Text.IndexOf("/", 1); //_objmedicalexamfieldDto.v_TextLabel = txtLabel.Text.Substring(0, indice + 1); if (indice != -1) { _objmedicalexamfieldDto.v_TextLabel = txtLabel.Text.Substring(0, indice); } else { _objmedicalexamfieldDto.v_TextLabel = txtLabel.Text; } _objmedicalexamfieldDto.v_abbreviation = txtAbbreviation.Text; _objmedicalexamfieldDto.i_LabelWidth = (int)unLabelWidth.Value; //_objmedicalexamfieldDto.i_ItemId == null ? 0 : int.Parse(unItemId.Text.ToString()); _objmedicalexamfieldDto.r_ValidateValue1 = _objmedicalexamfieldDto.r_ValidateValue1 == null ? 0 : float.Parse(unValidateValue1.Text.ToString()); _objmedicalexamfieldDto.r_ValidateValue2 = _objmedicalexamfieldDto.r_ValidateValue2 == null ? 0 : float.Parse(unValidateValue2.Text.ToString()); //_objmedicalexamfieldsDto.v_DefaultText = txtDefaultTextMultiLine.Text; _objmedicalexamfieldDto.i_MaxLenght = int.Parse(unMaxLenght.Text.ToString()); if (rbYesRequired.Checked) { _objmedicalexamfieldDto.i_IsRequired = 1; } else { _objmedicalexamfieldDto.i_IsRequired = 0; } if (rbYesIsCalculate.Checked) { _objmedicalexamfieldDto.i_IsCalculate = 1; } else { _objmedicalexamfieldDto.i_IsCalculate = 0; } _objmedicalexamfieldDto.i_ControlId = Int32.Parse(ddlGroupId.SelectedValue.ToString()); _objmedicalexamfieldDto.i_Column = Int32.Parse(txtColumn.Text); _objmedicalexamfieldDto.i_MeasurementUnitId = Int32.Parse(ddlUniMedId.SelectedValue.ToString()); _objmedicalexamfieldDto.i_GroupId = int.Parse(unGroupId.Text.ToString()); _objmedicalexamfieldDto.i_ItemId = _objmedicalexamfieldDto.i_ItemId == null ? 0 : int.Parse(unItemId.Text.ToString()); _objmedicalexamfieldDto.i_WidthControl = (int)unControlWidth.Value; _objmedicalexamfieldDto.i_HeightControl = (int)unHeightControl.Value; _objmedicalexamfieldDto.i_Order = (int)unOrder.Value; _objmedicalexamfieldDto.v_Formula = txtFormula.Text; //_objmedicalexamfieldDto.r_ValidateValue1 = float.Parse(unValidateValue1.Text.ToString()); //_objmedicalexamfieldDto.r_ValidateValue2 = float.Parse(unValidateValue2.Text.ToString()); if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 1)//Cadena Textual { _objmedicalexamfieldDto.v_DefaultText = objTextBox.Text; } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 2) // Cadena Multimedia { _objmedicalexamfieldDto.v_DefaultText = objTextBox.Text; } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 3) // Número Entero { _objmedicalexamfieldDto.v_DefaultText = une.Value.ToString(); } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 4) // Número Decimal { _objmedicalexamfieldDto.v_DefaultText = une.Value.ToString(); } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 5) //Sino Check { if (chk.Checked) { _objmedicalexamfieldDto.v_DefaultText = "1"; // SI } else { _objmedicalexamfieldDto.v_DefaultText = "0"; // NO } } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 6) //Sino Radio Button { if (rb1.Checked) { _objmedicalexamfieldDto.v_DefaultText = "1"; // SI } else { _objmedicalexamfieldDto.v_DefaultText = "0"; // NO } } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 7) // Sino Combo { _objmedicalexamfieldDto.v_DefaultText = combo.SelectedValue.ToString(); } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 9) // Lista { _objmedicalexamfieldDto.v_DefaultText = combo.SelectedValue.ToString(); } //if (ddlGroup.SelectedIndex == 0) //{ // _objmedicalexamfieldsDto.v_Group = null; //} //else //{ _objmedicalexamfieldsDto.v_Group = ddlGroup.Text; //} //Cargar Entidad para ComponentFields _objmedicalexamfieldsDto.v_ComponentId = _MedicalExamId; //Save the data _MedicalExamFliedId = _objMedicalExamFieldsBL.AddMedicalExamFields(ref objOperationResult, _objmedicalexamfieldDto, _objmedicalexamfieldsDto, _MedicalExamId, Globals.ClientSession.GetAsList()); if (_MedicalExamFliedId != "0") { _objmedicalexamfieldDto = _objMedicalExamFieldsBL.GetMedicalExamFields(ref objOperationResult, _MedicalExamFliedId); _Mode = "Edit"; } } else if (_Mode == "Edit") { //Populate the entity int indice = txtLabel.Text.IndexOf("/", 1); if (indice != -1) { _objmedicalexamfieldDto.v_TextLabel = txtLabel.Text.Substring(0, indice); } else { _objmedicalexamfieldDto.v_TextLabel = txtLabel.Text; } //_objmedicalexamfieldDto.v_TextLabel = txtLabel.Text; _objmedicalexamfieldDto.i_LabelWidth = (int)unLabelWidth.Value; _objmedicalexamfieldDto.v_abbreviation = txtAbbreviation.Text; _objmedicalexamfieldDto.r_ValidateValue1 = float.Parse(unValidateValue1.Text.ToString()); _objmedicalexamfieldDto.r_ValidateValue2 = float.Parse(unValidateValue2.Text.ToString()); _objmedicalexamfieldDto.i_MaxLenght = int.Parse(unMaxLenght.Text.ToString()); if (rbYesRequired.Checked) { _objmedicalexamfieldDto.i_IsRequired = 1; } else { _objmedicalexamfieldDto.i_IsRequired = 0; } if (rbYesIsCalculate.Checked) { _objmedicalexamfieldDto.i_IsCalculate = 1; } else { _objmedicalexamfieldDto.i_IsCalculate = 0; } _objmedicalexamfieldDto.i_ControlId = Int32.Parse(ddlGroupId.SelectedValue.ToString()); _objmedicalexamfieldDto.i_Column = Int32.Parse(txtColumn.Text); _objmedicalexamfieldDto.i_MeasurementUnitId = Int32.Parse(ddlUniMedId.SelectedValue.ToString()); _objmedicalexamfieldDto.i_GroupId = int.Parse(unGroupId.Text.ToString()); _objmedicalexamfieldDto.i_ItemId = int.Parse(unItemId.Text.ToString()); _objmedicalexamfieldDto.i_WidthControl = (int)unControlWidth.Value; _objmedicalexamfieldDto.i_HeightControl = (int)unHeightControl.Value; _objmedicalexamfieldDto.i_Order = (int)unOrder.Value; _objmedicalexamfieldDto.v_Formula = txtFormula.Text; //_objmedicalexamfieldDto.r_ValidateValue1 = float.Parse(unValidateValue1.Text.ToString()); //_objmedicalexamfieldDto.r_ValidateValue2 = float.Parse(unValidateValue2.Text.ToString()); _objmedicalexamfieldDto.r_ValidateValue1 = _objmedicalexamfieldDto.r_ValidateValue1 == null ? 0 : float.Parse(unValidateValue1.Text.ToString()); _objmedicalexamfieldDto.r_ValidateValue2 = _objmedicalexamfieldDto.r_ValidateValue2 == null ? 0 : float.Parse(unValidateValue2.Text.ToString()); if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 1)//Cadena Textual { _objmedicalexamfieldDto.v_DefaultText = objTextBox.Text; } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 2) // Cadena Multimedia { _objmedicalexamfieldDto.v_DefaultText = objTextBox.Text; } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 3) // Número Entero { _objmedicalexamfieldDto.v_DefaultText = une.Value.ToString(); } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 4) // Número Decimal { _objmedicalexamfieldDto.v_DefaultText = une.Value.ToString(); } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 5) //Sino Check { if (chk.Checked) { _objmedicalexamfieldDto.v_DefaultText = "1"; // SI } else { _objmedicalexamfieldDto.v_DefaultText = "0"; // NO } } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 6) //Sino Radio Button { if (rb1.Checked) { _objmedicalexamfieldDto.v_DefaultText = "1"; // SI } else { _objmedicalexamfieldDto.v_DefaultText = "0"; // NO } } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 7) // Sino Combo { _objmedicalexamfieldDto.v_DefaultText = combo.SelectedValue.ToString(); } else if (int.Parse(ddlGroupId.SelectedValue.ToString()) == 9) // Lista { _objmedicalexamfieldDto.v_DefaultText = combo.SelectedValue.ToString(); } //if (ddlGroup.SelectedIndex == 0) //{ // _objmedicalexamfieldsDto.v_Group = null; //} //else //{ _objmedicalexamfieldsDto.v_Group = ddlGroup.Text; //} //Save the data bool Result = _objMedicalExamFieldsBL.UpdateComponentFields(ref objOperationResult, _objmedicalexamfieldsDto, _TextLabelOld, txtLabel.Text, Globals.ClientSession.GetAsList()); if (Result) { _objMedicalExamFieldsBL.UpdateMedicalExamField(ref objOperationResult, _objmedicalexamfieldDto, _MedicalExamId, 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; MessageBox.Show("El registro se guardó correctamente", "CORRECTO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); grdDataMedicalExamFieldValue.Enabled = true; //this.Close(); } else // Operación con error { if (objOperationResult.ErrorMessage != "") { MessageBox.Show(objOperationResult.ErrorMessage, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { 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); } }
public string AddMedicalExamFields(ref OperationResult pobjOperationResult, componentfieldDto pobjDtoEntity, componentfieldsDto pobjDtoEntitys, string pstrComponentId, List <string> ClientSession) { //mon.IsActive = true; string NewId = "(No generado)"; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); var query1 = (from a in dbContext.componentfield join b in dbContext.componentfields on a.v_ComponentFieldId equals b.v_ComponentFieldId where a.v_TextLabel.ToUpper() == pobjDtoEntity.v_TextLabel.ToUpper() && b.v_ComponentId == pobjDtoEntitys.v_ComponentId && b.v_Group == pobjDtoEntitys.v_Group select a).ToList(); if (query1.Count > 0) { pobjOperationResult.ErrorMessage = "Nombre del componente duplicado"; return("0"); } #region ComponentField componentfield objEntity = componentfieldAssembler.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, 18), "MF"); objEntity.v_ComponentFieldId = NewId; dbContext.AddTocomponentfield(objEntity); dbContext.SaveChanges(); #endregion #region ComponentFields componentfields objEntitys = componentfieldsAssembler.ToEntity(pobjDtoEntitys); objEntitys.v_ComponentFieldId = NewId; objEntitys.v_ComponentId = pstrComponentId; objEntitys.d_InsertDate = DateTime.Now; objEntitys.i_InsertUserId = Int32.Parse(ClientSession[2]); objEntitys.i_IsDeleted = 0; dbContext.AddTocomponentfields(objEntitys); dbContext.SaveChanges(); #endregion pobjOperationResult.Success = 1; // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "EXAMEN MÉDICO CAMPO", "v_MedicalExamFieldsId=" + NewId.ToString(), Success.Ok, null); return(NewId); } 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, "EXAMEN MÉDICO CAMPO", "v_MedicalExamFieldsId=" + NewId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage); return("0"); } }
private void btnSave_Click(object sender, EventArgs e) { OperationResult objOperationResult = new OperationResult(); //if (_Mode == "New") //{ //} //else if (_Mode == "Edit") //{ _componentfieldsListDto = new List <componentfieldsDto>(); _componentfieldsListUpdate = new List <componentfieldsDto>(); _componentfieldsDtoDelete = new List <componentfieldsDto>(); //Temporal ComponentFields foreach (var item in _TempComponentFieldsList) { //Add if (item.i_RecordType == (int)RecordType.Temporal && item.i_RecordStatus == (int)RecordStatus.Agregado) { componentfieldsDto componentfieldsDto = new componentfieldsDto(); componentfieldsDto.v_ComponentId = item.v_ComponentId; componentfieldsDto.v_ComponentFieldId = item.v_ComponentFieldId; componentfieldsDto.v_Group = item.v_Group; _componentfieldsListDto.Add(componentfieldsDto); } // Update if (item.i_RecordType == (int)RecordType.NoTemporal && (item.i_RecordStatus == (int)RecordStatus.Modificado || item.i_RecordStatus == (int)RecordStatus.Grabado)) { componentfieldsDto componentfieldsDto = new componentfieldsDto(); componentfieldsDto.v_ComponentId = item.v_ComponentId; componentfieldsDto.v_ComponentFieldId = item.v_ComponentFieldId; componentfieldsDto.v_Group = item.v_Group; _componentfieldsListUpdate.Add(componentfieldsDto); } //Delete if (item.i_RecordType == (int)RecordType.NoTemporal && item.i_RecordStatus == (int)RecordStatus.EliminadoLogico) { componentfieldsDto componentfieldsDto = new componentfieldsDto(); componentfieldsDto.v_ComponentId = item.v_ComponentId; componentfieldsDto.v_ComponentFieldId = item.v_ComponentFieldId; _componentfieldsDtoDelete.Add(componentfieldsDto); } //} } _objMedicalExamFieldsBL.AddComponentFields(ref objOperationResult, _componentfieldsListDto, _componentfieldsListUpdate, _componentfieldsDtoDelete, 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. } }