timer控件、三级联动、帐号激活权限设置
一、Timer控件
Timer实际就是一个线程控件。
属性:Enabled 是否被启用
Interval 多长时间执行一次控件中的代码
事件: Tick 事件中放要执行的代码。
利用Timer控件可以实现即时聊天功能。动态的从数据库查询别人发的信息展示到聊天框中。
二、三级联动

实体类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace WindowsFormsApplication2
{
public class China
{
private string _AreaCode; public string AreaCode
{
get { return _AreaCode; }
set { _AreaCode = value; }
}
private string _AreaName; public string AreaName
{
get { return _AreaName; }
set { _AreaName = value; }
}
private string _ParentAreaCode; public string ParentAreaCode
{
get { return _ParentAreaCode; }
set { _ParentAreaCode = value; }
} }
}
数据操作类:
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text; namespace WindowsFormsApplication2
{
public class ChinaData
{
SqlConnection conn = null;
SqlCommand cmd = null; public ChinaData()
{
conn = new SqlConnection("server=.;database=Data0216;user=sa;pwd=123");
cmd = conn.CreateCommand();
} //通过一个父级编号,查询该父级编号对应的地区,放到一个集合中去。
public List<China> Select(string pcode)
{
List<China> clist = new List<China>();
cmd.CommandText = "select *from ChinaStates where ParentAreaCode = @a";
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@a", pcode);
conn.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
China c = new China();
c.AreaCode = dr[].ToString();
c.AreaName = dr[].ToString();
c.ParentAreaCode = dr[].ToString(); clist.Add(c);
}
conn.Close();
return clist;
}
}
}
后台代码
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; namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent(); //调用方法绑定所有省
Bind("", comboBox1);
//绑定所有选中省下面的市,selectvalue是绑定数据源给程序看的value中的选中的内容,和数据库有关。
Bind(comboBox1.SelectedValue.ToString(), comboBox2);
//绑定所有选中市下面的区县
Bind(comboBox2.SelectedValue.ToString(), comboBox3); } //数据绑定方法(给我一个地区父级编号,绑定到相应的Combox中去),需要一个地区父级编号和一个Combox对象两个参数
public void Bind(string pcode, ComboBox cb)
{
//给一个父级编号,把该父级编号查到的地区放到集合clist中去
List<China> clist = new ChinaData().Select(pcode); //绑定Combox的数据源
cb.DataSource = clist;
cb.DisplayMember = "AreaName";
cb.ValueMember = "AreaCode";
} //Combox1选中内容改变时,Combox2和Combox3中的数据源相应的改变。
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{ Bind(comboBox1.SelectedValue.ToString(), comboBox2);
if (comboBox2.SelectedValue != null)
{
Bind(comboBox2.SelectedValue.ToString(), comboBox3);
}
} //Combox2中选中内容改变时,Combox3中的数据源响应的改变。
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
Bind(comboBox2.SelectedValue.ToString(), comboBox3);
}
}
}
三、权限设置
所谓权限设置就是根据登录用户帐号的不同,该帐号对应显示的操作功能不同
实现方法:在数据库的用户表中增加字段进行权限的区分,根据从数据库表中查询到的数据进行相应的
timer控件、三级联动、帐号激活权限设置的更多相关文章
- 【2017-05-05】timer控件、三级联动、帐号激活权限设置
一.Timer控件 Timer实际就是一个线程控件. 属性:Enabled 是否被启用 Interval 多长时间执行一次控件中的代码 事件: Tick 事件中放要执行的代码. ...
- 10、面向对象以及winform的简单运用(isMdicontainer的设置、timer控件进行倒计时的制作)
IsMdicontainer的设置 这是对于整个窗体的设置,将一个窗体的IsMdicontainer设置为true之后,再打开新窗体便可以让新窗体被父容器包括在内. 操作方法: 1)先建立一个子窗体C ...
- C# Timer 控件的用法
一.主要的属性 在 Windows 窗体应用程序中,定时器控件(Timer)与其他的控件略有不同,它并不直接显示在窗体上,而是与其他控件连用. Enabled 属性: 用于设置该Timer控件是否可用 ...
- timer控件、三级联动
timer控件: 实现时间日期自增长: using System; using System.Collections.Generic; using System.ComponentModel; usi ...
- winform/timer控件/权限设置/三级联动
一.timer控件 组件--timer timer是一个线程,默认可以跨线程访问对象 属性:Enabled--可用性 Interval--间隔时间 Tick:间隔时间发生事件 二.三级联动 例: pu ...
- winform 用户控件、 动态创建添加控件、timer控件、控件联动
用户控件: 相当于自定义的一个panel 里面可以放各种其他控件,并可以在后台一下调用整个此自定义控件. 使用方法:在项目上右键.添加.用户控件,之后用户控件的编辑与普通容器控件类似.如果要在后台往窗 ...
- winform用户控件、动态创建添加控件、timer控件、控件联动
用户控件: 相当于自定义的一个panel 里面可以放各种其他控件,并可以在后台一下调用整个此自定义控件. 使用方法:在项目上右键.添加.用户控件,之后用户控件的编辑与普通容器控件类似.如果要在后台往窗 ...
- WinForm timer控件
timer 控件:按用户定义的时间间隔引发的事件 属性: Enabled 是否启用: Interval 事件发生的事件间隔,单位是毫秒 事件只有一个:Tick 事件经过指定的时间间隔 ...
- WinForm timer 控件
timer 控件:按用户定义的时间间隔引发的事件 属性: Enabled 是否启用: Interval 事件发生的事件间隔,单位是毫秒 事件只有一个:Tick 事件经过指定的时间间隔发生 打开一个窗口 ...
随机推荐
- [hive] hive 内部表和外部表
1.内部表 hive (test1)> create table com_inner_person(id int,name string,age int,ctime timestamp) row ...
- Visual Studio 2010 VS IDE 编辑界面出现绿色的点 去掉绿色的空格点
Visual Studio 2010 VS IDE 编辑界面出现绿色的点 去掉绿色的空格点 Vs乱按一顿忽然出现一堆绿色的点,我去好难看,还不知道什么鬼,查了查其实就是个 每个点表示一个空格 让他显 ...
- 安装redis时Newer version of jemalloc required错误解决
问题: [root@localhost redis-4.0.0]# make cd src && make allmake[1]: Entering directory `/root/ ...
- maven 私服同步无法获取依赖的pom.xml的依赖
项目中引入了依赖: <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hado ...
- oracle如何通过cmd导出某个用户下的所有表
1:如果要导入的用户下有空表,需要执行下面语句 select 'alter table '||table_name||' allocate extent;' from user_tables wher ...
- ubuntu 14.04升级python2
http://blog.csdn.net/zahuopuboss/article/details/50927432
- python根据字符串导入模块
问题: path = "auth.my_auth.AUTH" # 根据path实例化AUTH类 解决: path = "auth.my_auth.AUTH" i ...
- Java设计模式系列 — 构造器模式
想象下你有一个类,像下图所示有许多属性.假设你想让你的类不可变(顺便说一下,除非有一个好的理由不这样做,否则你应该坚持.但是我们会以另一种方式来达到要求.) public class User { p ...
- CentOS从源码安装Erlang
### 首先下载资源 wget http://erlang.org/download/otp_src_18.3.tar.gz ### 解压 .tar.gz ### 安装依赖包 yum install ...
- juqery 点击分页显示,指定一页显示多少个,首次加载显示多少个
源代码html: //源代码:html <div class="jq22"> <div class="hidden"> <li&g ...