C#之图书管理系统-部分代码

// ------------登录
     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();
        }

    
// ---------生成树形
     树型
        
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)
        
{
            
        }

        
双击事件打开窗口
 
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace 图书管理系统 { public partial class 登录窗口 : Form { //public static string ConnectionString = "Server=(local);database=图库;uid=sa;pwd=1234"; //sql server 混合模式 // public static string ConnectionString = "Server=(local);Integrated Security=SSPI;database=图库"; //windows模式 public string strSQL; public SqlConnection myConnection; public SqlCommandBuilder sqlCmdBld; public DataSet ds = new DataSet(); public SqlDataAdapter da; public int num=0; private DataTable myTable; private DataRow myRow; public static string strUser; public static string strPassword; // public static string strDepartment; public static bool login_flag = false; public 登录窗口() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { Close(); } private void 登录窗口_Load(object sender, EventArgs e) { linkdatabase link = new linkdatabase(); //实例化 myConnection = new SqlConnection(link.connectionstring()); //实例化连接 strSQL = "select * from 用户表 "; da = new SqlDataAdapter(strSQL, myConnection); ds.Clear(); da.Fill(ds, "用户表"); //////动作 myTable = ds.Tables["用户表"]; for (int i = 0; i < myTable.Rows.Count; i++) { comboBox1.Items.Add(myTable.Rows[i]["用户名"].ToString().Trim()); } } private void button1_Click(object sender, EventArgs e) { linkdatabase link = new linkdatabase(); //实例化 myConnection = new SqlConnection(link.connectionstring()); //实例化连接 strSQL = "sele
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值