首页 > 其他 > 详细

键盘回车(可以衍生用户操作任意键盘)

时间:2020-05-09 15:33:13      阅读:49      评论:0      收藏:0      [点我收藏+]
 /// <summary>
        /// 列表的回车事件,实现光标跳转
        /// </summary> 
        /// <param name="e"></param>
        private void DgvKeyPress(KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                //避免乱按回车键 造成报错
                if (dgvRecordList.Grid.ActiveCell == null)
                {
                    return;
                }
                if (StatCode == InvenMgrClassify.YP.GetHashCode().ToString())
                {
                    DrugInout drug = dgvRecordList.Grid.ActiveRow.ListObject as DrugInout;
                    List<DrugInout> drugs = dgvRecordList.DataSource as List<DrugInout>;
                    if (drug == null || drugs == null)
                    {
                        return;
                    }
                    //药品信息
                    if (dgvRecordList.Grid.ActiveCell.Column.Key == nameof(DrugInout.DgInfo))
                    {
                        DemPublic.NextFocusNew(dgvRecordList, dgvRecordList.Grid.ActiveRow.Index, nameof(DrugInout.DioActualAmt), true, false);
                    }
                    //盘点数
                    else if (dgvRecordList.Grid.ActiveCell.Column.Key == nameof(DrugInout.DioActualAmt))
                    {
                        if (drug.DgId == null)
                        {
                            return;
                        }
                        //如果是最后一行
                        if (dgvRecordList.Grid.ActiveRow.Index == drugs.Count - 1)
                        {
                            DemPublic.NextFocusNew(dgvRecordList, dgvRecordList.Grid.ActiveRow.Index, nameof(DrugOrdDtl.DgInfo), false, false);
                            AddGridRow();
                            dgvRecordList.Grid.PerformAction(UltraGridAction.EnterEditModeAndDropdown, false, false);
                            dgvRecordList.GridRefresh();
                        }
                        //如果不是最后一行,跳转到下一行
                        else
                        {
                            DemPublic.NextFocusNew(dgvRecordList, dgvRecordList.Grid.ActiveRow.Index + 1, nameof(DrugOrdDtl.DgInfo), true, false);
                        }
                    }
                }
                else if (StatCode == InvenMgrClassify.WC.GetHashCode().ToString())
                {
                    EisaiInout drug = dgvRecordList.Grid.ActiveRow.ListObject as EisaiInout;
                    List<EisaiInout> drugs = dgvRecordList.DataSource as List<EisaiInout>;
                    if (drug == null || drugs == null)
                    {
                        return;
                    }
                    //药品信息
                    if (dgvRecordList.Grid.ActiveCell.Column.Key == nameof(EisaiInout.EgInfo))
                    {
                        DemPublic.NextFocusNew(dgvRecordList, dgvRecordList.Grid.ActiveRow.Index, nameof(EisaiInout.EioActualAmt), true, false);
                    }
                    //实盘数
                    else if (dgvRecordList.Grid.ActiveCell.Column.Key == nameof(EisaiInout.EioActualAmt))
                    {
                        if (drug.EisaiId == null)
                        {
                            return;
                        }
                        //如果是最后一行
                        if (dgvRecordList.Grid.ActiveRow.Index == drugs.Count - 1)
                        {
                            DemPublic.NextFocusNew(dgvRecordList, drugs.Count - 1, nameof(EisaiInout.EgInfo), false, false);
                            AddGridRow();
                            dgvRecordList.Grid.PerformAction(UltraGridAction.EnterEditModeAndDropdown, false, false);
                            dgvRecordList.GridRefresh();
                        }
                        //如果不是最后一行,跳转到下一行
                        else
                        {
                            DemPublic.NextFocusNew(dgvRecordList, dgvRecordList.Grid.ActiveRow.Index + 1, nameof(EisaiInout.EgInfo), false, false);
                        }
                    }
                }
                else if (StatCode == InvenMgrClassify.HC.GetHashCode().ToString())
                {
                    MatInvchkDtl drug = dgvRecordList.Grid.ActiveRow.ListObject as MatInvchkDtl;
                    List<MatInvchkDtl> drugs = dgvRecordList.DataSource as List<MatInvchkDtl>;
                    if (drug == null || drugs == null)
                    {
                        return;
                    }
                    //药品信息
                    if (dgvRecordList.Grid.ActiveCell.Column.Key == nameof(MatInvchkDtl.DmcInfo))
                    {
                        DemPublic.NextFocusNew(dgvRecordList, dgvRecordList.Grid.ActiveRow.Index, nameof(MatInvchkDtl.MicdActAmt), true, false);
                    }
                    //实盘数
                    else if (dgvRecordList.Grid.ActiveCell.Column.Key == nameof(MatInvchkDtl.MicdActAmt))
                    {
                        if (drug.DmcId == null)
                        {
                            return;
                        }
                        //如果是最后一行
                        if (dgvRecordList.Grid.ActiveRow.Index == drugs.Count - 1)
                        {
                            DemPublic.NextFocusNew(dgvRecordList, drugs.Count - 1, nameof(MatInvchkDtl.DmcInfo), false, false);
                            AddGridRow();
                            dgvRecordList.Grid.PerformAction(UltraGridAction.EnterEditModeAndDropdown, false, false);
                            dgvRecordList.GridRefresh();
                        }
                        //如果不是最后一行,跳转到下一行
                        else
                        {
                            DemPublic.NextFocusNew(dgvRecordList, dgvRecordList.Grid.ActiveRow.Index + 1, nameof(MatInvchkDtl.DmcInfo), false, false);
                        }
                    }
                }
                else
                {
                    AppInvchkDtl drug = dgvRecordList.Grid.ActiveRow.ListObject as AppInvchkDtl;
                    List<AppInvchkDtl> drugs = dgvRecordList.DataSource as List<AppInvchkDtl>;
                    if (drug == null || drugs == null)
                    {
                        return;
                    }
                    //药品信息
                    if (dgvRecordList.Grid.ActiveCell.Column.Key == nameof(AppInvchkDtl.DacInfo))
                    {
                        DemPublic.NextFocusNew(dgvRecordList, dgvRecordList.Grid.ActiveRow.Index, nameof(AppInvchkDtl.AicdActAmt), true, false);
                    }
                    //实盘数
                    else if (dgvRecordList.Grid.ActiveCell.Column.Key == nameof(AppInvchkDtl.AicdActAmt))
                    {
                        if (drug.DacId == null)
                        {
                            return;
                        }
                        //如果是最后一行
                        if (dgvRecordList.Grid.ActiveRow.Index == drugs.Count - 1)
                        {
                            DemPublic.NextFocusNew(dgvRecordList, drugs.Count - 1, nameof(AppInvchkDtl.DacInfo), false, false);
                            AddGridRow();
                            dgvRecordList.Grid.PerformAction(UltraGridAction.EnterEditModeAndDropdown, false, false);
                            dgvRecordList.GridRefresh();
                        }
                        //如果不是最后一行,跳转到下一行
                        else
                        {
                            DemPublic.NextFocusNew(dgvRecordList, dgvRecordList.Grid.ActiveRow.Index + 1, nameof(AppInvchkDtl.DacInfo), false, false);
                        }
                    }
                }
            }
        }

 

键盘回车(可以衍生用户操作任意键盘)

原文:https://www.cnblogs.com/yuanshuo/p/12857131.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!