private void grdDataEPP_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)
                {
                    grdDataEPP.Rows[row.Index].Selected = true;
                    _TypeofEEPId = grdDataEPP.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)
                {
                    grdDataEPP.Rows[row.Index].Selected = true;
                    contextMenuTypeEPP.Items["modificarToolStripMenuItem"].Enabled = true;
                    _TypeofEEPName   = grdDataEPP.Selected.Rows[0].Cells[3].Value.ToString();
                    _Percentage      = double.Parse(grdDataEPP.Selected.Rows[0].Cells[4].Value.ToString());
                    _TypeofEEPId     = grdDataEPP.Selected.Rows[0].Cells[0].Value.ToString();
                    _objTypeOfEEPamc = _TempTypeOfEEPList.FindAll(p => p.v_TypeofEEPId == _TypeofEEPId).FirstOrDefault();
                    _IndexListEPP    = _TempTypeOfEEPList.FindIndex(p => p.v_TypeofEEPId == _TypeofEEPId);
                }
                else
                {
                    contextMenuTypeEPP.Items["modificarToolStripMenuItem"].Enabled = false;
                }
            }
        }
        private void btnMoveEPP_Click(object sender, EventArgs e)
        {
            OperationResult     objOperationResult     = new OperationResult();
            SystemParameterBL   objSystemParameterBL   = new SystemParameterBL();
            SystemParameterList objSystemParameterList = new SystemParameterList();
            TypeOfEEPList       objTypeOfEEP           = new TypeOfEEPList();

            if (treeViewEPP.SelectedNode == null)
            {
                return;
            }

            //Si la lista temporal es null se la setea con una lista vacia
            if (_TempTypeOfEEPList == null)
            {
                _TempTypeOfEEPList = new List <TypeOfEEPList>();
            }

            int ParameterId = int.Parse(treeViewEPP.SelectedNode.Name.ToString());

            History.frmOtroEPP frmOtroEpp = new History.frmOtroEPP();
            string             OtroEpp    = "";

            if (ParameterId == 16)
            {
                frmOtroEpp.ShowDialog();

                OtroEpp = frmOtroEpp.EppName;
                objSystemParameterList = objSystemParameterBL.GetParentNameSystemParameter(ref objOperationResult, frmOtroEpp.ParameterId);
            }
            else
            {
                objSystemParameterList = objSystemParameterBL.GetParentNameSystemParameter(ref objOperationResult, ParameterId);
            }


            History.frmEppPercentage frm = new History.frmEppPercentage(objSystemParameterList.v_Value1, 0);
            frm.ShowDialog();

            if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                if (objSystemParameterList != null)
                {
                    TypeOfEEPList findResult = new TypeOfEEPList();
                    //Busco en la lista temporal si ya se agrego el item seleccionado
                    if (ParameterId == 16)
                    {
                        findResult = _TempTypeOfEEPList.Find(p => p.i_TypeofEEPId == frmOtroEpp.ParameterId);
                    }
                    else
                    {
                        findResult = _TempTypeOfEEPList.Find(p => p.i_TypeofEEPId == ParameterId);
                    }



                    if (findResult == null)
                    {
                        objTypeOfEEP.v_TypeofEEPId = Guid.NewGuid().ToString();

                        if (ParameterId == 16)
                        {
                            objTypeOfEEP.i_TypeofEEPId   = frmOtroEpp.ParameterId;
                            objTypeOfEEP.v_TypeofEEPName = OtroEpp;
                        }
                        else
                        {
                            objTypeOfEEP.i_TypeofEEPId   = ParameterId;
                            objTypeOfEEP.v_TypeofEEPName = objSystemParameterList.v_Value1;
                        }


                        objTypeOfEEP.r_Percentage   = frm._Porcentage;
                        objTypeOfEEP.i_RecordStatus = (int)RecordStatus.Agregado;
                        objTypeOfEEP.i_RecordType   = (int)RecordType.Temporal;
                        _TempTypeOfEEPList.Add(objTypeOfEEP);
                    }
                    else
                    {
                        if (findResult.i_RecordStatus == (int)RecordStatus.EliminadoLogico)
                        {
                            if (findResult.i_RecordType == (int)RecordType.NoTemporal)// El registro Tiene in ID de BD
                            {
                                findResult.i_TypeofEEPId   = ParameterId;
                                findResult.v_TypeofEEPName = objSystemParameterList.v_Value1;
                                findResult.r_Percentage    = frm._Porcentage;
                                findResult.i_RecordStatus  = (int)RecordStatus.Grabado;
                            }
                            else if (findResult.i_RecordType == (int)RecordType.Temporal) // El registro tiene un ID temporal [GUID]
                            {
                                findResult.i_TypeofEEPId   = ParameterId;
                                findResult.v_TypeofEEPName = objSystemParameterList.v_Value1;
                                findResult.r_Percentage    = frm._Porcentage;
                                findResult.i_RecordStatus  = (int)RecordStatus.Agregado;
                            }
                        }
                        else
                        {
                            MessageBox.Show("Por favor seleccione otro item. ya existe", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                    }
                    var dataList = _TempTypeOfEEPList.FindAll(p => p.i_RecordStatus != (int)RecordStatus.EliminadoLogico);

                    // Cargar grilla
                    grdDataEPP.DataSource = new TypeOfEEPList();
                    grdDataEPP.DataSource = dataList;
                    grdDataEPP.Refresh();
                }
            }
        }