private void SelectCategoryForm_Load(object sender, EventArgs e)
 {
     scadenzettiDbDataSetTableAdapters.CategoriaTableAdapter cta = new Scadenzetti.scadenzettiDbDataSetTableAdapters.CategoriaTableAdapter();
     cdt = cta.GetDataOrderByNome();
     if (cdt.Count == 0)
     {
         MessageBox.Show("Non è stata ancora definita alcuna categoria.", "Nessuna categoria presente", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         this.Close();
         return;
     }
     else
     {
         for (int i = 0; i < cdt.Count; i++)
         {
             CategoryCheckbox cbx = new CategoryCheckbox();
             cbx.Text = cdt[i]["Nome"].ToString();
             cbx.IdCategoria = int.Parse(cdt[i]["ID"].ToString());
             if (selectedCategory.Contains(cbx.IdCategoria))
                 cbx.Checked = true;
             else
                 cbx.Checked = false;
             cbx.Size = new Size(250, 20);
             flowLayoutPanel.Controls.Add(cbx);
         }
     }
 }
        private void AddFatturaMultiMovForm_Load(object sender, EventArgs e)
        {
            //popola dropdown utenti
            uta = new Scadenzetti.scadenzettiDbDataSetTableAdapters.UtenteTableAdapter();
            udt = uta.GetDataOrderByNome();
            for (int i = 0; i < udt.Count; i++)
            {
                dropUtente.Items.Add(new UtenteDropDownItem(int.Parse(udt[i]["ID"].ToString()),
                    udt[i]["Nome"].ToString()));
            }

            //popola dropdown destinatari
            dta = new Scadenzetti.scadenzettiDbDataSetTableAdapters.DestinatarioMovTableAdapter();
            ddt = dta.GetDataOrderByNome();
            for (int i = 0; i < ddt.Count; i++)
            {
                dropDest.Items.Add(new DestinatarioDropDownItem(int.Parse(ddt[i]["ID"].ToString()),
                    ddt[i]["Nome"].ToString()));
            }

            //aggiungi due blocchi categoria
            catControls = new List<MovimentoFatturaControl>();
            scadenzettiDbDataSetTableAdapters.CategoriaTableAdapter cta = new Scadenzetti.scadenzettiDbDataSetTableAdapters.CategoriaTableAdapter();
            cdt = cta.GetDataOrderByNome();
            catlist = new List<Categoria>();
            Categoria cat;
            foreach(scadenzettiDbDataSet.CategoriaRow cr in cdt){
                cat = new Categoria();
                cat.Id = cr.ID;
                cat.Nome = cr.Nome;
                catlist.Add(cat);
            }
            MovimentoFatturaControl mfc = new MovimentoFatturaControl(catlist);
            catControls.Add(mfc);
            flowLayoutPanelMovs.Controls.Add(mfc);
            mfc.TotalChanged += totaleFattura_Changed;

            mfc = new MovimentoFatturaControl(catlist);
            catControls.Add(mfc);
            flowLayoutPanelMovs.Controls.Add(mfc);
            mfc.TotalChanged += totaleFattura_Changed;

            lblNumMovFattura.Text = "2";
        }
        public ReportSearchCriteriaForm()
        {
            InitializeComponent();

            dag = new DataAccessGateway();

            initializeMonthDictionaries();

            scadenzettiDbDataSetTableAdapters.UtenteTableAdapter uta = new Scadenzetti.scadenzettiDbDataSetTableAdapters.UtenteTableAdapter();
            udt = uta.GetDataOrderByNome();

            scadenzettiDbDataSetTableAdapters.CategoriaTableAdapter cta = new Scadenzetti.scadenzettiDbDataSetTableAdapters.CategoriaTableAdapter();
            cdt = cta.GetDataOrderByNome();

            //inizializzazione controlli
            initializeMonthExpenseTab();
            initializeYearMatrixTab();
            initializeCategTab();
            initializePersTab();
        }
        private void loadCategorie(int index)
        {
            scadenzettiDbDataSetTableAdapters.CategoriaTableAdapter cta = new Scadenzetti.scadenzettiDbDataSetTableAdapters.CategoriaTableAdapter();
            cdt = cta.GetDataOrderByNome();

            if (cdt.Count == 0)
            {
                MessageBox.Show("Non ci sono categorie archivio", "Nessuna categoria", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                this.DialogResult = DialogResult.Cancel;
                return;
            }

            showCategoria(index);
        }
        private void loadCategorieMovimento()
        {
            //carico le categorie precedentemente assegnate nella lista
            categories = new List<int>();
            scadenzettiDbDataSetTableAdapters.CategoriaMovimentoTableAdapter cmta = new Scadenzetti.scadenzettiDbDataSetTableAdapters.CategoriaMovimentoTableAdapter();
            cmdt = cmta.GetDataByMovimento(idMov);
            for (int i = 0; i < cmdt.Count; i++)
            {
                categories.Add(int.Parse(cmdt[i]["Categoria"].ToString()));
            }

            //elenco tutte le categorie
            scadenzettiDbDataSetTableAdapters.CategoriaTableAdapter cta = new Scadenzetti.scadenzettiDbDataSetTableAdapters.CategoriaTableAdapter();
            cdt = cta.GetDataOrderByNome();
            for (int j = 0; j < cdt.Count; j++)
            {
                CategoryCheckbox catcbx = new CategoryCheckbox();
                catcbx.AutoSize = true;
                catcbx.IdCategoria = int.Parse(cdt[j]["ID"].ToString());
                catcbx.Text = cdt[j]["Nome"].ToString();
                if (categories.Contains(catcbx.IdCategoria))
                    catcbx.Checked = true;
                else catcbx.Checked = false;
                flowLayoutPanel.Controls.Add(catcbx);
            }
        }