首页  软件  游戏  图书  电影  电视剧

请输入您要查询的软件:

 

软件 C#抽签小程序源码 
内容

C#抽签小程序源码,浏览excel  (带模版)  之后输入要抽签的人数,点击抽签即可。

核心代码如下所示:

private void button1_Click(object sender, EventArgs e)
        {
            int cqnum=-1;
            int rynum=-1;
            try
         {        
             cqnum=Convert.ToInt32(textBox3.Text);
                   rynum = set.Tables[0].Rows.Count;
         }
         catch (Exception)
         {
          MessageBox.Show("输入的内容有误,请填写数字类型的抽签人数");
          return ;
         }
            if (cqnum >= rynum)
            {
                MessageBox.Show("抽取的人数必须小于总人数");
                return;
            }
                 
            if(cqnum>0)
            {
             int[] a = GetRandomSequence0(cqnum, rynum);
             sjs(set, a);
            }
        }
        //int i = 1;
        public void sjs(DataSet set,int [] a)
        {
            textBox1.Text = "";
            if (s == null)
            {
                s = new DataTable();
                s.TableName = "姓名";
                s.Columns.Add("姓名");
            }
            else
            {

                s.Rows.Clear();
            }
            for (int i = 0; i < a.Length;i )
            {
                textBox1.Text = (i 1) "  " set.Tables[0].Rows[a[i]]["姓名"].ToString() "\r\n";

            }
        
           // s.Rows.Add();
          
        }

        public static int[] GetRandomSequence0(int total,int fw)
        {
            int[] hashtable = new int[fw];
            int[] output = new int[total];
            Random random = new Random();
            for (int i = 0; i < total; i )
            {
                int num = random.Next(1, fw);
                while (hashtable[num] > 0)
                {
                    num = random.Next(1, fw);
                }
             output[i] = num;
             hashtable[num] = 1;
            }
            return output; }


        private void button2_Click(object sender, EventArgs e)
        {

            if (s != null&&s.Rows.Count>0)
            {
                bl.To_Excel(s);
            }
        }
标签 小程序,抽签,c#
缩略图
软件名称 C#抽签小程序源码
软件图标
软件大小 346KB
发布时间
软件平台
软件语言 简体中文
软件授权 免费软件
操作系统 c#
系统类型
用户评分 4
软件版本
官方网站
官方网址
软件截图
软件总类 源码系统
软件大类 源码下载-软件开发-C#源码-c#抽签小程序
软件小类 C#源码
开发者
主办单位名称
ICP备案名
备案号
使用年龄
下载链接
攻略教程
详细介绍
操控设备
隐私政策
查看权限
敏感权限获取说明
软件类型 国产软件
安全警示 适度休息有益身心健康,请勿长期沉迷于使用电脑或刷手机。
随便看

 

传承兰台文化,共同保存历史记忆!兰台网收藏软件、游戏、图片、图书、电影、电视剧等互联网档案,是免费和可借阅文本、电影、音乐等档案的数字图书馆。

 

Copyright © 2004-2025 xlantai.com All Rights Reserved
更新时间:2025/5/20 12:05:44