zoukankan      html  css  js  c++  java
  • winform --用户控件 登陆,激活,权限

    用户控件:

    用户控件是用户自己创建并设置好的一个控件组,其实就是一个类,实例化之后调用就可以控制里面的控件,但是用户控件里面的控件的事件必须在用户控件中写。

     1 using System;
     2 using System.Collections.Generic;
     3 using System.ComponentModel;
     4 using System.Drawing;
     5 using System.Data;
     6 using System.Linq;
     7 using System.Text;
     8 using System.Windows.Forms;
     9 
    10 namespace 用户控件
    11 {
    12     public partial class First : UserControl
    13     {
    14         public First()
    15         {
    16             InitializeComponent();
    17         }
    18 
    19         private void First_MouseEnter(object sender, EventArgs e)
    20         {
    21             this.BackColor = Color.Red;
    22         }
    23 
    24         private void First_MouseLeave(object sender, EventArgs e)
    25         {
    26             this.BackColor = Color.Transparent;
    27         }
    28 
    29         private void First_DoubleClick(object sender, EventArgs e)
    30         {
    31             Form2 f2 = new Form2(label1.Text, label2.Text);
    32             f2.Show();
    33         }
    34     }
    35 }
    36 
    37 
    38 
    39 using System;
    40 using System.Collections.Generic;
    41 using System.ComponentModel;
    42 using System.Data;
    43 using System.Drawing;
    44 using System.Linq;
    45 using System.Text;
    46 using System.Windows.Forms;
    47 
    48 namespace 用户控件
    49 {
    50     public partial class Form1 : Form
    51     {
    52         public Form1()
    53         {
    54             InitializeComponent();
    55         }
    56 
    57         private void button1_Click(object sender, EventArgs e)
    58         {
    59             for (int i = 1; i <= 15; i++)
    60             {
    61                 First f = new First();
    62                 f.pictureBox1.BackgroundImage = Image.FromFile("G:\0425\6、WinForm\2016-7-4\用户控件\用户控件\images\1.png");
    63                 f.pictureBox1.BackgroundImageLayout = ImageLayout.Stretch;
    64                 f.label1.Text = "用户" + i;
    65                 f.label2.Text = "签名" + i;
    66 
    67                 flowLayoutPanel1.Controls.Add(f);
    68             }
    69 
    70         }
    71     }
    72 }
    用户控件

    登陆,激活,权限:

    登陆验证,账户激活验证,权限验证:
    1、验证用户名密码是否正确
    2、账户是否处于激活状态
    3、验证有哪些权限,可以看到哪些功能

     1 using System;
     2 using System.Collections.Generic;
     3 using System.ComponentModel;
     4 using System.Data;
     5 using System.Drawing;
     6 using System.Linq;
     7 using System.Text;
     8 using System.Windows.Forms;
     9 using 登陆_激活_权限.Model;
    10 
    11 namespace 登陆_激活_权限
    12 {
    13     public partial class Form2 : Form
    14     {
    15         Form1 F1 = null;
    16         public Form2(Form1 f1,Login looo)
    17         {
    18             InitializeComponent();
    19             F1 = f1;
    20             string[] aaa = looo.Permissions.Split(','); //通过","切割一个字符串并且放进一个数组中去。
    21 
    22 ----然后根据用户拥有几段字符串来确定权限,根据每段字符串所代表的按钮,如果字符串在,则按钮显示,否则则依旧隐藏不显示
    23             if (aaa.Contains("101"))
    24             {
    25                 button1.Visible = true;
    26             }
    27             if (aaa.Contains("102"))
    28             {
    29                 button2.Visible = true;
    30             }
    31             if (aaa.Contains("103"))
    32             {
    33                 button3.Visible = true;
    34             }
    35             
    36             
    37 
    38         }
    39     }
    40 }
  • 相关阅读:
    加载web项目时报的错误:Tomcat version 6.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 Web modul
    js修改title
    14.Android UiAutomator 图像处理
    13.UiAutomator 辅助APK的使用
    12.UiAutomator 获取系统信息
    11.UiAutomator 相关JAVA知识
    10.Android UiAutomator Junit 断言函数的使用
    面向对象基本关键词的解释
    Java图形界面——Border
    java文本编辑器v2.0 图形用户界面
  • 原文地址:https://www.cnblogs.com/tonyhere/p/5650608.html
Copyright © 2011-2022 走看看