功能性界面选择按钮函数的编写

来源:互联网 发布:韩国服装批发软件 编辑:程序博客网 时间:2024/06/06 00:42

这个是多个功能性界面选择按钮函数的编写。

   private void Btn_FunForm_Click(object sender, EventArgs e)        {            //********************************************************************            //对于并列功能选择按钮的函数的书写            //分为9个步骤            //利用switch进行判断            //Button的tabindex进行按顺序赋值            //*******************************************************************            //1.先判断动作主体是否是Button类型            if (!(sender is Button))            {                return;            }            //2.强制赋值            Button  Btntest=(Button)(sender);            //3.获取序号            int BtnIndex = Btntest.TabIndex;            //4.是否是退出按钮            if (BtnIndex == 20)            {                if (MessageBox.Show("确定要关闭吗?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)                {                    return;                }                this.Cursor = Cursors.WaitCursor;                Application.DoEvents();                this.Close();                return;            }            //5.是否到期            if (GlobleData.Setting.SetUpCheck && File.Exists(Application.StartupPath + "\\TxtFile\\cfg.txt") && (System.DateTime.Now - File.GetCreationTime(Application.StartupPath + "\\TxtFile\\cfg.txt")).TotalDays > 31)            {                MessageBox.Show("软件使用期限超过一个月,请联系集成商!");                return;            }            //6.和中间量进行比较            if (BtnTemp == Btntest)            {                return;            }            if (BtnTemp != null)            {                BtnTemp.BackColor = Color.White;            }            BtnTemp = Btntest;            BtnTemp.BackColor = Color.Yellow;            //7.是否还在初始化            if (GlobleData.Operator.Screenapp == true)            {                return;            }            GlobleData.Operator.Screenapp = true;            //8.初始化过程            GlobleData.SetScrFlag();            GlobelFunc.Frm_Hide(frm_Temp);            switch (BtnIndex)            {                            case 1:                    {                        GlobelFunc.Frm_Show(F1);                        frm_Temp = F1;                        break;                    }                case 2:                    {                        GlobelFunc.Frm_Show(F2);                        frm_Temp = F2;                        break;                    }                case 3:                    {                        GlobelFunc.Frm_Show(F3);                        frm_Temp = F3;                        break;                    }                case 4:                    {                        GlobelFunc.Frm_Show(F4);                        frm_Temp = F4;                        break;                    }                case 5:                    {                        GlobelFunc.Frm_Show(F5);                        frm_Temp = F5;                        break;                    }                case 6:                    {                        GlobelFunc.Frm_Show(F6);                        frm_Temp = F6;                        break;                    }                case 7:                    {                        GlobelFunc.Frm_Show(F7);                        frm_Temp = F7;                        break;                    }                case 8:                    {                        GlobelFunc.Frm_Show(F8);                        frm_Temp = F8;                        break;                    }                case 9:                    {                        GlobelFunc.Frm_Show(F9);                        frm_Temp = F9;                        break;                    }                case 10:                    {                        GlobelFunc.Frm_Show(F10);                        frm_Temp = F10;                        break;                    }                default:                    {                        break;                    }            }            //9.变量进行清理                       GlobleData.Screen.CurrentScreen = GlobleData.Screen.FormInfor[BtnIndex];;            GlobleData.Operator.Screenapp = false;                }