Exemplo n.º 1
0
        /// <summary>
        /// 获取指定专家组的上级专家组
        /// </summary>
        /// <param name="iGroupID"></param>
        /// <param name="conn"></param>
        /// <param name="tran"></param>
        /// <returns></returns>
        public static List <Dal.Models.ExpertGroup> GetParentList(int iGroupID, OleDbConnection conn, OleDbTransaction tran = null)
        {
            List <Dal.Models.ExpertGroup> lstParent = new List <Dal.Models.ExpertGroup>();

            Dal.Models.ExpertGroup group = GetExpertGroup(iGroupID, conn, tran);
            lstParent.Add(group);
            if (group.ParentID != null)
            {
                lstParent.AddRange(GetParentList(group.ParentID.Value, conn, tran));
            }
            return(lstParent);
        }
Exemplo n.º 2
0
        public void InitPage()
        {
            OleDbConnection conn = new OleDbConnection(Dal.OleDbHlper.ConnectionString);

            conn.Open();

            int id          = Convert.ToInt32(Request["id"]);
            int specialtyId = Convert.ToInt32(Request["SpecialtyID"]);

            Dal.Models.ExpertGroup expertGroup = BLL.ExpertGroup.GetExpertGroup(id, conn);
            labExpertGroupName.Text = expertGroup.GroupName;
            txtExpertGroupID.Text   = Convert.ToString(expertGroup.GroupID);
            hfSpecialtyID.Value     = specialtyId.ToString();
            conn.Close();
        }
Exemplo n.º 3
0
        public static List <Dal.Models.ExpertGroup> GetChildList(int iGroupID, OleDbConnection conn, OleDbTransaction tran = null)
        {
            Dal.Models.ExpertGroup group = GetExpertGroup(iGroupID, conn, tran);

            string strSql = " select * from ExpertGroup where ParentID = ? ";


            List <Dal.Models.ExpertGroup> lstChild = Dal.OleDbHlper.GetList <Dal.Models.ExpertGroup>(strSql, conn, CommandType.Text, tran
                                                                                                     , new OleDbParameter("@ParentID", OleDbType.Integer)
            {
                Value = iGroupID
            });

            lstChild.Insert(0, group);

            return(lstChild.Distinct().ToList());
        }
Exemplo n.º 4
0
        public static Dal.Models.ExpertGroup GetExpertGroupParent(int iGroupID, OleDbConnection conn, OleDbTransaction tran = null)
        {
            Dal.Models.ExpertGroup ExpertGroup = null;

            ExpertGroup = BLL.ExpertGroup.GetExpertGroup(iGroupID, conn, tran);
            if (ExpertGroup.ParentID.HasValue)
            {
                return(GetExpertGroupParent(ExpertGroup.ParentID.Value, conn, tran));
            }
            string      strSql = " SELECT  * FROM ExpertGroup where GroupID = ? ";
            IDataReader reader = Dal.OleDbHlper.ExecuteReader(strSql, conn, CommandType.Text, tran
                                                              , new OleDbParameter("@GroupID", OleDbType.Integer)
            {
                Value = iGroupID
            });

            return(Dal.Models.BaseEntity.GetEntity <Dal.Models.ExpertGroup>(reader));
        }
Exemplo n.º 5
0
        public void ImportExpertGroup(HttpContext context, OleDbConnection conn)
        {
            // 返回数据信息
            List <object> lstResult = new List <object>();

            if (context.Session["UserInfo"] == null)
            {
                lstResult.Add("-1");
                lstResult.Add("当前会话已结束,请重新登录!");
                context.Response.Write(JsonConvert.SerializeObject(lstResult));
                return;
            }

            Dal.Models.UserInfo user = (Dal.Models.UserInfo)context.Session["UserInfo"];
            string strActivityType   = context.Session["ActivityType"].ToString();

            Dal.Models.Activity activity = BLL.Activity.GetActivity(strActivityType, conn);
            if (activity == null)
            {
                lstResult.Add("-1");
                lstResult.Add("当前活动已关闭,请联系活动管理人员!");
                context.Response.Write(JsonConvert.SerializeObject(lstResult));
                return;
            }

            if (context.Request.Files.Count <= 0)
            {
                lstResult.Add("-1");
                lstResult.Add("请选择文件!");
                context.Response.Write(JsonConvert.SerializeObject(lstResult));
                return;
            }

            // 接收上传文件
            string excelFile = UploadFile(context);

            // 读取文件中的数据
            DataTable dtTemp = BLL.Common.ReadExcelByNPOI(excelFile, true, 0);

            if (dtTemp == null)
            {
                lstResult.Add("-1");
                lstResult.Add("读取文件中的数据失败!");
                context.Response.Write(JsonConvert.SerializeObject(lstResult));
                return;
            }

            //判断上传文件内容格式是否完整
            if (dtTemp.Columns[0].ColumnName != "项目信息" || dtTemp.Columns[15].ColumnName != "上级专家组3" ||
                dtTemp.Columns[12].ColumnName != "上级专家组2" || dtTemp.Columns[9].ColumnName != "上级专家组1")
            {
                lstResult.Add("-1");
                lstResult.Add("上传成功!由于上传文件内容与模版内容不符,数据添加失败!");
                context.Response.Write(JsonConvert.SerializeObject(lstResult));
                return;
            }

            Dal.Models.ExpertGroup group          = null;
            Dal.Models.Declaration decl           = null;
            Dal.Models.Expert      expertReviewer = null;

            dtTemp.Columns.Add("Ordinal");
            dtTemp.Columns.Add("ErrorMessage");
            DataTable dtError    = dtTemp.Clone();
            DataTable dtAllocate = dtTemp.Clone();

            OleDbTransaction tran = conn.BeginTransaction();

            for (int i = 1; i < dtTemp.Rows.Count; i++)
            {
                try
                {
                    // 如果没有填写项目评审专家组,略过
                    if (string.IsNullOrEmpty(dtTemp.Rows[i][4].ToString()) && string.IsNullOrEmpty(dtTemp.Rows[i][6].ToString()))
                    {
                        throw new NullReferenceException("项目评审专家组为空!");
                    }

                    decl = BLL.Declaration.GetDeclaration(dtTemp.Rows[i][1].ToString(), conn, tran);

                    //最上级专家组3
                    group = AddGroup(activity.ActivityID.Value, decl.SpecialtyID.Value, decl.SpecialtyName, user, dtTemp.Rows[i], 15, null, false, conn, tran);

                    //上级专家组2
                    group = AddGroup(activity.ActivityID.Value, decl.SpecialtyID.Value, decl.SpecialtyName, user, dtTemp.Rows[i], 12, group == null ? null : group.GroupID, false, conn, tran);

                    //上级专家组1
                    group = AddGroup(activity.ActivityID.Value, decl.SpecialtyID.Value, decl.SpecialtyName, user, dtTemp.Rows[i], 9, group == null ? null : group.GroupID, false, conn, tran);

                    //评审小组
                    group = AddGroup(activity.ActivityID.Value, decl.SpecialtyID.Value, decl.SpecialtyName, user, dtTemp.Rows[i], 4, group == null ? null : group.GroupID, true, conn, tran);

                    if (decl == null)
                    {
                        throw new Exception("项目:" + dtTemp.Rows[i][1].ToString() + "不存在!");
                    }

                    // 设定项目评审专家组
                    BLL.Declaration.AllocateDeclaration(decl.DeclarationID.Value, group.GroupID, conn, tran);

                    // 设定审批意见填写人
                    if (string.IsNullOrEmpty(dtTemp.Rows[i][5].ToString()))
                    {
                        // 审批意见填写人为空,则默认为专家组组长
                        BLL.Declaration.SetExpertReviewer(decl.DeclarationID.Value, group.GroupLeader, conn, tran);
                    }
                    else
                    {
                        expertReviewer = BLL.Expert.GetExpert(dtTemp.Rows[i][5].ToString(), conn, tran);
                        if (expertReviewer == null)
                        {
                            throw new Exception("审批意见填写人:" + dtTemp.Rows[i][5].ToString() + "不存在!");
                        }

                        if (!(expertReviewer.SpecialtyIDs ?? "").Contains(decl.SpecialtyID.ToString()))
                        {
                            throw new Exception("审批意见填写人:" + dtTemp.Rows[i][5].ToString() + "与项目专业不匹配!");
                        }

                        if (!BLL.ExpertGroup.IsExpertInGroup(group.GroupID.Value, expertReviewer.ExpertID.Value, conn, tran))
                        {
                            BLL.ExpertGroup.AddMember(new Dal.Models.GroupMember()
                            {
                                ExpertID = expertReviewer.ExpertID, GroupID = group.GroupID
                            }, conn, tran);
                        }

                        BLL.Declaration.SetExpertReviewer(decl.DeclarationID.Value, expertReviewer.ExpertID, conn, tran);
                    }

                    dtAllocate.ImportRow(dtTemp.Rows[i]);
                }
                catch (Exception ex)
                {
                    dtTemp.Rows[i]["ErrorMessage"] = ex.Message;
                    dtError.ImportRow(dtTemp.Rows[i]);
                }
            }
            tran.Commit();

            lstResult.Add(dtTemp.Rows.Count - 1);
            lstResult.Add(dtAllocate.Rows.Count);
            lstResult.Add(dtAllocate);
            lstResult.Add(dtError);

            context.Response.Write(JsonConvert.SerializeObject(lstResult));
        }
Exemplo n.º 6
0
        public Dal.Models.ExpertGroup AddGroup(
            int iActivityID,
            int iSpecialtyID,
            string strSpecialtyName,
            Dal.Models.UserInfo user,
            DataRow row,
            int iGroupNameIdx,
            int?iParentID,
            bool bHasMember,
            OleDbConnection conn,
            OleDbTransaction tran)
        {
            Dal.Models.ExpertGroup groupNew       = new Dal.Models.ExpertGroup();
            Dal.Models.ExpertGroup groupOrriginal = null;
            Dal.Models.Expert      expertMember   = null;

            groupNew.ActivityID  = iActivityID;
            groupNew.SpecialtyID = iSpecialtyID;
            groupNew.GroupName   = row[iGroupNameIdx].ToString();
            groupNew.CreateTime  = DateTime.Now;
            groupNew.ParentID    = iParentID;

            #region 专家组长、专家组名、上级专家组
            // 判断专家组长是否存在
            if (bHasMember)
            {
                groupNew.LeaderName = row[iGroupNameIdx + 2].ToString();
            }
            else
            {
                groupNew.LeaderName = row[iGroupNameIdx + 1].ToString();
            }

            if (string.IsNullOrEmpty(groupNew.LeaderName) && string.IsNullOrEmpty(groupNew.GroupName))
            {
                return(null);
            }

            if (string.IsNullOrEmpty(groupNew.GroupName))
            {
                throw new Exception("专家组组名不能为空!");
            }

            if (string.IsNullOrEmpty(groupNew.LeaderName))
            {
                throw new NullReferenceException("专家组组长不能为空!");
            }

            // 根据专家名取专家
            expertMember = BLL.Expert.GetExpert(groupNew.LeaderName, conn, tran);

            if (expertMember == null)
            {
                throw new Exception("专家:" + groupNew.LeaderName + "不存在!");
            }

            // 判断专家专业
            if (!expertMember.SpecialtyNames.Contains(strSpecialtyName))
            {
                throw new Exception("专家:" + groupNew.LeaderName + "专业不符!");
            }

            // 根据专家组组名取专家组
            groupOrriginal = BLL.ExpertGroup.GetExpertGroup(groupNew.GroupName, iSpecialtyID, conn, tran);
            if (groupOrriginal == null)
            {
                groupNew.GroupLeader = expertMember.ExpertID;
            }
            else
            {
                if (groupOrriginal.GroupLeader != expertMember.ExpertID)
                {
                    throw new Exception("专家组组长:" + groupNew.LeaderName + "信息不符!");
                }

                if (groupOrriginal.ParentID != iParentID)
                {
                    throw new Exception("同一专家组只能有一个上级专家组!");
                }

                groupNew.GroupID     = groupOrriginal.GroupID;
                groupNew.GroupLeader = expertMember.ExpertID;
            }

            #endregion

            #region 专家组副组长
            // 取副组长名
            if (bHasMember)
            {
                groupNew.DeputyNames = row[iGroupNameIdx + 3].ToString();
            }
            else
            {
                groupNew.DeputyNames = row[iGroupNameIdx + 2].ToString();
            }

            // 如果副组长名不为空,取副组长专家编号,如果副组长编号与现有专家组副组长编号不同,合并副组长
            groupNew.DeputyIDs = GetMemberIDs(iSpecialtyID, groupNew.DeputyNames, groupOrriginal == null ? "" : groupOrriginal.DeputyIDs, conn, tran);
            #endregion

            #region 专家组成员
            // 判断专家组成员是否存在
            if (bHasMember)
            {
                groupNew.MemberNames = row[iGroupNameIdx + 4].ToString();
            }

            // 如果专家组成员不为空,取专家组成员专家编号,如果专家组成员编号与现有专家组成员编号不同,合并专家组成员
            groupNew.MemberIDs = GetMemberIDs(iSpecialtyID, groupNew.MemberNames, groupOrriginal == null ? "" : groupOrriginal.MemberIDs, conn, tran);
            #endregion

            Dal.Models.ExpertGroup group = BLL.ExpertGroup.CreateExpertGroup(groupNew, user, conn, tran);

            return(group);
        }
Exemplo n.º 7
0
        public static Dal.Models.ExpertGroup CreateExpertGroup(Dal.Models.ExpertGroup group, Dal.Models.UserInfo user, OleDbConnection conn, OleDbTransaction tran = null)
        {
            if (group == null || group.ActivityID == null || group.GroupLeader == null || string.IsNullOrEmpty(group.GroupName))
            {
                throw new Exception("参数错误!");
            }

            Dal.Models.ExpertGroup groupOrriginal = GetExpertGroup(group.GroupName, group.SpecialtyID.Value, conn, tran);
            if (groupOrriginal != null && groupOrriginal.GroupID != group.GroupID)
            {
                throw new Exception("同一专业下,专家组名称不能重复!");
            }

            List <Dal.Models.Expert> lstExpert = null;

            lstExpert = Expert.GetExpertList(conn, user, null, "0701", group.GroupLeader.ToString(), tran);
            if (lstExpert == null || lstExpert.Count == 0)
            {
                throw new Exception("专家组组长不在专家库中或者已被禁用!");
            }

            List <string> lstDeputy = null;

            if (!string.IsNullOrEmpty(group.DeputyIDs))
            {
                lstDeputy = group.DeputyIDs.Split(',').ToList();
                lstExpert = Expert.GetExpertList(conn, user, null, "0701", group.DeputyIDs, tran);
                if (lstExpert == null || lstExpert.Count != lstDeputy.Count)
                {
                    throw new Exception("专家组副组长名单中有不在专家库中或者已被禁用的专家!");
                }
            }

            List <string> lstMember = null;

            if (!string.IsNullOrEmpty(group.MemberIDs))
            {
                lstMember = group.MemberIDs.Split(',').ToList();
                lstExpert = Expert.GetExpertList(conn, user, null, "0701", group.MemberIDs, tran);
                if (lstExpert == null || lstExpert.Count != lstMember.Count)
                {
                    throw new Exception("专家组成员名单中有不在专家库中或者已被禁用的专家!");
                }
            }

            StringBuilder sbSql = new StringBuilder();

            if (group.GroupID != null)
            {
                // 更新专家组信息
                sbSql.Append(" UPDATE ExpertGroup");
                sbSql.Append("  SET ActivityID=? ");
                sbSql.Append(" ,GroupName=? ");
                sbSql.Append(" ,GroupLeader=? ");
                sbSql.Append(" ,SpecialtyID=?");
                sbSql.Append(" ,ParentID=?");
                sbSql.Append(" WHERE  GroupID=?;");
                Dal.OleDbHlper.ExecuteNonQuery(sbSql.ToString(), conn, CommandType.Text, tran
                                               , new OleDbParameter("@ActivityID", OleDbType.Integer)
                {
                    Value = group.ActivityID
                }
                                               , new OleDbParameter("@GroupName", OleDbType.VarWChar)
                {
                    Value = group.GroupName
                }
                                               , new OleDbParameter("@GroupLeader", OleDbType.Integer)
                {
                    Value = group.GroupLeader
                }
                                               , new OleDbParameter("@SpecialtyID", OleDbType.Integer)
                {
                    Value = group.SpecialtyID
                }
                                               , new OleDbParameter("@ParentID", OleDbType.Integer)
                {
                    Value = group.ParentID
                }
                                               , new OleDbParameter("@GroupID", OleDbType.Integer)
                {
                    Value = group.GroupID
                });

                // 清空专家组成员 如果参数没有传入专家组成员,则不删除专家组成员
                sbSql.Clear();
                if (string.IsNullOrEmpty(group.MemberIDs))
                {
                    sbSql.Append(" delete from GroupMember where GroupID = ? and Grade <> '1203' ");
                }
                else
                {
                    sbSql.Append(" delete from GroupMember where GroupID = ? ");
                }

                Dal.OleDbHlper.ExecuteNonQuery(sbSql.ToString(), conn, CommandType.Text, tran
                                               , new OleDbParameter("@GroupID", OleDbType.Integer)
                {
                    Value = group.GroupID
                });
            }
            else
            {
                sbSql.Append(" INSERT INTO ExpertGroup ( ");
                sbSql.Append(" ActivityID ");
                sbSql.Append(" ,GroupName ");
                sbSql.Append(" ,GroupLeader ");
                sbSql.Append(" ,ParentID ");
                sbSql.Append(" ,SpecialtyID");
                sbSql.Append(" ) VALUES (?, ?, ?, ?, ? ) ");

                Dal.OleDbHlper.ExecuteNonQuery(sbSql.ToString(), conn, CommandType.Text, tran
                                               , new OleDbParameter("@ActivityID", OleDbType.Integer)
                {
                    Value = group.ActivityID
                }
                                               , new OleDbParameter("@GroupName", OleDbType.VarWChar)
                {
                    Value = group.GroupName
                }
                                               , new OleDbParameter("@GroupLeader", OleDbType.Integer)
                {
                    Value = group.GroupLeader
                }
                                               , new OleDbParameter("@ParentID", OleDbType.Integer)
                {
                    Value = group.ParentID
                }
                                               , new OleDbParameter("@SpecialtyID", OleDbType.Integer)
                {
                    Value = group.SpecialtyID
                });

                group = GetExpertGroup(group.GroupName, group.SpecialtyID.Value, conn, tran);
            }

            // 构建添加专家组成员的Sql文
            sbSql.Clear();
            sbSql.Append(" INSERT INTO GroupMember( ");
            sbSql.Append("   GroupID ");
            sbSql.Append(" , ExpertID ");
            sbSql.Append(" , Grade ");
            sbSql.Append(" , Ordinal ");
            sbSql.Append(" ) VALUES (?, ?, ?, ?) ");

            // 将专家组组长添加到专家组成员表中
            Dal.OleDbHlper.ExecuteNonQuery(sbSql.ToString(), conn, CommandType.Text, tran
                                           , new OleDbParameter("@GroupID", OleDbType.Integer)
            {
                Value = group.GroupID
            }
                                           , new OleDbParameter("@ExpertID", OleDbType.Integer)
            {
                Value = group.GroupLeader
            }
                                           , new OleDbParameter("@Grade", OleDbType.VarWChar)
            {
                Value = "1201"
            }
                                           , new OleDbParameter("@Ordinal", OleDbType.Integer)
            {
                Value = 1
            });

            // 将专家组副组长添加到专家组成员表中
            int i = 0;

            if (lstDeputy != null)
            {
                for (i = 0; i < lstDeputy.Count; i++)
                {
                    Dal.OleDbHlper.ExecuteNonQuery(sbSql.ToString(), conn, CommandType.Text, tran
                                                   , new OleDbParameter("@GroupID", OleDbType.Integer)
                    {
                        Value = group.GroupID
                    }
                                                   , new OleDbParameter("@ExpertID", OleDbType.Integer)
                    {
                        Value = lstDeputy[i]
                    }
                                                   , new OleDbParameter("@Grade", OleDbType.VarWChar)
                    {
                        Value = "1202"
                    }
                                                   , new OleDbParameter("@Ordinal", OleDbType.Integer)
                    {
                        Value = i + 2
                    });
                }
            }

            // 将专家组成员添加到专家组成员表中
            if (lstMember != null)
            {
                for (i = 0; i < lstMember.Count; i++)
                {
                    Dal.OleDbHlper.ExecuteNonQuery(sbSql.ToString(), conn, CommandType.Text, tran
                                                   , new OleDbParameter("@GroupID", OleDbType.Integer)
                    {
                        Value = group.GroupID
                    }
                                                   , new OleDbParameter("@ExpertID", OleDbType.Integer)
                    {
                        Value = lstMember[i]
                    }
                                                   , new OleDbParameter("@Grade", OleDbType.VarWChar)
                    {
                        Value = "1203"
                    }
                                                   , new OleDbParameter("@Ordinal", OleDbType.Integer)
                    {
                        Value = i + (lstDeputy == null ? 0 : lstDeputy.Count) + 2
                    });
                }
            }
            return(group);
        }
Exemplo n.º 8
0
        protected void btnDownload_Click(object sender, EventArgs e)
        {
            OleDbConnection conn = new OleDbConnection(Dal.OleDbHlper.ConnectionString);

            conn.Open();

            string strActivityType = Session["ActivityType"].ToString();

            Dal.Models.Activity activity = BLL.Activity.GetActivity(strActivityType, conn);
            Dal.Models.UserInfo user     = ((Dal.Models.UserInfo)Session["UserInfo"]);
            //int specialty = Convert.ToInt32(ddlSpecialty.SelectedValue);
            //List<Dal.Models.Declaration> lstDeclaration = BLL.Declaration.GetDeclarationList(user, activity.ActivityID.Value, conn)
            //    .Where(d => d.SpecialtyID == specialty).OrderBy(d => d.AssociationOrdinal).ToList();
            Dal.Models.DeclarationSearchCondition condition = new Dal.Models.DeclarationSearchCondition()
            {
                ActivityID        = activity.ActivityID,
                DeclarationStatus = "1803",
                SpecialtyID       = ddlSpecialty.SelectedValue,
                UserID            = user.UserID,
                UserType          = user.UserType
            };
            List <Dal.Models.Declaration> lstDeclaration = BLL.Declaration.GetDeclarationList(condition, conn);
            DataTable dtDeclaration = dtDeclaration = Dal.DataTableExtensions.ToDataTable(lstDeclaration);

            //根据活动和专业导出专家
            List <Dal.Models.Expert> lstExpert = BLL.Expert.GetExpertList(conn, user, null, "0701").Where(a => (a.SpecialtyNames ?? "").Contains(ddlSpecialty.SelectedItem.Text)).ToList();
            DataTable  dtExpert        = Dal.DataTableExtensions.ToDataTable(lstExpert);
            string     TempletFileName = Server.MapPath("~/Content/Template/项目评审专家组及专家信息模版.xls");                  //模板文件
            string     ReportFileName  = Server.MapPath("~/Content/Temp/ExcelTemp/DecGroupListAndExpertTemp.xls"); //导出文件
            FileStream file            = null;

            try
            {
                file = new FileStream(TempletFileName, FileMode.Open, FileAccess.Read);
            }
            catch (Exception)
            {
                hdMsg.Value = "模板文件不存在或正在打开!";
                return;
            }
            HSSFWorkbook hssfworkbook = new HSSFWorkbook(file);
            HSSFSheet    ws1          = (HSSFSheet)hssfworkbook.GetSheet("专家组"); //Sheet1
            HSSFSheet    ws2          = (HSSFSheet)hssfworkbook.GetSheet("专家");  //Sheet2

            if (ws1 == null || ws2 == null)                                      //工作薄中没有工作表
            {
                hdMsg.Value = "文件中缺少<专家组>或<专家>工作表!";
                return;
            }

            Dal.Models.ExpertGroup group = null;
            int count = dtDeclaration.Rows.Count;
            int iID;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    HSSFRow row = (HSSFRow)ws1.CreateRow(i + 2);
                    row.CreateCell(0).SetCellValue(i + 1); // 序号
                    row.CreateCell(1).SetCellValue(dtDeclaration.Rows[i]["DeclarationCode"].ToString().Trim());
                    row.CreateCell(2).SetCellValue(dtDeclaration.Rows[i]["DeclarationName"].ToString().Trim());
                    row.CreateCell(3).SetCellValue(dtDeclaration.Rows[i]["PrizeName"].ToString().Trim());

                    if (int.TryParse(dtDeclaration.Rows[i]["ExpertReviewGroupID"].ToString(), out iID))
                    {
                        // 评审专家组
                        group = BLL.ExpertGroup.GetExpertGroup(iID, conn);
                        row.CreateCell(4).SetCellValue(dtDeclaration.Rows[i]["ExpertReviewGroupName"].ToString());
                        row.CreateCell(5).SetCellValue(dtDeclaration.Rows[i]["ExpertReviewerName"].ToString());
                        row.CreateCell(6).SetCellValue(group.LeaderName);
                        row.CreateCell(7).SetCellValue(group.DeputyNames);
                        row.CreateCell(8).SetCellValue(group.MemberNames);

                        // 上级专家组1
                        if (group.ParentID != null)
                        {
                            group = BLL.ExpertGroup.GetExpertGroup(group.ParentID.Value, conn);
                            row.CreateCell(9).SetCellValue(group.GroupName);
                            row.CreateCell(10).SetCellValue(group.LeaderName);
                            row.CreateCell(11).SetCellValue(group.DeputyNames);

                            // 上级专家组2
                            if (group.ParentID != null)
                            {
                                group = BLL.ExpertGroup.GetExpertGroup(group.ParentID.Value, conn);
                                row.CreateCell(12).SetCellValue(group.GroupName);
                                row.CreateCell(13).SetCellValue(group.LeaderName);
                                row.CreateCell(14).SetCellValue(group.DeputyNames);

                                // 上级专家组3
                                if (group.ParentID != null)
                                {
                                    group = BLL.ExpertGroup.GetExpertGroup(group.ParentID.Value, conn);
                                    row.CreateCell(15).SetCellValue(group.GroupName);
                                    row.CreateCell(16).SetCellValue(group.LeaderName);
                                    row.CreateCell(17).SetCellValue(group.DeputyNames);
                                }
                            }
                        }
                    }
                }
            }
            ws1.ForceFormulaRecalculation = true;

            if (dtExpert.Rows.Count > 0)
            {
                for (int i = 0; i < dtExpert.Rows.Count; i++)
                {
                    HSSFRow row = (HSSFRow)ws2.CreateRow(i + 1);
                    row.CreateCell(0).SetCellValue(i + 1);
                    row.CreateCell(1).SetCellValue(dtExpert.Rows[i]["ExpertName"].ToString().Trim());     //姓名
                    row.CreateCell(2).SetCellValue(dtExpert.Rows[i]["Gender"].ToString().Trim());         //性别
                    row.CreateCell(3).SetCellValue(dtExpert.Rows[i]["IDTypeText"].ToString().Trim());     //证件类别
                    row.CreateCell(4).SetCellValue(dtExpert.Rows[i]["IDNumber"].ToString().Trim());       //证件号码
                    row.CreateCell(5).SetCellValue(dtExpert.Rows[i]["Email"].ToString().Trim());          //电子邮箱
                    row.CreateCell(6).SetCellValue(dtExpert.Rows[i]["AcademicTitle"].ToString().Trim());  //职称
                    row.CreateCell(7).SetCellValue(dtExpert.Rows[i]["Profession"].ToString().Trim());     //研究方向
                    row.CreateCell(8).SetCellValue(dtExpert.Rows[i]["Workplace"].ToString().Trim());      //工作单位
                    row.CreateCell(9).SetCellValue(dtExpert.Rows[i]["SpecialtyNames"].ToString().Trim()); //评优专业
                }
            }

            //先删除上一个临时文件
            if (File.Exists(ReportFileName))
            {
                FileInfo fi = new FileInfo(ReportFileName);
                if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                {
                    fi.Attributes = FileAttributes.Normal;
                }
                File.Delete(ReportFileName);
            }

            try
            {
                //创建临时文件写入数据
                using (FileStream filess = File.OpenWrite(ReportFileName))
                {
                    hssfworkbook.Write(filess);
                }
                System.IO.FileInfo filet          = new System.IO.FileInfo(ReportFileName);
                string             outputFileName = null;
                string             browser        = this.Context.Request.UserAgent.ToUpper();

                if (browser.Contains("MS") == true && browser.Contains("IE") == true)
                {
                    outputFileName = HttpUtility.UrlEncode("项目评审专家组及专家信息模版.xls");
                }
                else if (browser.Contains("FIREFOX") == true)
                {
                    outputFileName = "/项目评审专家组及专家信息模版.xls/";
                }
                else
                {
                    outputFileName = HttpUtility.UrlEncode("项目评审专家组及专家信息模版.xls");
                }
                Response.Clear();
                Response.Charset         = "GB2312";
                Response.ContentEncoding = System.Text.Encoding.UTF8;
                Response.AddHeader("Content-Disposition", "attachment; filename=" + outputFileName);
                Response.AddHeader("Content-Length", filet.Length.ToString());
                Response.ContentType = "application/ms-excel";
                Response.WriteFile(filet.FullName);
                Response.End();
            }
            catch (Exception ex)
            {
                hdMsg.Value = "模板文件不存在或正在打开!";
                return;
            }
        }