1
wtt
3 天以前 db658b16ef882ddcd56c4fea35aae42d0473b57d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using BaseSet;
 
namespace LMES
{
    public partial class MDIMain : Form
    {
        //private int childFormNumber = 0;
        public MDIMain()
        {
            InitializeComponent();
        }
 
        Frm_Show frmNav = new Frm_Show(); 
 
        private void MDIMain_Load(object sender, EventArgs e)
        {
            tabControl1.TabPages.Clear();
            tabControl1.Visible = false;
            //
            frmNav.MdiParent = this;
            frmNav.Text = "导航图";
            frmNav.Show();
            AddTabPage(frmNav);
            frmNav.Visible = false;
            frmNav.WindowState = FormWindowState.Maximized;
            frmNav.Visible = true;
            // 
            //
            tsDate.Text ="当前日期:"+ DateTime.Today.ToShortDateString();
            tsUser.Text = "当前操作员:" + DBUtility.ClsPub.CurUserName;
            tsAccNo.Text = "当前帐套:" + DBUtility.ClsPub.AccName;
            this.Text = DBUtility.ClsPub.HOrgName;
        }
 
 
        /// <summary>
        /// 添加一个标签
        /// </summary>
        /// <param name="frm"></param>
        public void AddTabPage(Form frm)
        {
            TabPage tp = new TabPage();
            tp.Tag = frm;
            tp.Text = frm.Text;
            tabControl1.TabPages.Add(tp);
            tabControl1.SelectedIndex = tabControl1.TabCount - 1;
            if (!tabControl1.Visible) tabControl1.Visible = true;
        }
 
 
        /// <summary>
        /// 删除一个标签
        /// </summary>
        /// <param name="selectedIndex"></param>
        private void CloseTabPage(int selectedIndex)
        {
            if ((tabControl1.TabPages[selectedIndex].Tag as Form).Text == "导航图")
            {
                return;
            }
            (tabControl1.TabPages[selectedIndex].Tag as Form).Close();
            tabControl1.TabPages.RemoveAt(selectedIndex);
            if (tabControl1.TabPages.Count == 0) tabControl1.Visible = false;
        }
 
        private void buttonItem1_Click(object sender, EventArgs e)
        {
            //Rtp_GridViewReportDlg frm_Test = new Rtp_GridViewReportDlg();
            //frm_Test.MdiParent = this;
            //frm_Test.Show();
        }
 
        private void sideBar1_Click(object sender, EventArgs e)
        {
 
        }
 
        private void 系统功能ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
        }
 
        private void 重新注册ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
            System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location);
        }
 
        private void 退出系统ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
             
        }
 
        private void 计算器ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Process p = new Process();
            p.StartInfo.FileName = System.Environment.CurrentDirectory + @"\CALC.EXE";
            p.Start();
        }
 
        private void 拷贝表格ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DBUtility.ClsPub.ForEachControl(ActiveMdiChild, true);
        }
 
        private void 数据导出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DBUtility.ClsPub.ForEachControl(ActiveMdiChild, false);
        }
 
        private void toolStripMenuItem4_Click(object sender, EventArgs e)
        {
 
        }
 
        private void 用户模块设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Xt_UserFunc oFrm = new Xt_UserFunc();
            //oFrm.ShowDialog();
        }
 
        private void 切换主界面ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //if (frmNav.Visible == true)
            //{
            //    frmNav.Visible = false;
            //    frmNavOld.WindowState = FormWindowState.Maximized;
            //    frmNavOld.Visible = true;
            //}
            //else
            //{
            //    frmNavOld.Visible = false;
            //    frmNav.WindowState = FormWindowState.Maximized;
            //    frmNav.Visible = true;
            //}
        }
 
        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            BLL.AboutBox1 oFrm = new BLL.AboutBox1();
            oFrm.ShowDialog();
        }
 
        private void 主菜单设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Xt_MainMenuSet oXt_MainMenuSet = new Xt_MainMenuSet(); 
            oXt_MainMenuSet.ShowDialog();
        }
 
        private void 错误信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BLL.Frm_SQLInfo oSQLInfo = new BLL.Frm_SQLInfo();
            oSQLInfo.ShowDialog();
        }
 
        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabControl1.SelectedIndex > -1)
                (tabControl1.TabPages[tabControl1.SelectedIndex].Tag as Form).Focus();
 
            for (int i = 0; i < tabControl1.TabCount; i++)
            {
                if ((tabControl1.TabPages[i].Tag as Form).Visible == false)
                {
                    CloseTabPage(i);
                }
            }
        }
 
        private void tabControl1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left) // 只有左键双击才响应关闭
                CloseTabPage(tabControl1.SelectedIndex);
        }
 
        
    }
}