コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            DBInit.init();
            using (SqlCommand cmd = new SqlCommand("FazerEmprestimo", DBInit.getmyConn()))
            {
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@quantia", SqlDbType.Decimal).Value  = textBox1.Text;
                cmd.Parameters.Add("@juro", SqlDbType.Decimal).Value     = textBox2.Text;
                cmd.Parameters.Add("@prazo", SqlDbType.Date).Value       = dateTimePicker1.Value.ToString("yyyy-MM-dd");
                cmd.Parameters.Add("@nCC", SqlDbType.Int).Value          = textBox3.Text;
                cmd.Parameters.Add("@nConta", SqlDbType.BigInt).Value    = textBox4.Text;
                cmd.Parameters.Add("@nFuncionario", SqlDbType.Int).Value = textBox5.Text;

                try
                {
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Empréstimo executado com sucesso", "Sucesso!");
                }
                catch (Exception f)
                {
                    MessageBox.Show(f.ToString());
                }
            }

            DBInit.close();
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            DBInit.init();
            using (SqlCommand cmd = new SqlCommand("InserirCliente", DBInit.getmyConn()))
            {
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@nCC", SqlDbType.Int).Value            = textBox1.Text;
                cmd.Parameters.Add("@nome", SqlDbType.VarChar, 40).Value   = textBox2.Text;
                cmd.Parameters.Add("@dataNasc", SqlDbType.Date).Value      = dateTimePicker1.Value.ToString("yyyy-MM-dd");
                cmd.Parameters.Add("@morada", SqlDbType.VarChar, 50).Value = textBox3.Text;
                cmd.Parameters.Add("@nCont", SqlDbType.Int).Value          = textBox4.Text;
                cmd.Parameters.Add("@nTelefone", SqlDbType.Int).Value      = textBox5.Text;

                try {
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Cliente adicionado com sucesso", "Sucesso!");
                }
                catch (Exception f) {
                    MessageBox.Show(f.ToString());
                }
            }

            DBInit.close();
        }
コード例 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            DBInit.init();
            using (SqlCommand cmd = new SqlCommand("FazerDepositoBalcao", DBInit.getmyConn()))
            {
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@quantia", SqlDbType.Decimal).Value = textBox1.Text;
                cmd.Parameters.Add("@nCliente", SqlDbType.Int).Value    = textBox2.Text;
                cmd.Parameters.Add("@nBalcao", SqlDbType.Int).Value     = textBox3.Text;
                cmd.Parameters.Add("@nConta", SqlDbType.BigInt).Value   = textBox4.Text;

                try
                {
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Depósito realizado com sucesso", "Sucesso!");
                }
                catch (Exception f)
                {
                    MessageBox.Show(f.ToString());
                }
            }

            DBInit.close();
        }
コード例 #4
0
        private void MostrarFuncionarios_Load(object sender, EventArgs e)
        {
            ////////// todos
            DataSet ptDataset = new DataSet();

            DBInit.init();
            SqlCommand cmd = new SqlCommand("MostrarTodosFuncionarios", DBInit.getmyConn());

            cmd.CommandType = CommandType.StoredProcedure;

            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(ptDataset);
            dataGridView1.DataSource = ptDataset.Tables[0];
            DBInit.close();

            /////// bancarios:
            DataSet ptDataset2 = new DataSet();

            DBInit.init();
            SqlCommand cmd2 = new SqlCommand("MostrarTodosFuncionariosGestores", DBInit.getmyConn());

            cmd2.CommandType = CommandType.StoredProcedure;

            SqlDataAdapter da2 = new SqlDataAdapter(cmd2);

            da2.Fill(ptDataset2);
            dataGridView2.DataSource = ptDataset2.Tables[0];
            DBInit.close();
        }
コード例 #5
0
        private void HistoricoCliente_Load(object sender, EventArgs e)
        {
            ////////// CONTAS
            DataSet ptDataset = new DataSet();

            DBInit.init();
            SqlCommand cmd = new SqlCommand("PesquisaContas", DBInit.getmyConn());

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@nCC", nCC);

            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(ptDataset);
            dataGridView1.DataSource = ptDataset.Tables[0];
            DBInit.close();

            /////// CARTOES:
            DataSet ptDataset2 = new DataSet();

            DBInit.init();
            SqlCommand cmd2 = new SqlCommand("PesquisaCartoes", DBInit.getmyConn());

            cmd2.CommandType = CommandType.StoredProcedure;
            cmd2.Parameters.AddWithValue("@nCC", nCC);

            SqlDataAdapter da2 = new SqlDataAdapter(cmd2);

            da2.Fill(ptDataset2);
            dataGridView2.DataSource = ptDataset2.Tables[0];
            DBInit.close();

            /////// HISTORICO:
            DataSet ptDataset3 = new DataSet();

            DBInit.init();
            SqlCommand cmd3 = new SqlCommand("PesquisaOperacoes", DBInit.getmyConn());

            cmd3.CommandType = CommandType.StoredProcedure;
            cmd3.Parameters.AddWithValue("@nCC", nCC);

            SqlDataAdapter da3 = new SqlDataAdapter(cmd3);

            da3.Fill(ptDataset3);
            dataGridView3.DataSource = ptDataset3.Tables[0];
            DBInit.close();
        }
コード例 #6
0
        private void EditarCliente_Load(object sender, EventArgs e)
        {
            DBInit.init();
            using (SqlCommand cmd = new SqlCommand("PesquisaClientes", DBInit.getmyConn()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@nCC", this.nCC);

                cmd.Parameters.Add("@nome", SqlDbType.VarChar, 40);
                cmd.Parameters["@nome"].Direction = ParameterDirection.Output;
                cmd.Parameters.Add("@dataNasc", SqlDbType.Date);
                cmd.Parameters["@dataNasc"].Direction = ParameterDirection.Output;
                cmd.Parameters.Add("@morada", SqlDbType.VarChar, 50);
                cmd.Parameters["@morada"].Direction = ParameterDirection.Output;
                cmd.Parameters.Add("@nCont", SqlDbType.Int);
                cmd.Parameters["@nCont"].Direction = ParameterDirection.Output;
                cmd.Parameters.Add("@nTelefone", SqlDbType.Int);
                cmd.Parameters["@nTelefone"].Direction = ParameterDirection.Output;
                cmd.Parameters.Add("@nCliente", SqlDbType.Int);
                cmd.Parameters["@nCliente"].Direction = ParameterDirection.Output;
                cmd.Parameters.Add("@dataAdesao", SqlDbType.Date);
                cmd.Parameters["@dataAdesao"].Direction = ParameterDirection.Output;

                DBInit.init();
                cmd.ExecuteNonQuery();
                DBInit.close();

                textBox1.Text = cmd.Parameters["@nCC"].Value.ToString();
                textBox2.Text = cmd.Parameters["@nome"].Value.ToString();

                int dia = Convert.ToInt16(cmd.Parameters["@dataNasc"].Value.ToString().Substring(0, 2));
                int mes = Convert.ToInt16(cmd.Parameters["@dataNasc"].Value.ToString().Substring(3, 2));
                int ano = Convert.ToInt16(cmd.Parameters["@dataNasc"].Value.ToString().Substring(6, 4));

                dateTimePicker1.Value = new DateTime(ano, mes, dia);

                textBox3.Text = cmd.Parameters["@morada"].Value.ToString();
                textBox4.Text = cmd.Parameters["@nCont"].Value.ToString();
                textBox5.Text = cmd.Parameters["@nTelefone"].Value.ToString();
                //MessageBox.Show("" + dia+" "+mes+" "+ano);
            }

            DBInit.close();
        }
コード例 #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            DBInit.init();
            using (SqlCommand cmd = new SqlCommand("CriarConta", DBInit.getmyConn()))
            {
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@nCC", SqlDbType.Int).Value = textBox1.Text;
                if (comboBox1.Text == "Prazo")
                {
                    cmd.Parameters.Add("@juros", SqlDbType.Decimal).Value = textBox2.Text;
                }
                else if (comboBox1.Text == "Ordem")
                {
                    cmd.Parameters.Add("@juros", SqlDbType.Decimal).Value = 0.0;
                }

                if (checkBox1.Checked)
                {
                    cmd.Parameters.Add("@admin", SqlDbType.Bit).Value = 1;
                }
                else
                {
                    cmd.Parameters.Add("@admin", SqlDbType.Bit).Value = 0;
                }


                cmd.Parameters.Add("@saldo", SqlDbType.Decimal).Value = textBox3.Text;


                try
                {
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Conta criada com sucesso", "Sucesso!");
                }
                catch (Exception f)
                {
                    MessageBox.Show(f.ToString());
                }
            }

            DBInit.close();
        }
コード例 #8
0
        private void button2_Click(object sender, EventArgs e)
        {
            DBInit.init();
            using (SqlCommand cmd = new SqlCommand("FazerTransferencia", DBInit.getmyConn()))
            {
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@quantia", SqlDbType.Decimal).Value      = textBox8.Text;
                cmd.Parameters.Add("@nCartao", SqlDbType.BigInt).Value       = textBox7.Text;
                cmd.Parameters.Add("@nContaDestino", SqlDbType.BigInt).Value = textBox6.Text;
                cmd.Parameters.Add("@nContaDono", SqlDbType.BigInt).Value    = textBox5.Text;


                cmd.ExecuteNonQuery();
                MessageBox.Show("Transferência realizada com sucesso", "Sucesso!");
            }

            DBInit.close();
        }
コード例 #9
0
        private void MostrarClientes_Load(object sender, EventArgs e)
        {
            DataSet ptDataset = new DataSet();

            DBInit.init();

            string sql = "MostrarTodosClientes";
            //SqlCommand com = new SqlCommand(sql, sc);

            SqlCommand cmd = new SqlCommand(sql, DBInit.getmyConn());


            cmd.CommandType = CommandType.StoredProcedure;

            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(ptDataset);
            dataGridView1.DataSource = ptDataset.Tables[0];
            DBInit.close();
        }