Exemplo n.º 1
0
        private async void _saveButton_Clicked(object sender, EventArgs e)
        {
            if (_nomeschedaEn.Text == "" || _recuperoEn.Text == "" || _ripetizioniEn.Text == "")
            {
                await DisplayAlert("Errore ", "Compila tutti i campi", "Ok");
            }

            else if (_ripetizioniEn.Text == null || _nomeschedaEn.Text == null || _recuperoEn.Text == null)
            {
                await DisplayAlert("Errore ", "Compila tutti i campi", "Ok");
            }

            else if (_ripetizioniEn.Text.Contains(".") || _recuperoEn.Text.Contains("."))
            {
                await DisplayAlert("Errore", "Il punto è un carattere vietato", "Ok");
            }

            else
            {
                var scheda = new Scheda {
                    SchedaName = _nomeschedaEn.Text, Recupero = int.Parse(_recuperoEn.Text), Ripetizioni = int.Parse(_ripetizioniEn.Text)
                };
                ItemListView.schede.Add(scheda);
                App.Dbcontroller.SaveScheda(scheda);
                await DisplayAlert(null, "La Scheda: " + _nomeschedaEn.Text + " è Stato Salvata", "Ok");

                await Navigation.PopAsync();
            }
        }
        private void ButtonDeleteBoard(object sender, RoutedEventArgs e)
        {
            Button ClickedButton = (Button)sender;
            Scheda DeletedBoard  = (Scheda)ClickedButton.DataContext;

            Boards.Remove(DeletedBoard);
        }
Exemplo n.º 3
0
        //Inserisci schede nella tabella 'schede' del DB e nel local dictionary

        public bool InserisciScheda(Scheda scheda)
        {
            try
            {
                String query = String.Format("INSERT INTO schede (ID_scheda, x, y) VALUES({0}, {1}, {2})",
                                             scheda.ID_scheda, scheda.Punto.Ascissa, scheda.Punto.Ordinata);

                AggiungiScheda(scheda);

                using (MySqlConnection connessione = new MySqlConnection("Database=" + Database + ";" + "Server=" + Server + ";" + "Port=3306;" + "UID=" + Uid + ";" + "Password="******";"))
                    using (MySqlCommand cmd = connessione.CreateCommand())
                    {
                        connessione.Open();
                        cmd.CommandText = query;
                        cmd.ExecuteNonQuery();
                    }
                Connesso = true;
                return(true);
            }
            catch (MySqlException e)
            {
                System.Diagnostics.Debug.WriteLine("Impossibile inserire le schede nel database" + e.ToString());
                Connesso = false;
                return(false);
            }
        }
Exemplo n.º 4
0
        //Seleziona l'elenco delle schede (tutte) dalla tabella 'schede' del DB

        public List <Scheda> SelezionaSchede()
        {
            //Creo una lista di schede per memorizzare i risultati

            List <Scheda> lista_schede = new List <Scheda>();

            using (MySqlConnection connessione = new MySqlConnection("Database=" + Database + ";" + "Server=" + Server + ";" + "Port=3306;" + "UID=" + Uid + ";" + "Password="******";"))
                using (MySqlCommand cmd = connessione.CreateCommand())
                {
                    try
                    {
                        connessione.Open();
                        cmd.CommandText = "SELECT * FROM schede";
                        using (var leggiDati = cmd.ExecuteReader())
                        {
                            while (leggiDati.Read())
                            {
                                Scheda scheda = new Scheda(leggiDati.GetInt32(0), leggiDati.GetDouble(1), leggiDati.GetDouble(2));
                                lista_schede.Add(scheda);
                            }
                            Connesso = true;
                            return(lista_schede);
                        }
                    }
                    catch (MySqlException e)
                    {
                        System.Diagnostics.Debug.WriteLine("Impossibile recuperare le informazioni sulle schede dal database" + e.ToString());
                        Connesso = false;
                        return(null);
                    }
                }
        }
        private void ButtonAddBoard(object sender, RoutedEventArgs e)
        {
            Scheda newBoard = new Scheda();

            Boards.Add(newBoard);

            return;
        }
Exemplo n.º 6
0
        public ActionResult DeleteConfirmed(int id)
        {
            Scheda scheda = db.Schedas.Find(id);

            db.Schedas.Remove(scheda);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 7
0
        protected override void DisplayContenuto(Scheda scheda, TableLayoutPanel table, Contenuto con, int level)
        {
            String tabs = "";

            for (int i = 0; i < level; i++)
            {
                tabs += "      ";
            }

            String[] currentId = new String[2] {
                scheda.IdScheda, con.Id
            };

            String key = con.Id;
            Label  l   = new Label();

            l.AutoSize = true;
            l.Text     = tabs + key;

            table.Controls.Add(l);

            Label l2 = new Label();

            l2.AutoSize = true;
            l2.Text     = _values[GenerateId(currentId)][0] + "";
            table.Controls.Add(l2);

            TextBox tb = new TextBox();

            tb.Text = _values[GenerateId(currentId)][1] == null ? "" : _values[GenerateId(currentId)][1];

            table.Controls.Add(tb);

            String[] ProprietaTag = new String[] { scheda.IdScheda, con.Id, scheda.GetValore(con.Id), null };
            //ID scheda | ID campo | Valore vecchio | Valore nuovo

            Button conferma = new Button();

            conferma.Text     = "Conferma";
            conferma.AutoSize = true;
            conferma.Tag      = new Object[] { currentId, tb };
            conferma.Click   += ModificaCampoScheda;
            table.Controls.Add(conferma);

            Button cancella = new Button();

            cancella.Text     = "Cancella";
            cancella.AutoSize = true;
            cancella.Tag      = new Object[] { currentId, tb };
            cancella.Click   += RipristinaCampoScheda;
            table.Controls.Add(cancella);

            if (_values[GenerateId(currentId)][1] != null)
            {
                tb.BackColor = Color.Yellow;
            }
        }
Exemplo n.º 8
0
        protected virtual void SchedaCancellata(String Id)
        {
            Scheda condannata = (from Scheda s in _schede.Keys where s.IdScheda == Id select s).First <Scheda>();

            RemoveScheda(condannata);
            if (_schedeView.SelectedNode != null && _schedeView.SelectedNode.Tag is Scheda && (_schedeView.SelectedNode.Tag as Scheda) == condannata)
            {
                _schedaPanel.Controls.Clear();
            }
            RefreshSchedeView(_schedeView);
            _output(this, new Utility.Messages.ChatComuneMessageEventArgs("Il personaggio " + Id + " appartenente a " + Documento.GetIstance().NomeUtente + " è morto."));
        }
Exemplo n.º 9
0
 protected override void AddSchedePendenti(TreeView tree)
 {
     foreach (String s in _schedePendenti)
     {
         Scheda   pendente = null;
         TreeNode tn       = new TreeNode();
         tn.BackColor = Color.Red;
         tn.Text      = s;
         tn.Tag       = pendente;
         tree.Nodes.Add(tn);
     }
 }
Exemplo n.º 10
0
 public ActionResult Edit([Bind(Include = "Scheda_Id,Numero,NumeroG,DataI,DataF,Uid")] Scheda scheda)
 {
     if (ModelState.IsValid)
     {
         db.Entry(scheda).State = EntityState.Modified;
         db.SaveChanges();
         db.DettaglioSchedas.RemoveRange(db.DettaglioSchedas.Where(d => d.Scheda_Id == scheda.Scheda_Id && d.Data > scheda.DataF));
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(scheda));
 }
Exemplo n.º 11
0
        // GET: Schedas/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Scheda scheda = db.Schedas.Find(id);

            if (scheda == null)
            {
                return(HttpNotFound());
            }
            return(View(scheda));
        }
Exemplo n.º 12
0
        public ActionResult TestChart(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Scheda scheda = db.Schedas.Find(id);

            if (scheda == null)
            {
                return(HttpNotFound());
            }
            var dati = db.DettaglioSchedas.Where(s => s.Scheda_Id == id).Select(s => new { g = s.Giorno, t = s.Temperatura, m = s.Muco, e = s.Ematic, d = s.Data }).ToList();

            ViewBag.DataPoints = JsonConvert.SerializeObject(dati, _jsonSetting);
            return(View(scheda));
        }
Exemplo n.º 13
0
        protected override void RefreshSchedeView(TreeView tree)
        {
            Scheda scheda = _schedaCorrente;

            tree.Nodes.Clear();
            foreach (Scheda s in _schede.Keys)
            {
                TreeNode node = new TreeNode();
                node.Tag  = s;
                node.Text = s.IdScheda;
                tree.Nodes.Add(node);
            }
            AddSchedePendenti(tree);
            ColoraSchedeView(tree.Nodes);

            tree.ExpandAll();
            _schedaCorrente = scheda;
        }
Exemplo n.º 14
0
 protected virtual void CancellaScheda(object sender, EventArgs e)
 {
     if (_schedeView.SelectedNode != null && _schedeView.SelectedNode.Tag is Scheda)
     {
         if (MessageBox.Show("Sei sicuro di voler eliminare questa scheda?", "Eliminazione scheda", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             Scheda condannata = (_schedeView.SelectedNode.Tag as Scheda);
             String ip         = (_schedeView.SelectedNode.Parent.Tag as String);
             _output(this, new GestoreGiocatoriMessageEventArgs(ip, new SchedaCancellataMessageEventArgs(condannata.IdScheda)));
             RemoveScheda(condannata);
             InitValues();
             if (ip != null)
             {
                 _gestoreGiocatori.RemoveSchede(ip, condannata);
             }
             _schedaPanel.Controls.Clear();
             RefreshSchedeView(_schedeView);
             SalvaSchede();
         }
     }
 }
Exemplo n.º 15
0
        public ActionResult Create([Bind(Include = "Scheda_Id,Numero,NumeroG,DataI,DataF,Uid")] Scheda scheda, [Bind(Include = "DettaglioScheda_Id,Data,Giorno,Temperatura,Scheda_Id")] DettaglioScheda dettaglioScheda)
        {
            var ut = User.Identity.GetUserId();

            scheda.Uid = ut;
            var num = db.Schedas.Where(u => u.Uid == ut).Max(n => n.Numero);

            if (num != null)
            {
                scheda.Numero = num + 1;
            }
            else
            {
                scheda.Numero = 1;
            }
            double giorniadd = (double)scheda.NumeroG;

            scheda.DataF = scheda.DataI.AddDays(giorniadd);
            var inizio = scheda.DataI;
            var giorni = scheda.NumeroG;

            if (ModelState.IsValid)
            {
                db.Schedas.Add(scheda);
                db.SaveChanges();
                //Creo una riga di dettaglio scheda in base al numero di giorni previsto
                for (int i = 0; i < giorni; i++)
                {
                    dettaglioScheda.Data      = inizio.AddDays(i);
                    dettaglioScheda.Giorno    = i + 1;
                    dettaglioScheda.Scheda_Id = scheda.Scheda_Id;
                    db.DettaglioSchedas.Add(dettaglioScheda);
                    db.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }

            return(View(scheda));
        }
Exemplo n.º 16
0
 protected override void AddSchedePendenti(TreeView tree)
 {
     foreach (String nome in _schedePendenti.Keys)
     {
         TreeNode parentnode = null;
         foreach (TreeNode t in tree.Nodes)
         {
             if (t.Tag == _schedePendenti[nome])
             {
                 parentnode = t;
             }
         }
         if (parentnode != null)
         {
             Scheda   s    = null;
             TreeNode node = new TreeNode();
             node.Tag       = s;
             node.Text      = nome;
             node.BackColor = Color.Red;
             parentnode.Nodes.Add(node);
         }
     }
 }
Exemplo n.º 17
0
        private void ConfermaNuovaScheda(object sender, EventArgs e)
        {
            if (sender is Button)
            {
                Button button = sender as Button;
                String ip     = (button.Tag as String);
                String name   = _schedeView.SelectedNode.Text;

                ElementoTemplate template = _schede.Values.Count > 0 ? _schede.Values.First <ElementoTemplate>() :
                                            Documento.GetIstance().Persister.LoadTemplate(Documento.GetIstance().Path + Documento.GetIstance().CurrentDescrittore.IdPartita + "/Template.xml");

                Scheda nuovaScheda = GeneraScheda(template, name);
                _schede.Add(nuovaScheda, template);
                _gestoreGiocatori.AddSchede(ip, nuovaScheda);
                _schedePendenti.Remove(name);
                _schedaPanel.Controls.Clear();
                InitValues();
                RefreshSchedeView(_schedeView);

                _output(this, new Utility.Messages.GestoreGiocatoriMessageEventArgs(ip, new NuovaSchedaConfermataMessageEventArgs(name)));

                SalvaSchede();
            }
        }
Exemplo n.º 18
0
        protected override void DisplayContenuto(Scheda scheda, TableLayoutPanel table, Contenuto con, int level)
        {
            String tabs = "";

            for (int i = 0; i < level; i++)
            {
                tabs += "      ";
            }

            String[] currentId = new String[] { scheda.IdScheda, con.Id };

            String key = con.Id;
            Label  l   = new Label();

            l.AutoSize = true;
            l.Text     = tabs + key;
            table.Controls.Add(l);

            Label l2 = new Label();

            l2.AutoSize = true;
            l2.Text     = _values[GenerateId(currentId)][0] + "";
            table.Controls.Add(l2);

            TextBox tb = new TextBox();

            tb.Text = _values[GenerateId(currentId)][1] == null ? "" : _values[GenerateId(currentId)][1];
            table.Controls.Add(tb);

            String[] ProprietaTag = new String[] { scheda.IdScheda, con.Id, scheda.GetValore(con.Id), null };
            //ID scheda | ID campo | Valore vecchio | Valore nuovo


            Button conferma = new Button();

            conferma.Tag      = new Object[] { currentId, tb };
            conferma.AutoSize = true;
            if (con.ConfermaMaster)
            {
                conferma.Text   = "Richiedi modifica";
                conferma.Click += RichiediModificaCampoScheda;
            }
            else
            {
                conferma.Text   = "Modifica";
                conferma.Click += ModificaCampoScheda;
            }

            table.Controls.Add(conferma);

            Button prova = new Button();

            prova.AutoSize = true;
            prova.Text     = "Prova";
            prova.Tag      = new Object[] { currentId, con.FormulaProva };
            prova.Click   += EseguiProva;
            table.Controls.Add(prova);
            if (!con.Modificabile)
            {
                tb.Enabled       = false;
                conferma.Enabled = false;
            }
            if (String.IsNullOrEmpty(con.FormulaProva.Trim()))
            {
                prova.Enabled = false;
            }
        }
Exemplo n.º 19
0
 public void AggiungiScheda(Scheda scheda)
 {
     schede.TryAdd(scheda.ID_scheda, scheda);
 }