示例#1
0
        public void printFiadores()
        {
            data.connectToDB();

            List <FiadorModel> fiadores = new List <FiadorModel>();

            String        sql = "SELECT * FROM (proj_pessoa join proj_fiador on proj_pessoa.nif=proj_fiador.nif)";
            SqlCommand    com = new SqlCommand(sql, data.connection());
            SqlDataReader reader;

            reader = com.ExecuteReader();
            while (reader.Read())
            {
                FiadorModel tmp = new FiadorModel();

                tmp.fname    = reader.GetString(0);
                tmp.lname    = reader.GetString(1);
                tmp.telefone = reader.GetDecimal(2);
                tmp.id       = reader.GetDecimal(3);
                tmp.nif      = reader.GetDecimal(4);


                fiadores.Add(tmp);
            }
            data.close();

            fillDataGrid(fiadores);
        }
示例#2
0
        private void savefiador(FiadorModel fiador)
        {
            data.connectToDB();


            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = "exec inserirFiador @fname, @lname, @telefone, @id, @nif";// "INSERT proj_pessoa (fname, lname, telefone, id, nif) values(@fname, @lname, @telefone, @id, @nif)";
            cmd.Parameters.Clear();
            cmd.Parameters.AddWithValue("@lname", fiador.lname);
            cmd.Parameters.AddWithValue("@fname", fiador.fname);
            cmd.Parameters.AddWithValue("@telefone", fiador.telefone);
            cmd.Parameters.AddWithValue("@id", fiador.id);
            cmd.Parameters.AddWithValue("@nif", fiador.nif);
            // cmd.Connection = data.connection();



            //SqlCommand cmd2 = new SqlCommand();
            //cmd2.CommandText = "INSERT proj_fiador (nif) values(@nif)";
            // cmd2.Parameters.Clear();
            //cmd2.Parameters.AddWithValue("@nif", fiador.nif);
            cmd.Connection = data.connection();

            try
            {
                cmd.ExecuteNonQuery();
                MessageBox.Show("Entry Successful!");
            }
            catch (Exception ex)
            {
                //throw new Exception("Failed to insert in database. \n ERROR MESSAGE: \n" + ex.Message);
                MessageBox.Show("Não foi possível guardar os dados! Verifique os campos inseridos!");
            }
            finally
            {
                data.close();
                // DadosPessoais.printFiadores();
            }
        }
示例#3
0
        private void submit_bt_Click(object sender, EventArgs e)
        {
            FiadorModel fiador = new FiadorModel();

            try
            {
                fiador.fname    = fname_textbox.Text.ToString();
                fiador.lname    = lname_textbox.Text.ToString();
                fiador.telefone = Decimal.Parse(tel_textbox.Text.ToString());
                fiador.id       = Decimal.Parse(id_textBox.Text.ToString());
                fiador.nif      = Decimal.Parse(nif_textBox.Text.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            savefiador(fiador);
            addContratoRenda parent = (addContratoRenda)Owner;

            parent.FillFiadorBox();
            this.Close();
        }