private void grdDataCommponentField_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { Point point = new System.Drawing.Point(e.X, e.Y); Infragistics.Win.UIElement uiElement = ((Infragistics.Win.UltraWinGrid.UltraGridBase)sender).DisplayLayout.UIElement.ElementFromPoint(point); if (uiElement == null || uiElement.Parent == null) { return; } Infragistics.Win.UltraWinGrid.UltraGridRow row = (Infragistics.Win.UltraWinGrid.UltraGridRow)uiElement.GetContext(typeof(Infragistics.Win.UltraWinGrid.UltraGridRow)); if (row != null) { btnDeleteCommponent.Enabled = true; grdDataCommponentField.Rows[row.Index].Selected = true; _ComponentFieldId = grdDataCommponentField.Selected.Rows[0].Cells[0].Value.ToString(); } } if (e.Button == MouseButtons.Right) { Point point = new System.Drawing.Point(e.X, e.Y); Infragistics.Win.UIElement uiElement = ((Infragistics.Win.UltraWinGrid.UltraGridBase)sender).DisplayLayout.UIElement.ElementFromPoint(point); if (uiElement == null || uiElement.Parent == null) { return; } Infragistics.Win.UltraWinGrid.UltraGridRow row = (Infragistics.Win.UltraWinGrid.UltraGridRow)uiElement.GetContext(typeof(Infragistics.Win.UltraWinGrid.UltraGridRow)); if (row != null) { grdDataCommponentField.Rows[row.Index].Selected = true; contextMenuImport.Items["modificarToolStripMenuItem"].Enabled = true; _GroupName = grdDataCommponentField.Rows[0].Cells[2].Value.ToString(); _ComponentFieldId = grdDataCommponentField.Selected.Rows[0].Cells[0].Value.ToString(); _objComponentFieldsamc = _TempComponentFieldsList.FindAll(p => p.v_ComponentId == _ComponentId && p.v_ComponentFieldId == _ComponentFieldId).FirstOrDefault(); _IndexList = _TempComponentFieldsList.FindIndex(p => p.v_ComponentId == _ComponentId && p.v_ComponentFieldId == _ComponentFieldId); } else { contextMenuImport.Items["modificarToolStripMenuItem"].Enabled = false; } } }
private void btnMoveCommponet_Click(object sender, EventArgs e) { OperationResult objOperationResult = new OperationResult(); ComponentFieldsList objComponentFields; if (checkedListBox1.Items.Count == 0) { return; } //Si la lista temporal es null se la setea con una lista vacia if (_TempComponentFieldsList == null) { _TempComponentFieldsList = new List <ComponentFieldsList>(); } frmGroupMedicalExamField frm = new frmGroupMedicalExamField(""); frm.ShowDialog(); if (frm.DialogResult == System.Windows.Forms.DialogResult.OK) { for (int i = 0; i < checkedListBox1.CheckedItems.Count; i++) { objComponentFields = new ComponentFieldsList(); KeyValueDTO obj = (KeyValueDTO)checkedListBox1.CheckedItems[i]; string ComponentFieldId = obj.Id; string ComponentFieldName = obj.Value1; //Busco en la lista temporal si ya se agrego el item seleccionado var findResult = _TempComponentFieldsList.Find(p => p.v_ComponentFieldId == ComponentFieldId); if (findResult == null) { objComponentFields.v_ComponentId = _ComponentId; objComponentFields.v_ComponentFieldId = ComponentFieldId; objComponentFields.v_Group = frm._GroupName; objComponentFields.v_TextLabel = ComponentFieldName; objComponentFields.i_RecordStatus = (int)RecordStatus.Agregado; objComponentFields.i_RecordType = (int)RecordType.Temporal; _TempComponentFieldsList.Add(objComponentFields); } else { if (findResult.i_RecordStatus == (int)RecordStatus.EliminadoLogico) { if (findResult.i_RecordType == (int)RecordType.NoTemporal)// El registro Tiene in ID de BD { findResult.v_ComponentId = _ComponentId; findResult.v_ComponentFieldId = ComponentFieldId; findResult.v_Group = frm._GroupName; objComponentFields.v_TextLabel = ComponentFieldName; findResult.i_RecordStatus = (int)RecordStatus.Grabado; } else if (findResult.i_RecordType == (int)RecordType.Temporal) // El registro tiene un ID temporal [GUID] { findResult.v_ComponentId = _ComponentId; findResult.v_ComponentFieldId = ComponentFieldId; findResult.v_Group = frm._GroupName; objComponentFields.v_TextLabel = ComponentFieldName; findResult.i_RecordStatus = (int)RecordStatus.Agregado; } } else { MessageBox.Show("El campo : " + findResult.v_TextLabel + " ya existe.", "Error de validaciĆ³n", MessageBoxButtons.OK, MessageBoxIcon.Warning); //return; } } } var dataList = _TempComponentFieldsList.FindAll(p => p.i_RecordStatus != (int)RecordStatus.EliminadoLogico); // Cargar grilla grdDataCommponentField.DataSource = new ComponentFieldsList(); grdDataCommponentField.DataSource = dataList; grdDataCommponentField.Refresh(); } }