Example #1
0
 protected void grdGruppi_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     try
     {
         int          idGruppo = Convert.ToInt32(e.CommandArgument);
         GruppiFrutti gruppo   = GruppiFruttiDAO.GetSingle(idGruppo);
         if (e.CommandName == "Visualizza")
         {
             txtNomeGruppo.Enabled      = txtDescrizioneGruppo.Enabled = false;
             txtNomeGruppo.Text         = gruppo.NomeGruppo;
             txtDescrizioneGruppo.Text  = gruppo.Descrizione;
             btnInserisciGruppo.Visible = btnModificaGruppo.Visible = false;
         }
         if (e.CommandName == "Modifica")
         {
             txtNomeGruppo.Enabled      = txtDescrizioneGruppo.Enabled = true;
             txtNomeGruppo.Text         = gruppo.NomeGruppo;
             txtDescrizioneGruppo.Text  = gruppo.Descrizione;
             hfIdGruppo.Value           = idGruppo.ToString();
             btnInserisciGruppo.Visible = false;
             btnModificaGruppo.Visible  = !btnInserisciGruppo.Visible;
         }
         if (e.CommandName == "Elimina")
         {
             if (CompGruppoFrutDAO.GetCompGruppo(idGruppo).Count <= 0)
             {
                 GruppiFruttiDAO.DeleteGruppo(idGruppo);
                 (Master as layout).SetAlert("alert-success", $"Gruppo {gruppo.NomeGruppo} eliminato con successo");
                 BindGrid();
             }
             else
             {
                 (Master as layout).SetAlert("alert-danger", $"Impossibile eliminare il gruppo, perchè contiene dei componenti");
             }
         }
     }
     catch (Exception ex)
     {
         (Master as layout).SetAlert("alert-danger", $"Errore durante il grdGruppi_RowCommand in GestisciGruppi - {ex.Message}");
     }
 }
Example #2
0
        protected void btnClonaGruppo_Click(object sender, EventArgs e)
        {
            DBTransaction tr = new DBTransaction();

            tr.Begin();
            try
            {
                int                   idGruppo      = Convert.ToInt32(ddlScegliGruppo.SelectedItem.Value);
                GruppiFrutti          gf            = GruppiFruttiDAO.GetSingle(idGruppo, tr);
                int                   idGruppoCopia = GruppiFruttiDAO.InserisciGruppo("Copia" + gf.NomeGruppo, gf.Descrizione, tr);
                List <CompGruppoFrut> components    = CompGruppoFrutDAO.GetCompGruppo(idGruppo, tr);
                components.ForEach(f => f.IdTblGruppo = idGruppoCopia);
                CompGruppoFrutDAO.InsertList(components, tr);
                tr.Commit();
            }
            catch (Exception ex)
            {
                tr.Rollback();
                (Master as layout).SetAlert("alert-danger", $"Errore durante la clonazione del gruppo selezionato - {ex.Message}");
            }

            (Master as layout).SetAlert("alert-success", "Gruppo clonato con successo");
            BindGrid();
        }
Example #3
0
 protected void MostraComponentiGruppo(int idGruppo)
 {
     lblPanelTitleGroupName.Text = GruppiFruttiDAO.GetSingle(idGruppo).NomeGruppo;
     componentiGruppo            = CompGruppoFrutDAO.GetCompGruppo(idGruppo);
 }