コード例 #1
0
        public static void AdicionarExameParaDataBase(DataHelper datahelper, ClasseExames exames)
        {
            DataRow datarow = datahelper.TableExames.NewRow();

            datarow[DataHelper.EXAME_NOME]        = exames.Nome;
            datarow[DataHelper.EXAME_EXAME_MEDIA] = exames.MediaExame;
            datarow[DataHelper.EXAME_CLIENTE_ID]  = exames.ClienteId;
            datahelper.TableExames.Rows.Add(datarow);
            datahelper.Guardar();
        }
コード例 #2
0
        // Botao para gravar os dados acerca do exame
        private void buttonGravar_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Tem a certeza que pretende adicionar um novo Cliente?", "Alerta:", MessageBoxButtons.OKCancel);

            if (result == DialogResult.OK)
            {
                ClasseExames exameParaAdicionar = new ClasseExames(textBoxTipoExame.Text, ClienteParaEditar.Id, textBoxMedia.Text);
                ClasseExames.AdicionarExameParaDataBase(datahelper, exameParaAdicionar);

                this.Close();
            }
        }
コード例 #3
0
        public static List <ClasseExames> getExames(DataHelper datahelper, long id)
        {
            List <ClasseExames> exames   = new List <ClasseExames>();
            DataView            dataView = datahelper.DataSet.Tables[DataHelper.DATATABLE_EXAMES].DefaultView;

            dataView.RowFilter = string.Format("{0} = '{1}'", DataHelper.EXAME_CLIENTE_ID, id);
            foreach (DataRowView drv in dataView)
            {
                DataRow      row        = drv.Row;
                string       nome       = (string)row[DataHelper.EXAME_NOME];
                long         clienteId  = long.Parse((string)row[DataHelper.EXAME_CLIENTE_ID]);
                string       exameMedia = (string)row[DataHelper.EXAME_EXAME_MEDIA];
                ClasseExames exame      = new ClasseExames(nome, clienteId, exameMedia);
                exames.Add(exame);
            }
            return(exames);
        }
コード例 #4
0
        // Com este botao é possivel remover um exame selecionado na dataGridViewExames
        private void buttonApagarExame_Click(object sender, EventArgs e)
        {
            int indexParaRemover = dataGridViewExames.CurrentCell.RowIndex;

            if (indexParaRemover >= 0)
            {
                DialogResult result = MessageBox.Show("Tem a certeza que pretende remover o Exame seleccionado?", "Alerta:", MessageBoxButtons.OKCancel);
                if (result == DialogResult.OK)
                {
                    long id = long.Parse((string)dataGridViewExames.CurrentRow.Cells["Cliente_ID"].Value);
                    ClasseExames.removerDaBaseDados(datahelper, id);
                }
            }
            else
            {
                MessageBox.Show("Alerta: Não selecionou nenhum exame. Tente novamente!");
            }
        }