Example #1
0
        private static void salvaRata(RataMovimento r, string tipo, int idUtente, int idDest, string causale, string note, List<int> categorie, OleDbConnection conn, ref OleDbCommand cmd)
        {
            cmd.Parameters.Add("Tipo", OleDbType.Char, 255).Value = tipo;
            cmd.Parameters.Add("DataScadenza", OleDbType.Date).Value = r.Scadenza;
            cmd.Parameters.Add("ImportoIvato", OleDbType.Double).Value = r.Importo;
            cmd.Parameters.Add("Ultimato", OleDbType.Boolean).Value = false;
            cmd.Parameters.Add("Causale", OleDbType.Char, 255).Value = causale;
            cmd.Parameters.Add("Note", OleDbType.Char, 255).Value = note;
            cmd.Parameters.Add("Utente", OleDbType.Integer).Value = idUtente;
            cmd.Parameters.Add("DestinatarioMov", OleDbType.Integer).Value = idDest;

            cmd.ExecuteNonQuery();

            OleDbCommand cmdId = new OleDbCommand("SELECT @@IDENTITY", conn);
            int newIdMov = (int)cmdId.ExecuteScalar();

            if (categorie != null)
            {
                string queryStringCat = "INSERT INTO CategoriaMovimento (Movimento, Categoria) VALUES (?, ?)";
                foreach (int i in categorie)
                {
                    OleDbCommand cmdCat = new OleDbCommand(queryStringCat, conn);
                    cmdCat.Parameters.Add("Movimento", OleDbType.Integer).Value = newIdMov;
                    cmdCat.Parameters.Add("Categoria", OleDbType.Integer).Value = i;
                    cmdCat.ExecuteNonQuery();
                }
            }
        }
Example #2
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            //validazione rate
            if (!isDataGridComplete())
            {
                MessageBox.Show("I dati sulle rate sono incompleti", "Dati incompleti", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (!areImportPositive())
            {
                MessageBox.Show("Gli importi delle rate devono essere positivi", "Importi errati", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (!areRateDateConsecutive())
            {
                MessageBox.Show("Le date di scadenza delle rate non sono consecutive", "Date errate", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            //creazione lista risultato
            RataMovimento r;
            rate.Clear();
            foreach (DataRow dr in rateDt.Rows)
            {
                r = new RataMovimento();
                r.Progr = int.Parse(dr["N° rata"].ToString());
                r.Scadenza = DateTime.Parse(dr["Scadenza"].ToString());
                r.Importo = decimal.Parse(dr["Importo"].ToString());

                rate.Add(r);
            }

            this.DialogResult = DialogResult.OK;
        }