예제 #1
0
 internal static LoadRdlcReport GetInstance()
 {
     if (fact == null)
     {
         fact = new LoadRdlcReport();
     }
     return(fact);
 }
        private void LoadReport(int selectedIndex)
        {
            //Initialisation de la chaine de connexion
            conn = new SqlConnection(Model.Properties.Settings.Default.strChaineConnexion);

            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }

            switch (cboCategorieItem.SelectedIndex)
            {
            case 0:
                //***Par identifiant équipement
                #region Par identifiant équipement
                using (IDbCommand cmd = conn.CreateCommand())
                {
                    SqlDataAdapter adapter = null;
                    DataSet        dataset = null;

                    cmd.CommandText = Queries.GetInstance().CommonQueryAffectationMateriel("where materiel.code_str=@code_str and materiel.archiver=@archiver");

                    SqlCommand sqlCmd = cmd as SqlCommand;
                    adapter = new SqlDataAdapter(sqlCmd);

                    cmd.Parameters.Add(clsMetier.GetInstance().getParameter(cmd, "@code_str", DbType.String, 10, cboIdentifiant.SelectedValue));
                    cmd.Parameters.Add(clsMetier.GetInstance().getParameter(cmd, "@archiver", DbType.Boolean, 2, chkArchiver.Checked));

                    dataset = LoadRdlcReport.GetInstance().LoadReportWithSubReportSignataire(adapter, "DataSet1", "smartManage.Desktop.Reports.RptAffectationMateriel.rdlc", rpvReport);

                    if (dataset != null)
                    {
                        dataset.Dispose();
                    }
                    if (adapter != null)
                    {
                        adapter.Dispose();
                    }
                    if (conn != null)
                    {
                        conn.Close();
                    }
                }
                #endregion
                break;

            case 1:
                //***Par année académique
                #region Par année académique
                using (IDbCommand cmd = conn.CreateCommand())
                {
                    SqlDataAdapter adapter = null;
                    DataSet        dataset = null;

                    cmd.CommandText = Queries.GetInstance().CommonQueryAffectationMateriel("where AC.code_str=@code_str and materiel.archiver=@archiver");

                    SqlCommand sqlCmd = cmd as SqlCommand;
                    adapter = new SqlDataAdapter(sqlCmd);

                    cmd.Parameters.Add(clsMetier.GetInstance().getParameter(cmd, "@code_str", DbType.String, 50, cboAC.SelectedValue));
                    cmd.Parameters.Add(clsMetier.GetInstance().getParameter(cmd, "@archiver", DbType.Boolean, 2, chkArchiver.Checked));

                    dataset = LoadRdlcReport.GetInstance().LoadReportWithSubReportSignataire(adapter, "DataSet1", "smartManage.Desktop.Reports.RptAffectationMateriel.rdlc", rpvReport);

                    if (dataset != null)
                    {
                        dataset.Dispose();
                    }
                    if (adapter != null)
                    {
                        adapter.Dispose();
                    }
                    if (conn != null)
                    {
                        conn.Close();
                    }
                }
                #endregion
                break;

            case 2:
                //***Par type de lieu d'affectation
                #region Par type de lieu d'affectation
                using (IDbCommand cmd = conn.CreateCommand())
                {
                    SqlDataAdapter adapter = null;
                    DataSet        dataset = null;

                    cmd.CommandText = Queries.GetInstance().CommonQueryAffectationMateriel("where type_lieu_affectation.designation=@designation and materiel.archiver=@archiver");

                    SqlCommand sqlCmd = cmd as SqlCommand;
                    adapter = new SqlDataAdapter(sqlCmd);

                    cmd.Parameters.Add(clsMetier.GetInstance().getParameter(cmd, "@designation", DbType.String, 50, cboTypeLieuAffectation.SelectedValue));
                    cmd.Parameters.Add(clsMetier.GetInstance().getParameter(cmd, "@archiver", DbType.Boolean, 2, chkArchiver.Checked));

                    dataset = LoadRdlcReport.GetInstance().LoadReportWithSubReportSignataire(adapter, "DataSet1", "smartManage.Desktop.Reports.RptAffectationMateriel.rdlc", rpvReport);

                    if (dataset != null)
                    {
                        dataset.Dispose();
                    }
                    if (adapter != null)
                    {
                        adapter.Dispose();
                    }
                    if (conn != null)
                    {
                        conn.Close();
                    }
                }
                #endregion
                break;

            case 3:
                //***Par lieu d'affectation
                #region Par lieu d'affectation
                using (IDbCommand cmd = conn.CreateCommand())
                {
                    SqlDataAdapter adapter = null;
                    DataSet        dataset = null;

                    cmd.CommandText = Queries.GetInstance().CommonQueryAffectationMateriel("where lieu_affectation.designation=@designation and materiel.archiver=@archiver");

                    SqlCommand sqlCmd = cmd as SqlCommand;
                    adapter = new SqlDataAdapter(sqlCmd);

                    cmd.Parameters.Add(clsMetier.GetInstance().getParameter(cmd, "@designation", DbType.String, 50, cboLieuAffectation.SelectedValue));
                    cmd.Parameters.Add(clsMetier.GetInstance().getParameter(cmd, "@archiver", DbType.Boolean, 2, chkArchiver.Checked));

                    dataset = LoadRdlcReport.GetInstance().LoadReportWithSubReportSignataire(adapter, "DataSet1", "smartManage.Desktop.Reports.RptAffectationMateriel.rdlc", rpvReport);

                    if (dataset != null)
                    {
                        dataset.Dispose();
                    }
                    if (adapter != null)
                    {
                        adapter.Dispose();
                    }
                    if (conn != null)
                    {
                        conn.Close();
                    }
                }
                #endregion
                break;

            case 4:
                //***Par catégorie matériel
                #region Par catégorie matériel
                using (IDbCommand cmd = conn.CreateCommand())
                {
                    SqlDataAdapter adapter = null;
                    DataSet        dataset = null;

                    cmd.CommandText = Queries.GetInstance().CommonQueryAffectationMateriel("where categorie_materiel.designation=@designation and materiel.archiver=@archiver");

                    SqlCommand sqlCmd = cmd as SqlCommand;
                    adapter = new SqlDataAdapter(sqlCmd);

                    cmd.Parameters.Add(clsMetier.GetInstance().getParameter(cmd, "@designation", DbType.String, 50, cboCategorieMateriel.SelectedValue));
                    cmd.Parameters.Add(clsMetier.GetInstance().getParameter(cmd, "@archiver", DbType.Boolean, 2, chkArchiver.Checked));

                    dataset = LoadRdlcReport.GetInstance().LoadReportWithSubReportSignataire(adapter, "DataSet1", "smartManage.Desktop.Reports.RptAffectationMateriel.rdlc", rpvReport);

                    if (dataset != null)
                    {
                        dataset.Dispose();
                    }
                    if (adapter != null)
                    {
                        adapter.Dispose();
                    }
                    if (conn != null)
                    {
                        conn.Close();
                    }
                }
                #endregion
                break;

            case 6:
                //***Par date d'affectation de matériel
                #region Par date d'affectation de matériel
                using (IDbCommand cmd = conn.CreateCommand())
                {
                    SqlDataAdapter adapter = null;
                    DataSet        dataset = null;

                    cmd.CommandText = Queries.GetInstance().CommonQueryAffectationMateriel("where categorie_materiel.designation=@designation and materiel.archiver=@archiver");

                    SqlCommand sqlCmd = cmd as SqlCommand;
                    adapter = new SqlDataAdapter(sqlCmd);

                    cmd.Parameters.Add(clsMetier.GetInstance().getParameter(cmd, "@designation", DbType.String, 50, cboCategorieMateriel.SelectedValue));
                    cmd.Parameters.Add(clsMetier.GetInstance().getParameter(cmd, "@archiver", DbType.Boolean, 2, chkArchiver.Checked));

                    dataset = LoadRdlcReport.GetInstance().LoadReportWithSubReportSignataire(adapter, "DataSet1", "smartManage.Desktop.Reports.RptAffectationMateriel.rdlc", rpvReport);

                    if (dataset != null)
                    {
                        dataset.Dispose();
                    }
                    if (adapter != null)
                    {
                        adapter.Dispose();
                    }
                    if (conn != null)
                    {
                        conn.Close();
                    }
                }
                #endregion
                break;
            }
        }