// ------------登录 private void Login_Load( object sender, System.EventArgs e) ... { t_user_name.Text = "admin"; t_password.Text = "admin";//clear this Control //t_password.Clear(); this.Focus(); t_user_name.Focus(); t_user_name.SelectionStart = 0; t_user_name.SelectionLength = t_user_name.Text.Length; } private void t_user_name_TextChanged( object sender, System.EventArgs e) ... { } private void button1_Click( object sender, System.EventArgs e) ... { my_class.Public_User Public_User = new LibrarySystem.my_class.Public_User(); my_class.DataControl My_DataControl = new my_class.DataControl( ); string user_name; string password; string msg_title; int flag; msg_title = my_class.Public_User.str_message; //类中static变量不用实例化再调用 user_name = t_user_name.Text.Trim(); password = t_password.Text.Trim(); if(user_name.Length < 1) //if (user_name ==""; ...{ //以下在类定义public static 作为全局变量使用 MessageBox.Show("请输入用户代号!",msg_title,MessageBoxButtons.OK,MessageBoxIcon.Information); t_user_name.Focus(); return; } if(Public_User.CheckString(password) == -1) ...{ MessageBox.Show("请输入用户密码!",msg_title,MessageBoxButtons.OK,MessageBoxIcon.Information); t_password.Focus(); return; } //MessageBox.Show(Curr_Path,msg_title); //MessageBox.Show(my_class.DataControl.ConnString,msg_title); flag = My_DataControl.Check_User(user_name,password); if( flag == -1) ...{ t_user_name.Focus(); t_user_name.SelectionStart = 0; t_user_name.SelectionLength = t_password.Text.Length; return; } if(flag == -2) ...{ t_password.Focus(); t_password.SelectionStart = 0; t_password.SelectionLength = t_password.Text.Length; return; } } private void button2_Click( object sender, System.EventArgs e) ... { Application.Exit(); } private void t_password_TextChanged( object sender, System.EventArgs e) ... { } private void t_password_Enter( object sender, System.EventArgs e) ... { } private void t_password_KeyDown( object sender, System.Windows.Forms.KeyEventArgs e) ... { if(e.KeyValue == 13) button1.Focus(); } private void t_user_name_KeyDown( object sender, System.Windows.Forms.KeyEventArgs e) ... { if(e.KeyValue ==13) t_password.Focus(); } // ---------生成树形 树型 #region 树型 private void create_tree() ...{ my_class.DataControl bind = new LibrarySystem.my_class.DataControl(); //my_class.DataControl bind2 = new LibrarySystem.my_class.DataControl(); string ls_sql = "select module_id,line_no,description,remark,note from Sys_Module where enabled = 'Y' order by line_no"; string ls_sql2 = "select Module_Id,Function_Id,Line_No,Description,Note,Enabled from dbo.Sys_Module_Function where Enabled='Y' order by line_no"; TreeNode tempnode1; TreeNode tempnode2; TreeNode tempnode; tempnode = new TreeNode(); tempnode.Text ="系统向导图"; //tempnode.Index = 0; tempnode.SelectedImageIndex = 1; tempnode.ImageIndex = 2; tempnode.Tag = "parent"; treeView1.Nodes.Add(tempnode); DataTable dt = bind.Get_Table(ls_sql); DataTable dt2 = bind.Get_Table(ls_sql2); DataView dv = new DataView(); DataView dv2 = new DataView(); dv.Table = dt; dv2.Table = dt2; foreach(DataRowView drv in dv) ...{ tempnode1 = new TreeNode(); //ListViewItem listitem = new ListViewItem(); //listitem.SubItems.Clear(); //listView1.Clear(); //listitem.SubItems[0].Text = drv["description"].ToString(); //listitem.ImageIndex = 0; //listitem.Index = 0; //listitem.Tag = 1; //listitem.Text = "test"; //listView1.Items.Add(listitem); tempnode1.Text = drv["description"].ToString(); tempnode1.Tag = drv["module_id"].ToString().Trim(); tempnode1.ImageIndex = 6; //tempnode1.Index = 1; //tempnode1. tempnode1.SelectedImageIndex = 5; tempnode.Nodes.Add(tempnode1); //treeView1.Select(); //treeView1.ExpandAll(); //tempnode.ExpandAll(); tempnode.Expand(); dv2.RowFilter = "Module_Id ='"+drv["module_id"].ToString().Trim()+"'"; if(dv2.Count < 1) continue; foreach(DataRowView drv2 in dv2) ...{ tempnode2 = new TreeNode(); tempnode2.Text = drv2["description"].ToString(); tempnode2.ImageIndex = 3; //tempnode2.Index = 2; tempnode2.Tag = drv2["function_id"].ToString().Trim(); //treeView1.SelectedNode.Nodes.Add(tempnode2); tempnode1.Nodes.Add(tempnode2); } } //my_class.DataControl get_info = new LibrarySystem.my_class.DataControl(); //MessageBox.Show(bind.User_name); statusBar1.Panels[1].Text = "登录名称:"+bind.User_name; } #endregion private void ini_listView() ... { listView1.Columns.Add("功能名称",100,HorizontalAlignment.Left); } private void Main_Fram_Load( object sender, System.EventArgs e) ... { //this.FormBorderStyle = FixedSingle; statusBar1.Panels[2].Text = "登录时间:"+DateTime.Now.ToString();; //treenode1.Tag = "0"; //treeView1.SelectedNode.Nodes.Add(treenode1); this.Left = 0; this.Top = 0; this.Height = this.MdiParent.Height - 30; this.Width = this.MdiParent.Width; treeView1.Left = 5; treeView1.Top = 5; treeView1.Height = this.Height - statusBar1.Height - 45; label_bar.Left = treeView1.Left + treeView1.Width; label_bar.Top = treeView1.Top; label_bar.Height = treeView1.Height; listView1.Left = label_bar.Left + label_bar.Width; listView1.Top = treeView1.Top; listView1.Width = this.Width - treeView1.Width - label_bar.Width - 20; listView1.Height = treeView1.Height; this.create_tree(); this.ini_listView(); } private void treeView1_AfterSelect( object sender, System.Windows.Forms.TreeViewEventArgs e) ... { //TreeNode treenode = (TreeNode)e.Node; string ls_tag; try ...{ if(e.Node.Parent == null) ...{ //MessageBox.Show(e.Node.Tag.ToString(),"0"); //return; string ls_sql = "select module_id,line_no,description,remark,note from Sys_Module where enabled = 'Y'"; my_class.DataControl da = new LibrarySystem.my_class.DataControl(); DataTable dt = da.Get_Table(ls_sql); DataView dv = new DataView(); dv.Table = dt; listView1.Clear(); foreach(DataRowView drv in dv) ...{ ListViewItem listview = new ListViewItem(); listview.SubItems.Clear(); listview.SubItems[0].Text = drv["description"].ToString(); listview.ImageIndex = 1; listview.Tag = "1"; listView1.Items.Add(listview); } return; } } catch(Exception se) ...{ MessageBox.Show(se.ToString(),""); } //if(e.Node.Parent.Parent == null) //{ //MessageBox.Show(e.Node.Tag.ToString(),"2"); // return; //} if(e.Node.Parent.Parent == null) ...{ //MessageBox.Show(e.Node.Tag.ToString(),"1"); //return; ls_tag = e.Node.Tag.ToString().Trim(); string ls_sql = "select Module_Id,Function_Id,Line_No,Description,Note,Enabled from dbo.Sys_Module_Function where Enabled='Y' and module_id='"+ls_tag+"'"; my_class.DataControl da = new LibrarySystem.my_class.DataControl(); DataTable dt = da.Get_Table(ls_sql); DataView dv = new DataView(); dv.Table = dt; listView1.Clear(); foreach(DataRowView drv in dv) ...{ ListViewItem listview = new ListViewItem(); listview.SubItems.Clear(); listview.SubItems[0].Text = drv["description"].ToString(); listview.ImageIndex = 5; listview.Tag = "2"; listView1.Items.Add(listview); } return; } if(e.Node.Parent.Parent.Parent == null) ...{ ls_tag = e.Node.Tag.ToString().Trim(); string ls_sql = "select function_id,win_id,line_no,win_name,description,note,win_type from Sys_Module_Function_line where enabled='Y' and function_id='"+ls_tag+"'"; my_class.DataControl da = new LibrarySystem.my_class.DataControl(); DataTable dt = da.Get_Table(ls_sql); DataView dv = new DataView(); dv.Table = dt; listView1.Clear(); foreach(DataRowView drv in dv) ...{ ListViewItem listview = new ListViewItem(); listview.SubItems.Clear(); listview.SubItems[0].Text = drv["description"].ToString(); listview.ImageIndex = 3; listview.Tag = drv["win_name"].ToString(); listView1.Items.Add(listview); } return; } //ls_tag = e.Node.Tag.ToString().Trim(); } private void statusBar1_PanelClick( object sender, System.Windows.Forms.StatusBarPanelClickEventArgs e) ... { } private void Main_Fram_Resize( object sender, System.EventArgs e) ... { return; //treeView1.Location.Y = 10; } private void Main_Fram_SizeChanged( object sender, System.EventArgs e) ... { return; } private void Main_Fram_StyleChanged( object sender, System.EventArgs e) ... { return; } private void listView1_SelectedIndexChanged( object sender, System.EventArgs e) ... { } private void listView1_ItemCheck( object sender, System.Windows.Forms.ItemCheckEventArgs e) ... { } private void listView1_Click( object sender, System.EventArgs e) ... { } 双击事件打开窗口 #region 双击事件打开窗口 private void listView1_DoubleClick(object sender, System.EventArgs e) ...{ //MessageBox.Show(e.ToString()); string ls_tag; Form my_form =null; if(listView1.SelectedItems.Count > 0) ...{ //listView1.SelectedItems. ls_tag = listView1.SelectedItems[0].Tag.ToString(); if(ls_tag =="1" || ls_tag =="2") ...{ MessageBox.Show("您选择的功能包,不能打开,请在左边树型目录中展开此功能包!",my_class.Public_User.str_message,MessageBoxButtons.OK,MessageBoxIcon.Information); return; } else ...{ //my_form = (Form)ls_tag; //my_form tt = new my_fo //MessageBox.Show(ls_tag,""); ls_tag = ls_tag.Trim(); Type type = Type.GetType("LibrarySystem."+ls_tag); try ...{ my_form = (Form)Activator.CreateInstance(type); } catch(Exception se) ...{ MessageBox.Show("此功能还没做完"+se.ToString(),"系统提示",MessageBoxButtons.OK,MessageBoxIcon.Information); return; } //my_form.MdiParent = this.MdiParent; //my_form.Show(); if(my_form.FormBorderStyle == FormBorderStyle.FixedDialog) ...{ my_form.TopMost = true; my_form.ShowDialog(); } else ...{ my_form.MdiParent = this.MdiParent; my_form.Show(); } /**//* foreach(Form formchild in MdiChildren) { if(formchild.Name == ls_tag) { Main_Fram fm = new Main_Fram(); fm.MdiParent = this.MdiParent; fm.Activate(); MessageBox.Show(ls_tag,""); //formchild.MdiParent = this.MdiParent; fm.Show(); //return; } else { MessageBox.Show("您选择的功能窗口还没做完!",my_class.Public_User.str_message,MessageBoxButtons.OK,MessageBoxIcon.Question); return; } } */ } } } private void label_bar_Click(object sender, System.EventArgs e) ...{ } private void label_bar_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) ...{ //treeView1.Width = e.X; //MessageBox.Show("","test"); } private void label_bar_Move(object sender, System.EventArgs e) ...{ //treeView1.Width = this.Left; } private void label_bar_MouseEnter(object sender, System.EventArgs e) ...{ } private void label_bar_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) ...{ mouse_offset = new Point(-e.X,-e.Y); } private void label_bar_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) ...{ if(e.Button == MouseButtons.Left)//左键按下 ...{ //Point offset = new Point(e.X,e.Y); Point mouse = Control.MousePosition; mouse.Offset(mouse_offset.X,mouse_offset.Y); ((Control)sender).Location = ((Control)sender).Parent.PointToClient(mouse); this.label_bar.Top = treeView1.Top; listView1.Left = this.label_bar.Left; listView1.Width = this.Width - this.label_bar.Width - this.label_bar.Left; treeView1.Width = this.label_bar.Left; } } private void Main_Fram_Closed(object sender, System.EventArgs e) ...{ } } #endregion