//------------------------------------------------- public void Init( IDataHotelCalcul calcul, CEasyQuery query, CODEQTableFromDataHotel table) { m_calcul = calcul as CDataHotelCalculDuration; if (m_calcul == null) { m_calcul = new CDataHotelCalculDuration(); } List <CColumnEQFromSource> cols = new List <CColumnEQFromSource>(); CColumnEQFromSource colSel = null; foreach (IColumnDeEasyQuery colTest in table.Columns) { CColumnEQFromSource cs = colTest as CColumnEQFromSource; if (cs != null && colTest != null && colTest.DataType == typeof(double)) { cols.Add(cs); if (cs.IdColumnSource == m_calcul.IdChampSource) { colSel = cs; } } } m_cmbChampSource.SelectedValue = colSel; if (table != null) { m_cmbChampSource.ListDonnees = cols; m_cmbChampSource.ProprieteAffichee = "ColumnName"; m_cmbChampSource.AssureRemplissage(); m_cmbChampSource.SelectedItem = colSel; } m_panelFiltre.Init(query, m_calcul.Filtre, table); }
//--------------------------------------------------------------- private void m_btnOk_Click(object sender, EventArgs e) { if (m_txtNomTable.Text.Length == 0) { MessageBox.Show(I.T("Please enter a table name|20004")); return; } m_tableFromDataHotel.NomFinal = m_txtNomTable.Text; m_tableFromDataHotel.UseCache = m_chkUseCache.Checked; List <IColumnDeEasyQuery> lst = new List <IColumnDeEasyQuery>(); foreach (ListViewItem item in m_wndListeColonnes.Items) { if (item.Checked) { IColumnDefinition colFromSource = item.Tag as IColumnDefinition; if (colFromSource != null) { IColumnDeEasyQuery newCol = m_tableFromDataHotel.GetColonneFor(colFromSource); if (newCol == null) { newCol = new CColumnEQFromSource(colFromSource); } newCol.ColumnName = item.Text; lst.Add(newCol); } CColonneCalculeeDataHotel colCalc = item.Tag as CColonneCalculeeDataHotel; if (colCalc != null) { colCalc.ColumnName = item.Text; lst.Add(colCalc); } } } m_tableFromDataHotel.SetColonnesOrCalculees(lst); List <CColonneEQCalculee> colsCalc = new List <CColonneEQCalculee>(); foreach (CColonneEQCalculee col in m_ctrlFormulesNommees.GetFormules()) { colsCalc.Add(col); } m_tableFromDataHotel.ColonnesCalculees = colsCalc; CResultAErreur result = m_panelOptions.MajChamps(m_tableFromDataHotel); if (!result) { CFormAlerte.Afficher(result.Erreur); return; } DialogResult = DialogResult.OK; Close(); }
//-------------------------------------------------- public string GetLibelle(IObjetDeEasyQuery table) { CColumnEQFromSource col = table.Columns.FirstOrDefault(c => c is CColumnEQFromSource && ((CColumnEQFromSource)c).IdColumnSource == m_strHotelColonneId) as CColumnEQFromSource; return((col != null ? col.ColumnName : "?") + new COperateurComparaisonMassStorage(m_operateur).Libelle + (m_formuleValeur != null ? m_formuleValeur.GetString() : "?")); }
//------------------------------------------------------- public IColumnDefinition GetColumnDefinitionFor(IColumnDeEasyQuery colonne) { CColumnEQFromSource colFromSource = colonne as CColumnEQFromSource; if (m_definitionTable != null && colFromSource != null) { return(m_definitionTable.Columns.FirstOrDefault(c => c.Id == colFromSource.IdColumnSource)); } return(null); }
//-------------------------------------------------------------- public void Init( CEasyQuery query, IObjetDeEasyQuery table, CDHFiltreValeur comparaison) { m_query = query; m_table = table; if (comparaison == null) { comparaison = new CDHFiltreValeur(); } m_comparaison = comparaison; List <COperateurComparaisonMassStorage> ops = new List <COperateurComparaisonMassStorage>(); foreach (EOperateurComparaisonMassStorage op in COperateurComparaisonMassStorage.ValeursEnumPossibles) { ops.Add(new COperateurComparaisonMassStorage(op)); } m_comboOperateur.ListDonnees = ops; m_comboOperateur.ProprieteAffichee = "Libelle"; m_comboOperateur.SelectedValue = new COperateurComparaisonMassStorage(comparaison.Operateur); IColumnDeEasyQuery colSel = null; List <CColumnEQFromSource> cols = new List <CColumnEQFromSource>(); foreach (IColumnDeEasyQuery col in m_table.Columns) { CColumnEQFromSource cs = col as CColumnEQFromSource; if (cs != null && col.DataType == typeof(double)) { cols.Add(cs); if (cs.IdColumnSource == m_comparaison.ColumnHotelId) { colSel = col; } } } m_comboChamp.ListDonnees = cols; m_comboChamp.ProprieteAffichee = "ColumnName"; m_comboChamp.SelectedValue = colSel; m_txtFormuleValeur.Init( new CFournisseurGeneriqueProprietesDynamiques(), new CObjetPourSousProprietes(m_query)); m_txtFormuleValeur.Formule = comparaison.FormuleValeur; m_txtFormuleCondition.Init( new CFournisseurGeneriqueProprietesDynamiques(), new CObjetPourSousProprietes(m_query)); m_txtFormuleCondition.Formule = comparaison.FormuleApplication; }
//------------------------------------------------------- public CODEQTableFromDataHotel(ITableDefinition definition) : base() { NomFinal = definition.TableName; Size = new Size(80, 150); m_definitionTable = definition; if (m_definitionTable != null) { foreach (IColumnDefinition def in m_definitionTable.Columns) { CColumnEQFromSource col = new CColumnEQFromSource(def); m_listeColonnes.Add(col); } } }
//------------------------------------------------- public CResultAErreurType <IDataHotelCalcul> GetCalcul() { CResultAErreurType <IDataHotelCalcul> res = new CResultAErreurType <IDataHotelCalcul>(); CColumnEQFromSource col = m_cmbChampSource.SelectedValue as CColumnEQFromSource; if (col == null) { res.EmpileErreur(I.T("Select a source field|20033")); return(res); } IDHFiltre filtre = m_panelFiltre.MajAndGetFiltre(); m_calcul.IdChampSource = col.IdColumnSource; m_calcul.Filtre = filtre; res.DataType = m_calcul; return(res); }
//-------------------------------------------------------- private void FillListeColonnes() { if (m_tableFromFramework != null) { Dictionary <string, CColumnEQFromSource> dicIdSourceToCol = new Dictionary <string, CColumnEQFromSource>(); foreach (IColumnDeEasyQuery col in m_tableFromFramework.ColonnesOrCalculees) { CColumnEQFromSource colFromSource = col as CColumnEQFromSource; if (colFromSource == null) { ListViewItem item = new ListViewItem(col.ColumnName); item.Tag = col; m_wndListeColonnes.Items.Add(item); } else { dicIdSourceToCol[colFromSource.IdColumnSource] = colFromSource; } } IObjetDeEasyQuery tableParent = m_tableFromFramework.ElementsSource.Length > 0 ? m_tableFromFramework.ElementsSource[0] : null; if (tableParent != null) { foreach (IColumnDeEasyQuery col in tableParent.Columns) { ListViewItem item = new ListViewItem(col.ColumnName); item.SubItems.Add(col.ColumnName); CColumnEQFromSource colFromSource = null; if (dicIdSourceToCol.TryGetValue(col.Id, out colFromSource)) { item.Text = colFromSource.ColumnName; item.Checked = true; colFromSource.DataType = col.DataType; } item.Tag = col; m_wndListeColonnesFromParent.Items.Add(item); } } } }
//------------------------------------------------------- protected override CResultAErreur GetDatasHorsCalculees(CListeQuerySource sources) { CEasyQuery query = Query; CResultAErreur result = CResultAErreur.True; if (query == null || sources == null) { result.EmpileErreur(I.T("Table @1 needs a source to provide datas|20001", NomFinal)); return(result); } CEasyQuerySource source = sources.GetSourceFromId(TableDefinition.SourceId); CDataHotelConnexion hotelConnexion = source != null ? source.Connexion as CDataHotelConnexion : null; if (hotelConnexion == null) { result.EmpileErreur(I.T("No connection for table @1|20006", NomFinal)); return(result); } CTableDefinitionDataHotel tableHotel = m_definitionTable as CTableDefinitionDataHotel; if (tableHotel == null) { result.EmpileErreur(I.T("Table @1 can not be calculated. A DataHotel table should be used as source|20002", NomFinal)); return(result); } DateTime?dateDebut = null; DateTime?dateFin = null; CContexteEvaluationExpression ctxEval = new CContexteEvaluationExpression(Query); if (m_formuleDateDebut != null) { result = m_formuleDateDebut.Eval(ctxEval); if (!result) { result.EmpileErreur(I.T("Error on start date formula in table @1|20003", NomFinal)); } else { dateDebut = result.Data as DateTime?; } } if (m_formuleDateFin != null) { result = m_formuleDateFin.Eval(ctxEval); if (!result) { result.EmpileErreur(I.T("Error on end date formula in table @1|20004", NomFinal)); } else { dateFin = result.Data as DateTime?; } } if (dateDebut == null || dateFin == null) { result.EmpileErreur(I.T("Both start date and end date must be set for table @1|20005", NomFinal)); } if (!result) { return(result); } List <string> lstIdsEntites = new List <string>(); if (SourceEntites != null) { lstIdsEntites.AddRange(SourceEntites.GetListeIdsEntites(Query)); } ITestDataHotel test = null; //Calcule le filtre if (m_filtre != null) { test = m_filtre.GetTestFinal(Query); } CDataHotelQuery hotelQuery = new CDataHotelQuery(); hotelQuery.TableId = tableHotel.Id; hotelQuery.DateDebut = dateDebut.Value; hotelQuery.DateFin = dateFin.Value; hotelQuery.EntitiesId.AddRange(lstIdsEntites); hotelQuery.Filtre = test; List <string> lstIdsColonnes = new List <string>(); List <IChampHotelCalcule> lstCalcs = new List <IChampHotelCalcule>(); foreach (IColumnDeEasyQuery col in m_listeColonnes) { CColumnEQFromSource colFromSource = col as CColumnEQFromSource; if (colFromSource != null) { lstIdsColonnes.Add(colFromSource.IdColumnSource); } CColonneCalculeeDataHotel colCalc = col as CColonneCalculeeDataHotel; if (colCalc != null) { if (colCalc.Calcul != null) { IChampHotelCalcule champHotelCalc = colCalc.Calcul.GetChampHotel(Query); if (champHotelCalc != null) { champHotelCalc.NomChampFinal = colCalc.ColumnName; lstCalcs.Add(champHotelCalc); } } } } hotelQuery.ChampsId = lstIdsColonnes; hotelQuery.ChampsCalcules = lstCalcs; DataTable tableResult = hotelConnexion.GetData(tableHotel, hotelQuery); if (tableResult != null) { Dictionary <string, IColumnDeEasyQuery> colNameSourceToDestCol = new Dictionary <string, IColumnDeEasyQuery>(); foreach (IColumnDeEasyQuery col in m_listeColonnes) { CColumnEQFromSource cs = col as CColumnEQFromSource; if (cs != null) { IColumnDefinition def = tableHotel.GetColumn(cs.IdColumnSource); if (def != null) { colNameSourceToDestCol[def.ColumnName] = col; } } } foreach (DataColumn col in tableResult.Columns) { IColumnDeEasyQuery colThis = null; if (colNameSourceToDestCol.TryGetValue(col.ColumnName, out colThis)) { col.ColumnName = colThis.ColumnName; } } } result.Data = tableResult; return(result); }
//----------------------------------- private void m_btnOk_Click(object sender, EventArgs e) { if (m_txtNomTable.Text.Length == 0) { MessageBox.Show(I.T("Please enter a table name|20004")); return; } List <CParametreJointure> lstParametres = new List <CParametreJointure>(); ArrayList lst = new ArrayList(m_panelJointure.Controls); lst.Reverse(); foreach (Control ctrl in lst) { CEditeurParametreJointure editeur = ctrl as CEditeurParametreJointure; if (editeur != null) { CResultAErreur result = editeur.MajChamps(); if (!result) { editeur.BackColor = Color.Red; CFormAfficheErreur.Show(result.Erreur); return; } editeur.BackColor = BackColor; lstParametres.Add(editeur.Parametre); } } List <IColumnDeEasyQuery> lstColonnes = new List <IColumnDeEasyQuery>(); foreach (ListViewItem item in m_wndListeColonnes1.Items) { if (item.Checked) { IColumnDeEasyQuery col = item.Tag as IColumnDeEasyQuery; if (col != null) { bool bColExiste = false; foreach (IColumnDeEasyQuery colEx in m_objetJointure.ColonnesSource) { CColumnEQFromSource colExSrc = colEx as CColumnEQFromSource; if (colExSrc != null && colExSrc.IdColumnSource == col.Id) { colEx.ColumnName = item.Text; lstColonnes.Add(colEx); bColExiste = true; break; } } if (!bColExiste) { IColumnDeEasyQuery newCol = new CColumnEQFromSource(col); newCol.ColumnName = item.Text; lstColonnes.Add(newCol); } } } } foreach (ListViewItem item in m_wndListeColonnes2.Items) { if (item.Checked) { IColumnDeEasyQuery col = item.Tag as IColumnDeEasyQuery; if (col != null) { bool bColExiste = false; foreach (IColumnDeEasyQuery colEx in m_objetJointure.ColonnesSource) { CColumnEQFromSource colExSrc = colEx as CColumnEQFromSource; if (colExSrc != null && colExSrc.IdColumnSource == col.Id) { colEx.ColumnName = item.Text; lstColonnes.Add(colEx); bColExiste = true; break; } } if (!bColExiste) { IColumnDeEasyQuery newCol = new CColumnEQFromSource(col); newCol.ColumnName = item.Text; lstColonnes.Add(newCol); } } } } m_objetJointure.UseCache = m_chkUseCache.Checked; m_objetJointure.ModeJointure = (CODEQJointure.EModeJointure)m_cmbTypeJointure.SelectedIndex; m_objetJointure.ColonnesSource = lstColonnes; m_objetJointure.ParametresJointure = lstParametres; m_objetJointure.NomFinal = m_txtNomTable.Text; DialogResult = DialogResult.OK; Close(); }
//----------------------------------- private void m_btnOk_Click(object sender, EventArgs e) { if (m_txtNomTable.Text.Length == 0) { MessageBox.Show(I.T("Please enter a table name|20004")); return; } CResultAErreur result = CResultAErreur.True; if (m_txtEditeFormule.Formule == null) { result = m_txtEditeFormule.ResultAnalyse; if (result == null) { result = CResultAErreur.True; } result.EmpileErreur(I.T("Error in the formula|20011")); CFormAfficheErreur.Show(result.Erreur); return; } m_tableFiltre.NomFinal = m_txtNomTable.Text; m_tableFiltre.UseCache = m_chkUseCache.Checked; m_tableFiltre.Formule = m_txtEditeFormule.Formule; m_tableFiltre.InclureToutesLesColonnesSource = m_chkInclureTout.Checked; if (!m_tableFiltre.InclureToutesLesColonnesSource) { List <CColumnEQFromSource> lstColonnes = new List <CColumnEQFromSource>(); foreach (ListViewItem item in m_wndListeColonnesFromSource.Items) { if (item.Checked) { IColumnDeEasyQuery col = item.Tag as IColumnDeEasyQuery; if (col != null) { bool bColExiste = false; foreach (IColumnDeEasyQuery colEx in m_tableFiltre.ColonnesFromSource) { CColumnEQFromSource colExSrc = colEx as CColumnEQFromSource; if (colExSrc != null && colExSrc.IdColumnSource == col.Id) { colEx.ColumnName = item.Text; lstColonnes.Add(colExSrc); bColExiste = true; break; } } if (!bColExiste) { CColumnEQFromSource newCol = new CColumnEQFromSource(col); newCol.ColumnName = item.Text; lstColonnes.Add(newCol); } } } } m_tableFiltre.ColonnesFromSource = lstColonnes.AsReadOnly(); } else { m_tableFiltre.ColonnesFromSource = null; } result = m_panelPostFilter.MajChamps(); if (!result) { CFormAlerte.Afficher(result.Erreur); return; } List <CColonneEQCalculee> lst = new List <CColonneEQCalculee>(); foreach (CColonneEQCalculee col in m_ctrlFormulesNommees.GetFormules()) { lst.Add(col); } m_tableFiltre.ColonnesCalculeesFromSource = lst; DialogResult = DialogResult.OK; Close(); }
private void m_btnOk_Click(object sender, EventArgs e) { if (m_txtNomTable.Text.Length == 0) { MessageBox.Show(I.T("Please enter a table name|20004")); return; } m_tableFromBase.NomFinal = m_txtNomTable.Text; m_tableFromBase.UseCache = m_chkUseCache.Checked; List <IColumnDeEasyQuery> lst = new List <IColumnDeEasyQuery>(); foreach (ListViewItem item in m_wndListeColonnes.Items) { if (item.Checked) { IColumnDefinition colFromSource = item.Tag as IColumnDefinition; IColumnDeEasyQuery newCol = m_tableFromBase.GetColonneFor(colFromSource); if (newCol == null) { newCol = new CColumnEQFromSource(colFromSource); } newCol.ColumnName = item.Text; lst.Add(newCol); } } m_tableFromBase.SetColonnesOrCalculees(lst); List <CColonneEQCalculee> colsCalc = new List <CColonneEQCalculee>(); foreach (CColonneEQCalculee col in m_ctrlFormulesNommees.GetFormules()) { colsCalc.Add(col); } m_tableFromBase.ColonnesCalculees = colsCalc; CResultAErreur result = CResultAErreur.True; if (m_controleOptions != null) { result = m_controleOptions.MajChamps(); } CResultAErreurType <CCAMLQuery> resCAML = m_panelCAML.MajChamps(); if (!resCAML) { result.EmpileErreur(resCAML.Erreur); } else { m_tableFromBase.CAMLQuery = resCAML.DataType; } if (result) { result = m_panelPostFilter.MajChamps(); } if (!result) { CFormAlerte.Afficher(result.Erreur); return; } DialogResult = DialogResult.OK; Close(); }
//------------------------------------------------------- protected override CResultAErreur GetDatasHorsCalculees(CListeQuerySource sources) { CResultAErreur result = CResultAErreur.True; if (sources == null) { result.EmpileErreur(I.T("Table @1 needs a source to provide datas|20001", NomFinal)); return(result); } CEasyQuerySource source = sources.GetSourceFromId(TableDefinition.SourceId); CDataHotelConnexion hotelConnexion = source != null ? source.Connexion as CDataHotelConnexion : null; if (hotelConnexion == null) { result.EmpileErreur(I.T("No connection for table @1|20006", NomFinal)); return(result); } CTableDefinitionEntitiesDataHotel tableHotel = m_definitionTable as CTableDefinitionEntitiesDataHotel; if (tableHotel == null) { result.EmpileErreur(I.T("Table @1 can not be calculated. A DataHotel table should be used as source|20002", NomFinal)); return(result); } DateTime?dateDebut = null; DateTime?dateFin = null; CContexteEvaluationExpression ctxEval = new CContexteEvaluationExpression(Query); if (m_formuleDateDebut != null) { result = m_formuleDateDebut.Eval(ctxEval); if (!result) { result.EmpileErreur(I.T("Error on start date formula in table @1|20003", NomFinal)); } else { dateDebut = result.Data as DateTime?; } } if (m_formuleDateFin != null) { result = m_formuleDateFin.Eval(ctxEval); if (!result) { result.EmpileErreur(I.T("Error on end date formula in table @1|20004", NomFinal)); } else { dateFin = result.Data as DateTime?; } } if (dateDebut == null || dateFin == null) { result.EmpileErreur(I.T("Both start date and end date must be set for table @1|20005", NomFinal)); } if (!result) { return(result); } DataTable tableResult = hotelConnexion.GetData(tableHotel, dateDebut.Value, dateFin.Value); if (tableResult != null) { Dictionary <string, IColumnDeEasyQuery> colNameSourceToDestCol = new Dictionary <string, IColumnDeEasyQuery>(); foreach (IColumnDeEasyQuery col in m_listeColonnes) { CColumnEQFromSource cs = col as CColumnEQFromSource; if (cs != null) { IColumnDefinition def = tableHotel.GetColumn(cs.IdColumnSource); if (def != null) { colNameSourceToDestCol[def.ColumnName] = col; } } } foreach (DataColumn col in tableResult.Columns) { IColumnDeEasyQuery colThis = null; if (colNameSourceToDestCol.TryGetValue(col.ColumnName, out colThis)) { col.ColumnName = colThis.ColumnName; } } } result.Data = tableResult; return(result); }
//-------------------------------------------------------- private void m_btnOk_Click(object sender, EventArgs e) { if (m_txtNomTable.Text.Length == 0) { MessageBox.Show(I.T("Please enter a table name|20101")); return; } m_tableFromFramework.FiltreDynamique = m_panelFiltre.FiltreDynamique; m_tableFromFramework.ChampSource = m_champ; m_tableFromFramework.NomFinal = m_txtNomTable.Text; m_tableFromFramework.UseCache = m_chkUseCache.Checked; List <IColumnDeEasyQuery> lst = new List <IColumnDeEasyQuery>(); foreach (ListViewItem item in m_wndListeColonnes.Items) { CColumnDeEasyQueryChampDeRequete col = item.Tag as CColumnDeEasyQueryChampDeRequete; if (col != null) { lst.Add(col); } } foreach (ListViewItem item in m_wndListeColonnesFromParent.Items) { if (item.Checked) { IColumnDeEasyQuery col = item.Tag as IColumnDeEasyQuery; if (col != null) { bool bColExiste = false; foreach (IColumnDeEasyQuery colEx in m_tableFromFramework.Columns) { CColumnEQFromSource colExSrc = colEx as CColumnEQFromSource; if (colExSrc != null && colExSrc.IdColumnSource == col.Id) { colEx.ColumnName = item.Text; lst.Add(colEx); bColExiste = true; break; } } if (!bColExiste) { IColumnDeEasyQuery newCol = new CColumnEQFromSource(col); newCol.ColumnName = item.Text; lst.Add(newCol); } } } } m_tableFromFramework.SetColonnesOrCalculees(lst); List <CColonneEQCalculee> colsCalc = new List <CColonneEQCalculee>(); foreach (CColonneEQCalculee col in m_ctrlFormulesNommees.GetFormules()) { colsCalc.Add(col); } m_tableFromFramework.ColonnesCalculees = colsCalc; CResultAErreur result = CResultAErreur.True; if (m_controleOptions != null) { result = m_controleOptions.MajChamps(); } if (result) { result = m_panelPostFilter.MajChamps(); } if (!result) { CFormAlerte.Afficher(result.Erreur); return; } DialogResult = DialogResult.OK; Close(); }