Ejemplo n.º 1
0
        /// <summary>
        /// 申请,将数据添加到数据库中
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnEnsure_Click(object sender, EventArgs e)
        {
            DialogResult result;
            result = MessageBox.Show("确定申请?", "系统消息", MessageBoxButtons.OKCancel);
            if (cmbHost.Text != ""  && cmbTopic.Text != "")
            {
                if (result == DialogResult.OK)
                {
                    con.ConHost = cmbHost.Text;
                    con.ConSubMen = emp.EmId;
                    con.ConOthers = rtxRemarks.Text;
                    con.ConPlace = bdrPlace;
                    con.ConStartTime = constart;
                    con.ConEndTime = conend;
                    con.ConStatus = '0';
                    con.ConIsDone = '0';
                    con.ConName = cmbTopic.Text;
                    con.ConRecordMen = Convert.ToInt32(cmbRecMan.SelectedValue);

                    // 随机选择会务执行人

                    List<EmployeeModel> emlist = new List<EmployeeModel>();
                    List<EmployeeModel> onelist = new List<EmployeeModel>();
                    emlist = userbll.GetAllEmployee();
                    foreach (EmployeeModel em2 in emlist)
                    {
                        if (em2.EmPermission == "CE")
                        {
                            onelist.Add(em2);
                        }
                    }

                    Random r = new Random();
                    int ecId = r.Next(0, onelist.Count - 1);

                    con.ConStaffMen = onelist[ecId].EmId;

                    // 会议使用资源表中添加条目
                    List<string> rscList = new List<string>();
                    IEnumerator myEnumerator = cklStaff.CheckedIndices.GetEnumerator();
                    int index;
                    string[] rsc;
                    while (myEnumerator.MoveNext())
                    {
                        index = (int)myEnumerator.Current;
                        cklStaff.SelectedItem = cklStaff.Items[index];
                        rsc = cklStaff.Text.Split(' ');
                        rscList.Add(rsc[0]);
                        //MessageBox.Show(rsc[0]);
                    }
                    int ConId = userbll.ConApply(con, rscList);

                    for (int i = 0; i < addconmem.dataset.Tables["table"].Rows.Count; i++)
                    {
                        InConMemberModel ICMM = new InConMemberModel();
                        ICMM.ConId = ConId;
                        DataRow dr;
                        dr = addconmem.dataset.Tables["table"].Rows[i];
                        ICMM.ConEmId = Convert.ToInt32(dr["员工ID"]);
                        ICMM.ConRegister = '0';
                        userbll.AddConMenRecord(ICMM);
                    }

                    // 申请会议
                    MessageBox.Show("申请成功,请耐心等待管理员审核通知");
                    this.Close();
                }
            } // end if
            else
            {
                MessageBox.Show("请填写完整信息");
            }
        }