segunda-feira, 9 de dezembro de 2024

UFCD 5409 - Engenharia de Requisitos




#include <stdio.h>



int main(int argc, char *argv[])

{

int valor1, valor2, opcao, resultado;

puts("Introduza o primeiro valor");

scanf("%d", &valor1);

puts("Introduza o segundo valor");

scanf("%d", &valor2);

puts("1-Soma");

puts("2-Subtracao");

puts("3-Multiplicacao");

puts("4-Divisao");

printf("Opcao:");

scanf("%d",&opcao);

switch(opcao){

case 1: resultado=valor1+valor2; break;

case 2: resultado=valor1-valor2; break;

case 3: resultado=valor1*valor2; break;

case 4: resultado=valor1/valor2; break;

default: puts("A opcao esta incorrecta");

}

printf("O resultado e: %d\n", resultado);

return 0;

}





domingo, 8 de dezembro de 2024

UFCD 3935 - CONEXAO C# COM SQL SERVER


 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Data.SqlClient;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;




namespace WindowsFormsApp3

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }


        private void Form1_Load(object sender, EventArgs e)

        {


        }


        private void btnTestar_Click(object sender, EventArgs e)

        {

            try

            {

                string connetionString;

                SqlConnection cnn;

                connetionString = @"Data Source=DESKTOP-BQD85M5\SQLEXPRESS;Initial Catalog=aulas;User ID=;Password=";

                cnn = new SqlConnection(connetionString);

                cnn.Open();

                MessageBox.Show("Conexão ok!");

                cnn.Close();

            }

            catch (SqlException erro)

            {

                MessageBox.Show(erro.Message);


            }

        }

    }

}





UFCD 3935 - C# Tutorial - Connect SQL server database with Visual Studio C# with source code(Tutorial C# - Conecte o banco de dados do servidor SQL com o Visual Studio C# com código-fonte)

 



Connect SQL server database with Visual Studio C# [ with source code ]

 



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'names1DataSet.Table1' table. You can move, or remove it, as needed.
            this.table1TableAdapter.Fill(this.names1DataSet.Table1);

            


        }

        private void button1_Click(object sender, EventArgs e)
        {
            table1BindingSource.AddNew();

        }

        private void button2_Click(object sender, EventArgs e)
        {
            table1BindingSource.EndEdit();
            table1TableAdapter.Update(names1DataSet.Table1);

        }

        private void button3_Click(object sender, EventArgs e)
        {
            table1BindingSource.RemoveCurrent();
    table1TableAdapter.Update(names1DataSet.Table1);

        }

        private void button4_Click(object sender, EventArgs e)
        {
            this.Close();

        }

        private void button5_Click(object sender, EventArgs e)
        {
            table1BindingSource.MoveFirst();

        }

        private void button6_Click(object sender, EventArgs e)
        {
            table1BindingSource.MoveLast();

        }

        private void button7_Click(object sender, EventArgs e)
        {
            table1BindingSource.MovePrevious();

        }

        private void button8_Click(object sender, EventArgs e)
        {
            table1BindingSource.MoveNext();

        }
    }
}