示例#1
0
 protected void btnInserisciGruppo_Click(object sender, EventArgs e)
 {
     try
     {
         string nomeGruppo = txtNomeGruppo.Text;
         if (GruppiFruttiDAO.GetByNome(nomeGruppo) == null)
         {
             GruppiFruttiDAO.InserisciGruppo(nomeGruppo, txtDescrizioneGruppo.Text);
             (Master as layout).SetAlert("alert-success", $"Gruppo {txtNomeGruppo.Text} inserito con successo");
             BindGrid();
         }
         else
         {
             (Master as layout).SetAlert("alert-warning", $"Gruppo NON inserito, perchè il nome '{txtNomeGruppo.Text}' è già presente");
         }
     }
     catch (Exception ex)
     {
         (Master as layout).SetAlert("alert-danger", $"Errore durante il btnInserisciGruppo_Click in GestisciGruppi - {ex.Message}");
     }
 }
示例#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();
        }