public static bool 更新站内消息(站内消息 message)
 {
     return Mongo.更新(message);
 }
        private void btn_commit_Click(object sender, EventArgs e)
        {
            #region 验证填写信息是否完善
            if (string.IsNullOrWhiteSpace(text_project_name.Text))
            {
                MessageBox.Show("请填写项目名称!");
                text_project_name.Focus();
                return;
            }
            if (string.IsNullOrWhiteSpace(text_project_number.Text))
            {
                MessageBox.Show("请填写项目编号!");
                text_project_number.Focus();
                return;
            }
            if (string.IsNullOrWhiteSpace(date_bid_time.Text))
            {
                MessageBox.Show("请填写评标时间!");
                date_bid_time.Focus();
                return;
            }

            Regex reg = new Regex(@"^[0-9]\d*$");
            if (string.IsNullOrWhiteSpace(text_totalnum_extract.Text))
            {
                MessageBox.Show("预定抽选个数必须填写!");
                text_totalnum_extract.Focus();
                return;
            }
            else if (!reg.IsMatch(text_totalnum_extract.Text))
            {
                MessageBox.Show("请输入正确的抽选个数!");
                text_totalnum_extract.Focus();
                return;
            }
            else if (text_totalnum_extract.Text == "0")
            {
                MessageBox.Show("预定抽选个数必须大于0!");
                text_totalnum_extract.Focus();
                return;
            }
            if (string.IsNullOrWhiteSpace(text_operator_name.Text))
            {
                MessageBox.Show("请填写操作人姓名!");
                text_operator_name.Focus();
                return;
            }
            if (string.IsNullOrWhiteSpace(text_operator_tel.Text))
            {
                MessageBox.Show("请填写操作人电话!");
                text_operator_tel.Focus();
                return;
            }
            if (dtg_condition_confirm.RowCount <= 0)
            {
                MessageBox.Show("请至少选择一个条件后再提交!");
                return;
            }

            var row_count = dtg_condition_confirm.RowCount;
            var temp_count = 0;
            for (int i = 0; i < row_count; i++)
            {
                var d = int.Parse(dtg_condition_confirm.Rows[i].Cells[2].Value.ToString());
                temp_count += d;
            }
            if (int.Parse(text_totalnum_extract.Text) != temp_count)
            {
                MessageBox.Show("各条件抽取个数总和与预定抽选总数不一致,请检查后再提交数据!");
                return;
            }
            #endregion

            DialogResult dr = MessageBox.Show("确定提交本次抽选申请?", "提示", MessageBoxButtons.YesNo);
            if (dr == DialogResult.Yes)
            {
                #region 添加抽选申请
                专家抽选记录 model = new 专家抽选记录
                {
                    申请时间 = DateTime.Now,
                    项目编号 = text_project_name.Text,
                    项目名称 = text_project_number.Text,
                    评标时间 = Convert.ToDateTime(date_bid_time.Text),
                    总计预定抽选专家数 = int.Parse(text_totalnum_extract.Text),
                    操作人姓名 = text_operator_name.Text,
                    操作人电话 = text_operator_tel.Text
                };
                model.经办人.用户ID = CommonHelper.currentUser.Id;
                model.申请抽选状态 = 申请抽选状态.已提交待批准;

                //屏蔽列表
                var outlist = dtg_avoid_expert.Tag;
                var l = new List<用户链接<专家>>();
                if (outlist!=null)
                {
                    var pk = outlist.ToString();
                    foreach (var item in pk.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        var z = new 用户链接<专家>
                        {
                            用户ID = long.Parse(item)
                        };
                        l.Add(z);
                    }
                }
                model.回避专家列表 = l;

                int count = dtg_condition_confirm.RowCount;
                var condition = new List<专家抽选记录._专家抽选条件>();
                for (int i = 0; i < count; i++)
                {
                    var t_condition = new 专家抽选记录._专家抽选条件();
                    t_condition.需要专家数量 = int.Parse(dtg_condition_confirm.Rows[i].Cells[2].Value.ToString());

                    //专家类别
                    var tempparmlist = dtg_condition_confirm.Rows[i].Cells[9].Value.ToString();
                    if (!string.IsNullOrWhiteSpace(tempparmlist))
                    {
                        foreach (var temp in tempparmlist.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            t_condition.专家类别.Add((专家类别)(int.Parse(temp)));
                        }
                    }

                    //专家级别
                    tempparmlist = dtg_condition_confirm.Rows[i].Cells[10].Value.ToString();
                    if (!string.IsNullOrWhiteSpace(tempparmlist))
                    {
                        foreach (var temp in tempparmlist.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            t_condition.专家级别.Add((专家级别)(int.Parse(temp)));
                        }
                    }

                    //专家类型
                    tempparmlist = dtg_condition_confirm.Rows[i].Cells[11].Value.ToString();
                    if (!string.IsNullOrWhiteSpace(tempparmlist))
                    {
                        foreach (var temp in tempparmlist.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            t_condition.专家类型.Add((专家类型)(int.Parse(temp)));
                        }
                    }
                    //最高学历
                    tempparmlist = dtg_condition_confirm.Rows[i].Cells[12].Value.ToString();
                    if (!string.IsNullOrWhiteSpace(tempparmlist))
                    {
                        foreach (var temp in tempparmlist.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            t_condition.学历要求.Add((学历)(int.Parse(temp)));
                        }
                    }
                    //最高学位
                    tempparmlist = dtg_condition_confirm.Rows[i].Cells[13].Value.ToString();
                    if (!string.IsNullOrWhiteSpace(tempparmlist))
                    {
                        foreach (var temp in tempparmlist.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            t_condition.学位要求.Add((学位)(int.Parse(temp)));
                        }
                    }
                    //专业技术职称
                    tempparmlist = dtg_condition_confirm.Rows[i].Cells[8].Value.ToString();
                    if (!string.IsNullOrWhiteSpace(tempparmlist))
                    {
                        if (tempparmlist != "不限")
                        {
                            foreach (var temp in tempparmlist.Split(new[] { "*" }, StringSplitOptions.RemoveEmptyEntries))
                            {
                                t_condition.专业技术职称.Add((专业技术职称)(int.Parse(temp)));
                            }
                        }
                    }

                    //可评标物质类别匹配模式
                    tempparmlist = dtg_condition_confirm.Rows[i].Cells[4].Value.ToString();
                    if (!string.IsNullOrWhiteSpace(tempparmlist) && tempparmlist == "1")
                    {
                        t_condition.模糊查询 = dtg_condition_confirm.Rows[i].Cells[0].Value.ToString(); ;
                    }
                    else
                    {
                        //可评标物质类别
                        tempparmlist = dtg_condition_confirm.Rows[i].Cells[0].Tag.ToString();
                        if (!string.IsNullOrWhiteSpace(tempparmlist))
                        {
                            var t = new 专家抽选记录._专家抽选条件._评标产品类别();
                            var 可评标物质类别 = tempparmlist.Split(new[] { "#" }, StringSplitOptions.RemoveEmptyEntries);
                            if (可评标物质类别[1] == "1")
                            {
                                t.二级分类可用专家不足返回一级分类 = true;
                            }
                            else
                            {
                                t.二级分类可用专家不足返回一级分类 = false;
                            }

                            var p = 可评标物质类别[0].Split(new[] { "*" }, StringSplitOptions.RemoveEmptyEntries);
                            t.一级分类 = p[0];
                            t.二级分类 = new List<string>();
                            for (var j = 1; j < p.Length; j++)
                            {
                                t.二级分类.Add(p[j]);
                            }

                            t_condition.可评标产品类别.Add(t);
                        }
                    }

                    //抽选描述
                    t_condition.描述 = dtg_condition_confirm.Rows[i].Cells[14].Value.ToString();
                    //所在地域
                    t_condition.所在地区.省份 = dtg_condition_confirm.Rows[i].Cells[5].Value.ToString();
                    t_condition.所在地区.城市 = dtg_condition_confirm.Rows[i].Cells[6].Value.ToString();
                    t_condition.所在地区.区县 = dtg_condition_confirm.Rows[i].Cells[7].Value.ToString();

                    condition.Add(t_condition);
                }
                model.专家抽选条件 = condition;
                专家抽选管理.添加专家抽选历史(model);

                //站内消息
                站内消息 Msg = new 站内消息();
                对话消息 Talk = new 对话消息();

                Msg.重要程度 = 重要程度.特别重要;
                Msg.消息类型 = 消息类型.普通;
                var u_id = CommonHelper.currentUser.Id;

                Msg.发起者.用户ID = u_id;
                Talk.发言人.用户ID = u_id;
                站内消息管理.添加站内消息(Msg, u_id, 10002);
                Talk.消息主体.标题 = "待审核抽取评审专家";
                Talk.消息主体.内容 = "有一条待审核的申请抽取评审专家未处理,<a style='color:red;text-decoration:underline;' href='/专家抽选/Expert_ApplayAuditList'>点击这里进行审核</a>";
                对话消息管理.添加对话消息(Talk, Msg);
                MessageBox.Show("提交成功!");
                #endregion

                Program.PendApprovalform = new PendApproval();
                FormHelper.changeFormToIndex(this, Program.PendApprovalform);
            }
        }
 public static bool 添加站内消息(站内消息 message, long 发起者ID, long 收信人ID)
 {
     message.发起者.用户ID = 发起者ID;
     message.收信人.用户ID = 收信人ID;
     return Mongo.添加(message);
 }