Exemple #1
0
        //新增
        private void btn_Save_Click(object sender, EventArgs e)
        {
            db_examName manage = new db_examName();

            if (string.IsNullOrEmpty(txtName.Text.Trim()))
            {
                MessageBox.Show("请输入考试名称!", "系统提示!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                if (!manage.Exists(txtName.Text.Trim()))
                {
                    try
                    {
                        manage.examName = txtName.Text.ToString().Trim();
                        manage.Add();

                        DialogResult dialogres = MessageBox.Show("添加考试名称成功!", "系统提示!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        if (dialogres == DialogResult.OK)
                        {
                            showAll();
                            txtName.Text = String.Empty;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    MessageBox.Show("此考试名称已存在,请换个名称!", "系统提示!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
Exemple #2
0
        //删除
        private void btn_Del_Click(object sender, EventArgs e)
        {
            db_examName manage   = new db_examName();
            string      idString = "";

            for (int i = 0; i < ckListBoxName.CheckedItems.Count; i++)
            {
                string name = ckListBoxName.GetItemText(ckListBoxName.CheckedItems[i]);
                string id   = new db_examName(name).ID.ToString();
                idString += id + ",";
            }
            if (!string.IsNullOrEmpty(idString))
            {
                if (MessageBox.Show("确定删除?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    if (manage.DeleteList(idString.Remove(idString.Length - 1)))
                    {
                        showAll();
                        MessageBox.Show("成功删除" + idString.Remove(idString.Length - 1).Split(',').Length + "个考试名称!", "系统提示!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        txtName.Text = String.Empty;
                    }
                }
            }
            else
            {
                MessageBox.Show("请选择考试名称再点删除", "系统提示!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
 //单击checkListBox的项
 private void ckListBoxCydw_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (ckListBoxName.SelectedItem != null)
     {
         string      name   = ckListBoxName.SelectedItem.ToString();
         db_examName manage = new db_examName(name);
         varID        = manage.ID;
         txtName.Text = name;
     }
 }
Exemple #4
0
 /// <summary>
 /// 在CheckListBox中显示所有考场
 /// </summary>
 private void showAll()
 {
     #region 先清空CheckListBox列表
     for (int i = 0; i < ckListBoxName.Items.Count; i++)
     {
         ckListBoxName.Items.Clear();
     }
     #endregion
     db_examName manage = new db_examName();
     DataTable   dtList = manage.GetList("").Tables[0];
     for (int i = 0; i < dtList.Rows.Count; i++)
     {
         ckListBoxName.Items.Insert(i, dtList.Rows[i]["examName"].ToString());
     }
 }
Exemple #5
0
        /// <summary>
        /// 绑定考试名称
        /// </summary>
        private void BindCmbKSMC()
        {
            DataTable dtDicCydw = new db_examName().GetList("").Tables[0];
            DataRow   dr        = dtDicCydw.NewRow();

            dr["ID"]       = "0";
            dr["examname"] = "--请选择--";
            dtDicCydw.Rows.InsertAt(dr, 0);
            cmbKaoshiName.DisplayMember = "examname";
            cmbKaoshiName.ValueMember   = "ID";
            cmbKaoshiName.DataSource    = dtDicCydw.DefaultView;


            cmbStatus.Items.Insert(0, "--状态--");
            cmbStatus.Items.Insert(1, "已签到");
            cmbStatus.Items.Insert(2, "未签到");
            cmbStatus.SelectedIndex = 0;
        }
Exemple #6
0
        //修改
        private void btn_Modify_Click(object sender, EventArgs e)
        {
            db_examName manage = new db_examName();
            string      name   = txtName.Text.Trim();

            manage.ID       = varID;
            manage.examName = name;
            if (manage.Update())
            {
                MessageBox.Show("修改考试名称成功!", "系统提示!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                showAll();
                txtName.Text = String.Empty;
            }
            else
            {
                MessageBox.Show("操作失败!", "系统提示!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void get_kcList()
        {
            db_examName examNameModel = new db_examName();
            DataTable   dtExamName    = examNameModel.GetList("").Tables[0];
            int         allCount      = dtExamName.Rows.Count; //一共有多少条数据
            int         rowsCount     = 0;                     //循环行数
            int         colsCount     = 5;                     //循环列数

            if (allCount % colsCount > 0)                      //余数>0
            {
                rowsCount = (allCount / colsCount) + 1;
            }
            else
            {
                rowsCount = allCount / colsCount;
            }

            int count = -1;//记数用

            Button[,] btnSlot = new Button[rowsCount, colsCount];
            for (int i = 0; i < rowsCount; i++)
            {
                for (int j = 0; j < colsCount; j++)
                {
                    if (j + i * 5 < allCount)
                    {
                        btnSlot[i, j] = new Button();
                        //按钮大小初始化
                        btnSlot[i, j].Size = new Size(185, 35);
                        //位置初始化
                        btnSlot[i, j].Location  = new Point(j * 205 + 43, i * 41 + 41); //一行一行显示出来
                        btnSlot[i, j].FlatStyle = FlatStyle.Flat;
                        count++;
                        btnSlot[i, j].Name   = "btn" + count;                                     //为btn设置name属性
                        btnSlot[i, j].Text   = dtExamName.Rows[j + i * 5]["examName"].ToString(); //"btn" + count;  //BTN显示的内容
                        btnSlot[i, j].Click += new EventHandler(button1_Click);
                        this.Controls.Add(btnSlot[i, j]);                                         //在哪里创建,btnContainer为一个大的button,所有的<strong>button都嵌套在里面</strong>
                    }
                }
            }
        }