private void btnSave_Click(object sender, EventArgs e)
        {
            Participant    participantinfo = new Participant();
            ParticipantBLL pbll            = new ParticipantBLL();
            string         Name            = txtName.Text.Trim();
            string         RolePlay        = cbRolePlay.Text;

            if (!string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(RolePlay))
            {
                participantinfo.Name       = Name;
                participantinfo.Majary     = txtMajary.Text.Trim();
                participantinfo.Postion    = txtPostion.Text.Trim();
                participantinfo.Company    = txtCompany.Text.Trim();
                participantinfo.Department = txtDepartment.Text.Trim();
                participantinfo.RolePlay   = RolePlay;
                participantinfo.ProName    = HAZOP分析系统.ProName;
                if (pbll.Add_Participant(participantinfo))
                {
                    MessageBox.Show("添加成功!");
                    MyParticipantInfoDataBindEvents();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("失败成功!");
                }
            }
            else
            {
                MessageBox.Show("人员名和项目角色不能为空!");
            }
        }
Exemplo n.º 2
0
        private void tspDeleteProNameList_Click(object sender, EventArgs e)
        {
            if (this.lvProNameList.SelectedItems.Count > 0)
            {
                string ProName = this.lvProNameList.SelectedItems[0].Text;

                ProjectBLL bll = new ProjectBLL();
                bll.Delete_ProNameList(ProName);

                AnalyResultBLL analyResultBLL = new AnalyResultBLL();
                analyResultBLL.Delete_Result(ProName);

                NodeBLL nodeBLL = new NodeBLL();
                nodeBLL.Delete_ProName(ProName);

                ParticipantBLL participantBLL = new ParticipantBLL();
                participantBLL.Delete_ProName(ProName);

                SelectedPramasBLL selectedPramasBLL = new SelectedPramasBLL();
                selectedPramasBLL.Delete_ProName(ProName);

                ProNameDataBind();
            }
            else
            {
                this.Close();
            }
        }
Exemplo n.º 3
0
        private void recupererListeParticipants(Evenement evt)
        {
            ParticipantBLL ptcpBLL = new ParticipantBLL();

            List <Participant> listeParticipants = ptcpBLL.getAllParticipantByEvenement(evt);

            gridViewParticipants.DataSource = listeParticipants;

            gridViewParticipants.DataBind();
        }
        /// <summary>
        /// Action effectuée lorsque l'on clique sur le bouton ajout des participants
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAjouterParticipant_Click(object sender, EventArgs e)
        {
            //L'utilisateur a confirmé l'ajout des participants sélectionnés
            if ("Y".Equals(hiddenFieldAjouterParticipant.Value))
            {
                List <Participant> listeParticipantsAAjouter = new List <Participant>();
                ProjetCadeaux_Entites.Evenement evt          = new ProjetCadeaux_Entites.Evenement();
                evt.id_evenement = int.Parse(ViewState["evenementId"].ToString());


                foreach (GridViewRow row in gridViewPersonnesRecherche.Rows)
                {
                    CheckBox cbChoixPersonne = ((CheckBox)row.FindControl("cbChoixPersonne"));

                    if (cbChoixPersonne.Checked)
                    {
                        CheckBox cbHasListe = ((CheckBox)row.FindControl("cbChoixListe"));

                        String id           = gridViewPersonnesRecherche.DataKeys[row.RowIndex]["id_personne"].ToString();
                        String nomSelect    = row.Cells[3].Text;
                        String prenomSelect = row.Cells[4].Text;

                        Participant part = new Participant();
                        part.hasListe        = cbHasListe.Checked;
                        part.nom_participant = nomSelect + " " + prenomSelect;
                        part.id_personne     = int.Parse(id);
                        part.id_evenement    = int.Parse(ViewState["evenementId"].ToString());

                        listeParticipantsAAjouter.Add(part);
                    }
                }

                gridViewPersonnesRecherche.DataSource = null;
                gridViewPersonnesRecherche.DataBind();

                ParticipantBLL       partBLL      = new ParticipantBLL();
                ListeIdeesCadeauxBLL listeService = new ListeIdeesCadeauxBLL();

                Boolean retour = partBLL.ajouterListeParticipant(listeParticipantsAAjouter) && listeService.creerListeIdeesCadeaux(listeParticipantsAAjouter, evt);

                if (!retour)
                {
                    FailureText.Text = "Tous les participants n'ont pas pû être ajoutés";
                }
                else
                {
                    SuccessText.Text = "Les participants ont été ajoutés";
                }

                btnAjouterParticipant.Visible = false;

                RechargerGridViewParticipants();
            }
        }
        /// <summary>
        /// Action effectuée au moment du clic sur la recherche des personnes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnRecherchePersonne_Click(object sender, EventArgs e)
        {
            string nom    = rechercheNomParticipantTb.Text;
            string prenom = recherchePrenomParticipantTb.Text;

            int            cle = int.Parse(Request.Params["evenementId"].ToString());
            PersonnesBLL   personnesService = new PersonnesBLL();
            EvenementBLL   evtBLL           = new EvenementBLL();
            ParticipantBLL ptcpBLL          = new ParticipantBLL();

            //Récupération des personnes que l'on a recherché
            List <Personne> listePersonnesRecherches = personnesService.recherchePersonne(nom, prenom);

            //Recherche des personnes qui font déjà partie de l'évènement
            Evenement evt = evtBLL.getEvenementById(cle);

            List <Participant> listeParticipants = ptcpBLL.getAllParticipantByEvenement(evt);

            //On retire les personnes participant déjà
            if (listeParticipants.Count > 0)
            {
                for (int i = 0; i < listePersonnesRecherches.Count; i++)
                {
                    Personne pers = listePersonnesRecherches[i];

                    for (int j = 0; j < listeParticipants.Count; j++)
                    {
                        Participant part = listeParticipants[j];

                        if (part.id_personne == pers.id_personne)
                        {
                            listePersonnesRecherches.Remove(pers);
                            i--;
                        }
                    }
                }
            }

            if (listePersonnesRecherches.Count > 0)
            {
                btnAjouterParticipant.Visible = true;

                gridViewPersonnesRecherche.DataSource = listePersonnesRecherches;

                gridViewPersonnesRecherche.DataBind();
            }
            else
            {
                FailureText.Text = "Aucune personne ne correspond aux critères.";
            }
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["connecte"] != null && Request.Params["evenementId"] != null)
            {
                if (!IsPostBack)
                {
                    ViewState["evenementId"] = Request.Params["evenementId"].ToString();

                    RechargerGridViewParticipants();
                }

                if (ViewState["listePersonnesChargee"] == null || ViewState["listePersonnesChargee"].ToString() != "true")
                {
                    ParticipantBLL participantBLL = new ParticipantBLL();

                    List <Participant> listeParticipantAyantListeCadeau = new List <Participant>();
                    ProjetCadeaux_Entites.Evenement evt = new ProjetCadeaux_Entites.Evenement();
                    Participant connecte     = new Participant();
                    Personne    persConnecte = new Personne();

                    evt.id_evenement         = int.Parse(ViewState["evenementId"].ToString());
                    connecte.id_personne     = int.Parse(Session["personneID"].ToString());
                    persConnecte.id_personne = connecte.id_personne;

                    //Afficher le lien administration si admin
                    EvenementBLL evtService = new EvenementBLL();
                    evt = evtService.getEvenementById(evt.id_evenement);

                    if (estAdmin(persConnecte, evt))
                    {
                        linkAdministrerEvenement.Visible      = true;
                        linkAdministrerEvenement.NavigateUrl += evt.id_evenement;
                    }
                    else
                    {
                        linkAdministrerEvenement.Visible = false;
                    }

                    listeParticipantAyantListeCadeau = participantBLL.getAllParticipantSaufConnecteAyantListeByEvenement(evt, connecte);

                    DataTable retour = new DataTable();

                    retour.Columns.Add("ID");
                    retour.Columns.Add("nom");

                    DataRow dr2 = retour.NewRow();
                    dr2["ID"]  = "";
                    dr2["nom"] = "--";
                    retour.Rows.Add(dr2);

                    foreach (Participant part in listeParticipantAyantListeCadeau)
                    {
                        String id  = part.id_personne.ToString();
                        String nom = part.nom_participant;

                        DataRow dr = retour.NewRow();
                        dr["ID"]  = id;
                        dr["nom"] = nom;

                        retour.Rows.Add(dr);
                    }

                    listeParticipantAyantListe.DataValueField = "ID";
                    listeParticipantAyantListe.DataTextField  = "nom";

                    listeParticipantAyantListe.DataSource = retour;
                    listeParticipantAyantListe.DataBind();
                    ViewState["listePersonnesChargee"] = "true";
                }
            }
            else
            {
                Response.Redirect("~/");
            }
        }
Exemplo n.º 7
0
        /// <summary>
        ///导出DataGridView中的数据到Excel文件
        /// </summary>
        /// <remarks>
        /// add com "Microsoft Excel 14.0 Object Library"
        /// using Excel=Microsoft.Office.Interop.Excel;
        /// using System.Reflection;
        /// </remarks>
        /// <param name= "dgv"> DataGridView </param>
        public static void DataGridViewToExcel(DataGridView dgv)
        {
            //申明保存对话框
            SaveFileDialog dlg = new SaveFileDialog();

            //默然文件后缀
            dlg.DefaultExt = "xls";
            //文件后缀列表
            dlg.Filter = "Excel文件(*.xls)|*.xls";
            //默然路径是系统当前路径
            dlg.InitialDirectory = Directory.GetCurrentDirectory();
            //打开保存对话框
            if (dlg.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            //返回文件路径
            string fileNameString = dlg.FileName;

            //验证strFileName是否为空或值无效
            if (fileNameString.Trim() == " ")
            {
                return;
            }
            //定义表格内数据的行数和列数
            int rowscount = dgv.Rows.Count;
            int colscount = dgv.Columns.Count;

            //行数必须大于0
            if (rowscount <= 0)
            {
                MessageBox.Show("没有数据可供保存 ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //列数必须大于0
            if (colscount <= 0)
            {
                MessageBox.Show("没有数据可供保存 ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //行数不可以大于65536
            if (rowscount > 65536)
            {
                MessageBox.Show("数据记录数太多(最多不能超过65536条),不能保存 ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //列数不可以大于255
            if (colscount > 255)
            {
                MessageBox.Show("数据记录行数太多,不能保存 ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //验证以fileNameString命名的文件是否存在,如果存在删除它
            FileInfo file = new FileInfo(fileNameString);

            if (file.Exists)
            {
                try
                {
                    file.Delete();
                }
                catch (Exception error)
                {
                    MessageBox.Show(error.Message, "删除失败 ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            ExcelApp.Application objExcel    = null;
            ExcelApp.Workbook    objWorkbook = null;
            ExcelApp.Worksheet   objsheet    = null;
            try
            {
                //申明对象
                objExcel    = new Microsoft.Office.Interop.Excel.Application();
                objWorkbook = objExcel.Workbooks.Add(true);
                objsheet    = (Worksheet)objWorkbook.Worksheets.Add(Type.Missing, Type.Missing, 1, Type.Missing);

                //设置EXCEL可见
                objExcel.Visible = true;

                //向Excel中写入表格的表头
                CombineTransverse(1, 1, 12, "分析项目:", objExcel, objsheet);
                CombineTransverse(1, 13, 16, "表页:", objExcel, objsheet);
                CombineTransverse(2, 1, 3, "图纸编号:", objExcel, objsheet);
                CombineTransverse(2, 4, 12, "版本号:", objExcel, objsheet);
                CombineTransverse(2, 13, 16, "日期:", objExcel, objsheet);

                ParticipantBLL     participantBLL  = new ParticipantBLL();
                List <Participant> list            = participantBLL.Get_ParticipantInfoList(InitialInterface.ProName);
                string             participantList = String.Empty;
                foreach (Participant p in list)
                {
                    participantList = participantList + p.Name + " ";
                }

                CombineTransverse(3, 1, 3, "小组成员:" + participantList, objExcel, objsheet);
                CombineTransverse(3, 4, 12, "", objExcel, objsheet);
                CombineTransverse(3, 13, 16, "会议时间:", objExcel, objsheet);
                CombineTransverse(4, 1, 12, "节点:", objExcel, objsheet);
                CombineTransverse(4, 13, 16, "", objExcel, objsheet);
                CombineTransverse(5, 1, 3, "设计意图:", objExcel, objsheet);
                CombineTransverse(5, 4, 16, "", objExcel, objsheet);

                Range range = objsheet.Range[objsheet.Cells[1, 1], objsheet.Cells[5, 16]];
                //range.WrapText = true;
                range.Font.Color = Color.Black; //字体颜色
                range.Font.Name  = "宋体";        //字体
                //range.Font.Bold = true; //设置为粗体
                range.Font.Size           = 14; //字体大小
                range.HorizontalAlignment = XlHAlign.xlHAlignLeft;
                range.ColumnWidth         = 12; //列宽
                range.RowHeight           = 22; //行高
                //range.EntireRow.AutoFit();//添加到行高设置之后才有效
                //range.Borders.ColorIndex = 2;//边框颜色
                range.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;//边框线类型

                Range TitleRange = objsheet.Range[objsheet.Cells[6, 1], objsheet.Cells[6, 16]];
                TitleRange.Font.Color          = Color.Black; //字体颜色
                TitleRange.Font.Name           = "宋体";        //字体
                TitleRange.Font.Size           = 12;          //字体大小
                TitleRange.HorizontalAlignment = XlHAlign.xlHAlignCenter;
                TitleRange.RowHeight           = 20;          //行高

                int displayColumnsCount = 1;
                for (int i = 0; i <= dgv.ColumnCount - 1; i++)
                {
                    if (dgv.Columns[i].Visible == true)
                    {
                        objExcel.Cells[6, displayColumnsCount] = dgv.Columns[i].HeaderText.Trim();
                        displayColumnsCount++;
                    }
                    else
                    {
                    }
                }
                //向Excel中逐行逐列写入表格中的数据
                for (int row = 0; row <= dgv.RowCount - 1; row++)
                {
                    displayColumnsCount = 1;
                    for (int col = 0; col < colscount; col++)
                    {
                        if (dgv.Columns[col].Visible == true)
                        {
                            try
                            {
                                objExcel.Cells[row + 7, displayColumnsCount] = "'" + dgv.Rows[row].Cells[col].Value.ToString().Trim();
                                displayColumnsCount++;
                            }
                            catch (Exception)
                            {
                            }
                        }
                        else
                        {
                        }
                    }
                }
                //设置自适应行高
                Range endrange = objsheet.Range[objsheet.Cells[1, 1], objsheet.Cells[rowscount + 6, colscount - 3]];
                endrange.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
                endrange.WrapText          = true;
                endrange.EntireRow.AutoFit();
                //保存文件
                objWorkbook.SaveAs(fileNameString, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message, "警告 ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            MessageBox.Show("导出完毕! ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemplo n.º 8
0
        public static void DataBaseToExcel()
        {
            AnalyResultBLL analyResultBLL = new AnalyResultBLL();

            System.Data.DataTable dt = analyResultBLL.OutAllToExcel(HAZOP分析系统.ProName);

            //申明保存对话框
            SaveFileDialog dlg = new SaveFileDialog();

            //默然文件后缀
            dlg.DefaultExt = "xls";
            //文件后缀列表
            dlg.Filter = "Excel文件(*.xls)|*.xls";
            //默然路径是系统当前路径
            dlg.InitialDirectory = Directory.GetCurrentDirectory();
            //打开保存对话框
            if (dlg.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            //返回文件路径
            string fileNameString = dlg.FileName;

            //验证strFileName是否为空或值无效
            if (fileNameString.Trim() == " ")
            {
                return;
            }

            //定义表格内数据的行数和列数
            int rowscount = dt.Rows.Count;
            int colscount = dt.Columns.Count;

            //行数必须大于0
            if (rowscount <= 0)
            {
                MessageBox.Show("没有数据可供保存 ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //列数必须大于0
            if (colscount <= 0)
            {
                MessageBox.Show("没有数据可供保存 ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //行数不可以大于65536
            if (rowscount > 65536)
            {
                MessageBox.Show("数据记录数太多(最多不能超过65536条),不能保存 ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //列数不可以大于255
            if (colscount > 255)
            {
                MessageBox.Show("数据记录行数太多,不能保存 ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //验证以fileNameString命名的文件是否存在,如果存在删除它
            FileInfo file = new FileInfo(fileNameString);

            if (file.Exists)
            {
                try
                {
                    file.Delete();
                }
                catch (Exception error)
                {
                    MessageBox.Show(error.Message, "删除失败 ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            ExcelApp.Application objExcel    = null;
            ExcelApp.Workbook    objWorkbook = null;
            ExcelApp.Worksheet   objsheet    = null;
            try
            {
                //申明对象
                objExcel    = new Microsoft.Office.Interop.Excel.Application();
                objWorkbook = objExcel.Workbooks.Add(true);
                objsheet    = (Worksheet)objWorkbook.Worksheets.Add(Type.Missing, Type.Missing, 1, Type.Missing);

                //设置EXCEL可见
                objExcel.Visible = true;

                //向Excel中写入表格的表头
                CombineTransverse(1, 1, 12, "分析项目:", objExcel, objsheet);
                CombineTransverse(1, 13, 16, "表页:", objExcel, objsheet);
                CombineTransverse(2, 1, 3, "图纸编号:", objExcel, objsheet);
                CombineTransverse(2, 4, 12, "版本号:", objExcel, objsheet);
                CombineTransverse(2, 13, 16, "日期:", objExcel, objsheet);

                ParticipantBLL     participantBLL  = new ParticipantBLL();
                List <Participant> list            = participantBLL.Get_ParticipantInfoList(HAZOP分析系统.ProName);
                string             participantList = String.Empty;
                if (list != null)
                {
                    foreach (Participant p in list)
                    {
                        participantList = participantList + p.Name + " ";
                    }
                }


                CombineTransverse(3, 1, 3, "小组成员:" + participantList, objExcel, objsheet);
                CombineTransverse(3, 4, 12, "", objExcel, objsheet);
                CombineTransverse(3, 13, 16, "会议时间:", objExcel, objsheet);
                CombineTransverse(4, 1, 12, "节点:", objExcel, objsheet);
                CombineTransverse(4, 13, 16, "", objExcel, objsheet);
                CombineTransverse(5, 1, 3, "设计意图:", objExcel, objsheet);
                CombineTransverse(5, 4, 16, "", objExcel, objsheet);

                Range range = objsheet.Range[objsheet.Cells[1, 1], objsheet.Cells[5, 16]];
                //range.WrapText = true;
                range.Font.Color = Color.Black; //字体颜色
                range.Font.Name  = "宋体";        //字体
                //range.Font.Bold = true; //设置为粗体
                range.Font.Size           = 14; //字体大小
                range.HorizontalAlignment = XlHAlign.xlHAlignLeft;
                range.ColumnWidth         = 12; //列宽
                range.RowHeight           = 22; //行高
                //range.EntireRow.AutoFit();//添加到行高设置之后才有效
                //range.Borders.ColorIndex = 2;//边框颜色
                range.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;//边框线类型

                Range TitleRange = objsheet.Range[objsheet.Cells[6, 1], objsheet.Cells[6, 16]];
                TitleRange.Font.Color          = Color.Black; //字体颜色
                TitleRange.Font.Name           = "宋体";        //字体
                TitleRange.Font.Size           = 12;          //字体大小
                TitleRange.HorizontalAlignment = XlHAlign.xlHAlignCenter;
                TitleRange.RowHeight           = 20;          //行高

                int displayColumnsCount = 1;
                for (int i = 0; i <= dt.Columns.Count - 1; i++)
                {
                    if (dt.Columns[i].ColumnName != "F0" && dt.Columns[i].ColumnName != "Fs" && dt.Columns[i].ColumnName != "ProName" &&
                        dt.Columns[i].ColumnName != "ResultID" && dt.Columns[i].ColumnName != "NodeName")
                    {
                        string colunmName = String.Empty;
                        if (dt.Columns[i].ColumnName == "RecordNumver")
                        {
                            colunmName = "编号";
                        }
                        if (dt.Columns[i].ColumnName == "Pramas")
                        {
                            colunmName = "参数";
                        }
                        if (dt.Columns[i].ColumnName == "PramasAndIntroduce")
                        {
                            colunmName = "参数+引导词";
                        }
                        if (dt.Columns[i].ColumnName == "DeviateDescription")
                        {
                            colunmName = "偏离描述";
                        }
                        if (dt.Columns[i].ColumnName == "Reason")
                        {
                            colunmName = "原因";
                        }
                        if (dt.Columns[i].ColumnName == "Consequence")
                        {
                            colunmName = "后果";
                        }
                        if (dt.Columns[i].ColumnName == "Measure")
                        {
                            colunmName = "现有措施";
                        }
                        if (dt.Columns[i].ColumnName == "Suggestion")
                        {
                            colunmName = "建议项";
                        }
                        if (dt.Columns[i].ColumnName == "Company")
                        {
                            colunmName = "负责单位/人";
                        }
                        if (dt.Columns[i].ColumnName == "Mark")
                        {
                            colunmName = "备注";
                        }
                        if (dt.Columns[i].ColumnName == "Si")
                        {
                            colunmName = "S";
                        }
                        if (dt.Columns[i].ColumnName == "Li")
                        {
                            colunmName = "L";
                        }
                        if (dt.Columns[i].ColumnName == "Ri")
                        {
                            colunmName = "R";
                        }
                        if (dt.Columns[i].ColumnName == "S")
                        {
                            colunmName = "Sr";
                        }
                        if (dt.Columns[i].ColumnName == "L")
                        {
                            colunmName = "Lr";
                        }
                        if (dt.Columns[i].ColumnName == "R")
                        {
                            colunmName = "Rr";
                        }
                        objExcel.Cells[6, displayColumnsCount] = colunmName;
                        displayColumnsCount++;
                    }
                    else
                    {
                    }
                }
                //向Excel中逐行逐列写入表格中的数据
                for (int row = 0; row <= dt.Rows.Count - 1; row++)
                {
                    displayColumnsCount = 1;
                    for (int col = 0; col < colscount; col++)
                    {
                        if (dt.Columns[col].ColumnName != "F0" && dt.Columns[col].ColumnName != "Fs" && dt.Columns[col].ColumnName != "ProName" &&
                            dt.Columns[col].ColumnName != "ResultID" && dt.Columns[col].ColumnName != "NodeName")
                        {
                            try
                            {
                                objExcel.Cells[row + 7, displayColumnsCount] = "'" + dt.Rows[row].ItemArray[col].ToString();
                                displayColumnsCount++;
                            }
                            catch (Exception)
                            {
                            }
                        }
                        else
                        {
                        }
                    }
                }
                //设置自适应行高
                Range endrange = objsheet.Range[objsheet.Cells[1, 1], objsheet.Cells[rowscount + 6, colscount - 5]];
                endrange.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
                endrange.WrapText          = true;
                endrange.EntireRow.AutoFit();
                //保存文件
                objWorkbook.SaveAs(fileNameString, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message, "警告 ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            MessageBox.Show("导出完毕! ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        /// <summary>
        /// Action effectuée lorsque l'on clique sur le bouton enregistrer les modifications
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnModifierParticipant_Click(object sender, EventArgs e)
        {
            List <Participant> listeParticipantsAModifier = new List <Participant>();

            List <Participant> listeParticipants = new List <Participant>();
            ParticipantBLL     partService       = new ParticipantBLL();
            Participant        partTemp          = new Participant();

            foreach (GridViewRow row in gridViewParticipants.Rows)
            {
                String id = gridViewParticipants.DataKeys[row.RowIndex]["id_participant"].ToString();

                Participant part = new Participant();
                part.id_participant = int.Parse(id);
                part.id_evenement   = int.Parse(ViewState["evenementId"].ToString());
                part.hasListe       = ((CheckBox)row.FindControl("cbHasListe")).Checked;

                //On récupère l'id de la personne
                partTemp = partService.getAllInfosByParticipant(part);
                if (partTemp != null)
                {
                    part.id_personne = partTemp.id_personne;
                }

                listeParticipants.Add(part);
            }

            //Ne garder que les participants modifiés
            int cle = int.Parse(ViewState["evenementId"].ToString());

            EvenementBLL   evtBLL  = new EvenementBLL();
            ParticipantBLL ptcpBLL = new ParticipantBLL();

            Evenement evt = evtBLL.getEvenementById(cle);

            List <Participant> listeParticipantsBefore = ptcpBLL.getAllParticipantByEvenement(evt);

            if (listeParticipants.Count == listeParticipantsBefore.Count)
            {
                for (int i = 0; i < listeParticipants.Count; i++)
                {
                    if (listeParticipants[i].id_participant == listeParticipantsBefore[i].id_participant &&
                        listeParticipants[i].hasListe != listeParticipantsBefore[i].hasListe)
                    {
                        listeParticipantsAModifier.Add(listeParticipants[i]);
                    }
                }
            }
            //Modifier les participants

            if (listeParticipantsAModifier.Count > 0)
            {
                ParticipantBLL       partBLL      = new ParticipantBLL();
                ListeIdeesCadeauxBLL listeService = new ListeIdeesCadeauxBLL();

                Boolean retour = partBLL.modifierHasListesListeParticipants(listeParticipantsAModifier) && listeService.updateActiveListe(listeParticipantsAModifier, evt);

                if (retour)
                {
                    SuccessText.Text = "Les modifications ont bien été prises en compte";
                }
                else
                {
                    FailureText.Text = "Les modifications n'ont pas pu être prises en compte";
                }

                RechargerGridViewParticipants();
            }
        }
        /// <summary>
        /// Action de suppression des participants sélectionnés
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSupprimerParticipant_Click(object sender, EventArgs e)
        {
            //L'utilisateur a confirmé la suppression des participants
            if ("Y".Equals(supprimerParticipants.Value))
            {
                Boolean            connecteEstParticipantASupprimer = false;
                List <Participant> listeParticipantsASupprimer      = new List <Participant>();
                ParticipantBLL     partService = new ParticipantBLL();
                Participant        partTemp    = new Participant();

                foreach (GridViewRow row in gridViewParticipants.Rows)
                {
                    CheckBox cbChoixParticipant = ((CheckBox)row.FindControl("cbChoix"));

                    if (cbChoixParticipant.Checked)
                    {
                        String id = gridViewParticipants.DataKeys[row.RowIndex]["id_participant"].ToString();
                        if (id.Equals(Session["personneID"].ToString()))
                        {
                            connecteEstParticipantASupprimer = true;
                        }

                        Participant part = new Participant();
                        part.id_participant = int.Parse(id);
                        part.id_evenement   = int.Parse(ViewState["evenementId"].ToString());

                        partTemp = partService.getAllInfosByParticipant(part);
                        if (partTemp != null)
                        {
                            part.id_personne = partTemp.id_personne;
                        }

                        listeParticipantsASupprimer.Add(part);
                    }
                }
                if (!connecteEstParticipantASupprimer)
                {
                    ListeIdeesCadeauxBLL listeService = new ListeIdeesCadeauxBLL();

                    ProjetCadeaux_Entites.Evenement evt = new ProjetCadeaux_Entites.Evenement();
                    evt.id_evenement = int.Parse(ViewState["evenementId"].ToString());

                    Boolean retour = partService.supprimerListeParticipants(listeParticipantsASupprimer) && listeService.desactiverListe(listeParticipantsASupprimer, evt);

                    if (retour)
                    {
                        SuccessText.Text = "Tous les participants sélectionnés ont pu être supprimés";
                    }
                    else
                    {
                        FailureText.Text = "Les participants n'ont pas pu être supprimés";
                    }

                    RechargerGridViewParticipants();
                }
                else
                {
                    FailureText.Text = "Vous ne pouvez supprimer l'administrateur de l'évènement";
                }
            }
        }