Ejemplo n.º 1
0
        //----------------------------------------------------------------------------+
        //                                TabItem_Drop                                |
        //----------------------------------------------------------------------------+
        private void TabItem_Drop(object sender, DragEventArgs e)
        {
            if (_ReadOnly)
            {
                return;
            }
            var tabItemTarget = e.Source as TabItem;

            if (tabItemTarget.Header.ToString() == App.NewTabHeaderText)
            {
                return;
            }
            var tabItemSource = e.Data.GetData(typeof(TabItem)) as TabItem;

            if (!tabItemTarget.Equals(tabItemSource))
            {
                string    sourceHeader  = tabItemSource.Header.ToString();
                ucTabella sourceContent = tabItemSource.Content as ucTabella;
                tabItemSource.Content = null;
                sourceContent.ChangeAlias(sourceHeader);
                string    targetHeader  = tabItemTarget.Header.ToString();
                ucTabella targetContent = tabItemTarget.Content as ucTabella;
                tabItemTarget.Content = null;
                targetContent.ChangeAlias(targetHeader);
                tabItemSource.Header  = targetHeader;
                tabItemSource.Content = targetContent;
                tabItemTarget.Header  = sourceHeader;
                tabItemTarget.Content = sourceContent;
            }
        }
Ejemplo n.º 2
0
        public void Load(ref XmlDataProviderManager x, string ID, string tab, Hashtable Sessioni, int SessioneNow, string Tab, string IDTree, string IDCliente)
        {
            _x  = x;
            _ID = ID;
            id  = int.Parse(ID.ToString());
            cBusinessObjects.idcliente  = int.Parse(IDCliente.ToString());
            cBusinessObjects.idsessione = int.Parse(Sessioni[SessioneNow].ToString());

            TabItem ti;

            dati = cBusinessObjects.GetData(id, typeof(NodoMultiplo));
            foreach (DataRow dtrow in dati.Rows)
            {
                ti        = new TabItem();
                ti.Header = dtrow["Tab"].ToString();

                switch (dtrow["Tipologia"].ToString())
                {
                case "Testo":
                    ucTesto Testo = new ucTesto();
                    Testo.ReadOnly = _ReadOnly;
                    Testo.Load(dtrow["ID"].ToString(), IDCliente, Sessioni[SessioneNow].ToString());

                    ti.Content = Testo;
                    break;

                case "Tabella":
                    ucTabella Tabella = new ucTabella();
                    Tabella.ReadOnly = _ReadOnly;
                    Tabella.Load(dtrow["ID"].ToString(), "", IDTree, "", IDCliente, Sessioni[SessioneNow].ToString());

                    ti.Content = Tabella;
                    break;

                case "Tabella Replicabile":
                    ucTabellaReplicata TabellaReplicata = new ucTabellaReplicata();
                    TabellaReplicata.ReadOnly = _ReadOnly;
                    TabellaReplicata.Load(dtrow["ID"].ToString(), dtrow["Tab"].ToString(), IDTree, IDCliente, Sessioni[SessioneNow].ToString());

                    ti.Content = TabellaReplicata;
                    break;

                case "Check List":
                    ucCheckList CheckList = new ucCheckList();
                    CheckList.ReadOnly = _ReadOnly;
                    CheckList.Load(dtrow["ID"].ToString(), IDCliente, Sessioni[SessioneNow].ToString());

                    ti.Content = CheckList;
                    break;

                case "Check List +":
                    ucCheckListPlus CheckListPlus = new ucCheckListPlus();
                    CheckListPlus.ReadOnly = _ReadOnly;
                    CheckListPlus.Load(dtrow["ID"].ToString(), IDCliente, Sessioni[SessioneNow].ToString());

                    ti.Content = CheckListPlus;
                    break;

                case "Nodo Multiplo":
                    ucNodoMultiplo NodoMultiplo = new ucNodoMultiplo();
                    NodoMultiplo.ReadOnly = _ReadOnly;
                    NodoMultiplo.Load(ref _x, dtrow["ID"].ToString(), dtrow["Tab"].ToString(), Sessioni, SessioneNow, Tab, IDTree, IDCliente);

                    ti.Content = NodoMultiplo;
                    break;

                case "Excel: Errori Rilevati":
                    uc_Excel_ErroriRilevati uce_er = new uc_Excel_ErroriRilevati();

                    try
                    {
                        uce_er.LoadDataSource(dtrow["ID"].ToString(), IDCliente, Sessioni[SessioneNow].ToString());
                    }
                    catch (Exception ex)
                    {
                        string log = ex.Message;
                    }

                    ti.Content = uce_er;
                    break;

                case "Excel: Bilancio":

                    uc_Excel_Bilancio uce_b = new uc_Excel_Bilancio(1);

                    try
                    {
                        XmlDataProviderManager _x_AP = null;

                        //if (Sessioni.Contains((SessioneNow + 1)))
                        //{
                        //	_x_AP = new XmlDataProviderManager(Sessioni[(SessioneNow + 1)].ToString());
                        //}

                        uce_b.LoadDataSource(ref _x, ID, _x_AP, App.AppDataFolder + "\\" + Tab, IDCliente, cBusinessObjects.idsessione.ToString());
                    }
                    catch (Exception ex)
                    {
                        string log = ex.Message;
                        break;                                // uce_b.LoadDataSource(ref _x, "-1", null);
                    }

                    ti.Content = uce_b;
                    break;

                default:
                    break;
                }

                tabControl.Items.Add(ti);
            }
        }
Ejemplo n.º 3
0
        //----------------------------------------------------------------------------+
        //                                    Load                                    |
        //----------------------------------------------------------------------------+
        public void Load(string ID, string tab, string IDTree, string IDCliente, string IDSessione)
        {
            id = int.Parse(ID.ToString());
            cBusinessObjects.idcliente  = int.Parse(IDCliente.ToString());
            cBusinessObjects.idsessione = int.Parse(IDSessione.ToString());

            _ID = ID;


            _IDTree = IDTree;
            TabItem   ti;
            ArrayList Tabs = new ArrayList();

            dati = cBusinessObjects.GetData(id, typeof(Tabella));
            if (dati.Rows.Count == 0)
            {
                ucTabella t = new ucTabella();
                t.ReadOnly = _ReadOnly;
                t.Load(ID, "", _IDTree, "", IDCliente, IDSessione);
                if (tab == "")
                {
                    tab = "Tabella Principale";
                }
                else if (_NewTabModifiedNames.ContainsKey(IDTree + "_" + ID))
                {
                    tab = String.Format(_NewTabModifiedNames[IDTree + "_" + ID], 1);//in questo caso è sempre la prima
                }
                ti        = new TabItem();
                ti.Header = tab;
                t.ChangeAlias(tab);
                ti.Content = t;
                //tabControl.Items.Add(ti); // E.B. comment
                Tabs.Add(tab); // E.B.
            }
            else
            {
                bool trovata = false;
                foreach (DataRow dtrow in dati.Rows)
                {
                    try
                    {
                        string tabtmp = dtrow["Tab"].ToString();
                        if (tabtmp != "")
                        {
                            trovata = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        string log = ex.Message;
                    }
                }
                if (!trovata)
                {
                    foreach (DataRow dtrow in dati.Rows)
                    {
                        dtrow["Tab"] = "Tabella Principale";
                    }
                    cBusinessObjects.SaveData(id, dati, typeof(Tabella));
                }
            }

            foreach (DataRow dtrow in dati.Rows)
            {
                try
                {
                    string tabtmp = dtrow["Tab"].ToString();
                    if (!Tabs.Contains(tabtmp))
                    {
                        Tabs.Add(tabtmp);
                    }
                }
                catch (Exception ex)
                {
                    string log = ex.Message;
                }
            }


            for (int i = 0; i < Tabs.Count; i++)
            {
                ti        = new TabItem();
                ti.Header = Tabs[i];
                ucTabella t_int = new ucTabella();
                t_int.ReadOnly = _ReadOnly;
                t_int.Load(ID, (string)(Tabs[i]), _IDTree, "", IDCliente, IDSessione);
                t_int.ChangeAlias(Tabs[i].ToString());
                ti.Content = t_int;

                tabControl.Items.Add(ti);
            }
            ti        = new TabItem();
            ti.Header = App.NewTabHeaderText;
            tabControl.Items.Add(ti);
        }
Ejemplo n.º 4
0
        //----------------------------------------------------------------------------+
        //                        tabControl_SelectionChanged                         |
        //----------------------------------------------------------------------------+
        private void tabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            tabControl.Focus();
            if (e.AddedItems.Count > 0 && (e.AddedItems[0]).GetType().Name == "TabItem")
            {
                if (((string)(((TabItem)(e.AddedItems[0])).Header)) == App.NewTabHeaderText)
                {
                    if (_ReadOnly)
                    {
                        try
                        {
                            MessageBox.Show(App.MessaggioSolaScrittura, "Attenzione");
                        }
                        catch (Exception ex)
                        {
                            string log = ex.Message;
                        }
                        tabControl.SelectedIndex = 0;
                        return;
                    }
                    var    dialog     = new wInputBox("Inserire Titolo della nuova Tabella");
                    string newTabName = String.Empty;
                    if (_NewTabModifiedNames.ContainsKey(_IDTree + "_" + _ID))
                    {
                        newTabName = String.Format(_NewTabModifiedNames[_IDTree + "_" + _ID], tabControl.Items.Count);//in questo caso è sempre la prima
                    }
                    dialog.ResponseText = newTabName;
                    dialog.ShowDialog(); // E.B. solleva eccezione
                    if (!dialog.diagres)
                    {
                        return;
                    }
                    string newHeader = dialog.ResponseText;
                    if (newHeader == "")
                    {
                        MessageBox.Show("Attenzione, Titolo non valido");
                        tabControl.SelectedIndex = 0;
                        return;
                    }
                    foreach (TabItem item in tabControl.Items)
                    {
                        if (((string)(item.Header)) == newHeader)
                        {
                            MessageBox.Show("Attenzione, Titolo già esistente");
                            tabControl.SelectedIndex = 0;
                            return;
                        }
                    }
                    TabItem ti = new TabItem();
                    ti.Header = newHeader;
                    ucTabella t = new ucTabella();
                    t.ReadOnly = _ReadOnly;

                    if (((TabItem)(tabControl.Items[tabControl.Items.Count - 2])).Content != null)
                    {
                        ((ucTabella)(((TabItem)(tabControl.Items[tabControl.Items.Count - 2])).Content)).Save();
                        ucTabella tt = ((ucTabella)(((TabItem)(tabControl.Items[tabControl.Items.Count - 2])).Content));
                        t.Load(_ID, newHeader, _IDTree, ((TabItem)(tabControl.Items[tabControl.Items.Count - 2])).Header.ToString(), cBusinessObjects.idcliente.ToString(), cBusinessObjects.idsessione.ToString());
                        t.dati.Clear();
                        for (int i = 0; i <= tt.dati.Rows.Count - 1; i++)
                        {
                            DataRow dtrow = tt.dati.Rows[i];
                            //    if (dtrow["isnew"].ToString() != "1" && dtrow["tab"].ToString() == ((TabItem)(tabControl.Items[tabControl.Items.Count - 2])).Header.ToString())
                            if (dtrow["tab"].ToString() == ((TabItem)(tabControl.Items[tabControl.Items.Count - 2])).Header.ToString())
                            {
                                DataRow dd = t.dati.Rows.Add(id, cBusinessObjects.idcliente, cBusinessObjects.idsessione);
                                dd["Tab"]   = newHeader;
                                dd["name"]  = dtrow["name"];
                                dd["value"] = "";
                                dd["ID"]    = dtrow["ID"];
                                dd["isnew"] = dtrow["isnew"];
                            }
                        }
                        t.DoGenerateTable();
                    }
                    else
                    {
                        t.Load(_ID, newHeader, _IDTree, "", cBusinessObjects.idcliente.ToString(), cBusinessObjects.idsessione.ToString());
                    }
                    ti.Content = t;
                    tabControl.Items.Insert(tabControl.Items.Count - 1, ti);
                    tabControl.SelectedIndex = tabControl.Items.Count - 2;
                }
            }
        }