Example #1
0
        private void btnSalva_Click(object sender, EventArgs e)
        {
            var result = MessageBox.Show("Vuoi acquistare questa abilità?", "Sei sicuro?", MessageBoxButtons.YesNo);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                string cdAttitudine = cmbAttitudine.SelectedValue.ToString();
                long   cdAbilita    = (long)grdAbilita.SelectedRows[0].Cells["CdAbilita"].Value;
                long?  numAcquisti  = null;
                if (numVolte.Enabled)
                {
                    numAcquisti = (long)numVolte.Value;
                }
                using (context = CreateDatabaseContext())
                {
                    PersonaggiManagerNew characterManager = new PersonaggiManagerNew(context);
                    bool res = characterManager.AddSkillToCharacter(numeroPg, cdAbilita, numAcquisti, cdAttitudine, txtSpecifiche.Text.Trim());
                    if (res)
                    {
                        context.SaveChanges();
                        MessageBox.Show("Abilità acquistata");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Errore durante il salvataggio");
                    }
                }
            }
        }