Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            String filepath = MyTools.GetOpenExcelFilePath();

            if (filepath == null)
            {
                return;
            }

            try
            {
                //读取表格并导入到数组中
                MyTools.ReadExcel(filepath);
            }
            catch (Exception exception)
            {
                textBox1.Text += "\r\n读取出错:" + exception.Message;
                // textBox1.Text +=
            }



            if (Form1.PersonList != null)
            {
                //清空人员数据库
                MySqlitePersons.DeletePersonsTable();
                //写入人员到数据库
                MySqlitePersons.WritePersonsToSQL();

                //显示到数据ListView
                AddDataToListView();
            }
            textBox1.Text += "\r\n读取成功";
        }
Пример #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("所有中奖人员和奖项都将重置\n确认清除吗", "清除奖项", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            //取消清除
            if (result == DialogResult.Cancel)
            {
                return;
            }

            //所有奖项重置为未抽取状态
            for (int i = 0; i < Form1.LuckCatagroyList.Count; i++)
            {
                List <String> catagroy = Form1.LuckCatagroyList[i];
                catagroy[2] = "未抽取";     //奖项状态
            }


            //已中奖人员名单添加到抽奖人员数据库
            for (int i = 0; i < Form1.LuckedPerson.Count; i++)
            {
                List <String> person = Form1.LuckedPerson[i];
                MySqlitePersons.AddOnePersonFormTable(person[3], person[4], person[5]);
                MySqlitePersons.ReadPersonsFormSQL();
            }

            //清除所有中奖人员名单,清空人员数据
            listView1.Items.Clear();
            Form1.LuckedPerson = new List <List <String> >();

            //删除数据库表
            MySqliteLuckedPerson.DeleteLuckedTable();
        }
Пример #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            //清除选中功能

            foreach (ListViewItem item in listView1.SelectedItems)  //选中项遍历
            {
                String indexString = item.Text.ToString();
                int    index       = Convert.ToInt32(indexString);
                Form1.PersonList.RemoveAt(index - 1);

                //获取工号
                String id = listView1.SelectedItems[0].SubItems[1].Text.ToString();
                //获取名字
                String name = listView1.SelectedItems[0].SubItems[3].Text.ToString();

                //从数据库表删除该id人员
                MySqlitePersons.DeleteOnePersonFormTable(id, name);


                listView1.Items.Remove(item);   //按项移除


                break;
            }


            //刷新列表,不然出BUG
            AddDataToListView();
        }
Пример #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            //清除所有人员功能,清空人员数据
            listView1.Items.Clear();
            Form1.PersonList = new List <List <String> >();

            //删除数据库表
            MySqlitePersons.DeletePersonsTable();
        }
Пример #5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            panel3.Visible = false;
            panel4.Visible = false;

            MySqlitePersons.ReadPersonsFormSQL();
            MySqliteConfig.ReadConfigsFormSQL();
            MySqliteCategory.ReadCategoryFormSQL();
            MySqliteLuckedPerson.ReadLuckedFormSQL();

            SetCompanyNameAndLogo();

            ShowNextLuck(GetNextLuckIndex());
        }
Пример #6
0
        private void RemoveLuckPerson()
        {
            //允许多次抽奖
            if (MultipleLuck)
            {
                return;
            }

            //获取中奖人工号和名字
            String id   = label7.Text;
            String name = label9.Text;

            //从数据库中删除
            MySqlitePersons.DeleteOnePersonFormTable(id, name);

            //从数据库重新获取人员名单
            MySqlitePersons.ReadPersonsFormSQL();
        }
Пример #7
0
        //放弃奖励,人员退回抽奖列表,奖项设为未抽取
        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("放弃奖项", "确认放弃吗", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            //取消弃奖
            if (result == DialogResult.Cancel)
            {
                return;
            }

            int index = GetFocusedItemIndex();

            if (index == -1)
            {
                //没有选中任何项
                return;
            }

            List <String> luck = new List <String>();

            String state = listView1.FocusedItem.SubItems[3].Text;  //奖项状态

            if (state == "已弃奖")
            {
                MessageBox.Show("懒得理你");
                return;
            }
            String level = listView1.FocusedItem.SubItems[1].Text;      //奖项名
            String goods = listView1.FocusedItem.SubItems[2].Text;      //奖品名称

            String id         = listView1.FocusedItem.SubItems[4].Text; //中奖人工号
            String department = listView1.FocusedItem.SubItems[5].Text; //中奖人部门
            String name       = listView1.FocusedItem.SubItems[6].Text; //中奖人名字

            //添加到抽奖人员数据库
            MySqlitePersons.AddOnePersonFormTable(id, department, name);
            MySqlitePersons.ReadPersonsFormSQL();


            //已弃奖的奖项重置为未抽取状态
            for (int i = 0; i < Form1.LuckCatagroyList.Count; i++)
            {
                List <String> catagroy    = Form1.LuckCatagroyList[i];
                String        luckedLevel = catagroy[0]; //奖项名
                String        luckedGoods = catagroy[1]; //奖品名称
                String        luckedState = catagroy[2]; //奖项状态

                if (luckedState != "已抽取")
                {
                    continue;
                }
                if (level == luckedLevel && goods == luckedGoods)
                {
                    catagroy[2] = "未抽取";
                    break;
                }
            }
            //保存新的奖项列表
            MySqliteCategory.WriteCategoryToSQL();



            //已弃奖的中奖结果重置为已弃奖状态
            for (int i = 0; i < Form1.LuckedPerson.Count; i++)
            {
                List <String> lucked           = Form1.LuckedPerson[i];
                String        luckedLevel      = lucked[0];
                String        luckedGoods      = lucked[1];
                String        luckedState      = lucked[2];
                String        luckedId         = lucked[3];
                String        luckedDepartment = lucked[4];
                String        luckedName       = lucked[5];

                if (luckedState != "已抽取") //|| luckedState != "已弃奖")
                {
                    continue;
                }

                if (level == luckedLevel && goods == luckedGoods && id == luckedId && department == luckedDepartment && name == luckedName)
                {
                    lucked[2] = "已弃奖";
                    break;
                }
            }
            MySqliteLuckedPerson.WriteLuckedToSQL();

            //刷新列表,不然出BUG
            AddDataToListView();
        }