private void buttonGuardar_Click(object sender, EventArgs e) { if (cbxPromotor.Enabled == false && cbxEstadoProcesso.Enabled == false) { permitirInserir(); buttonGuardar.Text = "Guardar"; } else { try { Promotor promotor = (Promotor)cbxPromotor.SelectedItem; EstadoProcesso estadoprocesso = (EstadoProcesso)cbxEstadoProcesso.SelectedItem; camara.ProcessoSet.Add(new Processo(dataInicio.Value, promotor, estadoprocesso)); camara.SaveChanges(); lerDadosProcessos(); lerDadosPromotores(); lerDadosEstadoProcesso(); permitirInserir(); } catch (Exception ex) { MessageBox.Show("Falha ao adicionar este Processo, insira novamente todos os dados nos campos designados", "FALHA AO INSERIR", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } } }
private void btnAtualizar_Click(object sender, EventArgs e) { btnDesbloquear.BackgroundImage = Properties.Resources.unlock; Promotor promotor = (Promotor)listBox1.SelectedItem; promotor.Nome = tbxNomePromotor.Text; promotor.Morada = tbxMoradaPromotor.Text; promotor.Telemovel = tbxTelemovelPromotor.Text; promotor.CodigoAcesso = tbxCodigoAcessoPromotor.Text; promotor.Email = tbxEmailPromotor.Text; promotor.Senha = tbxSenhaPromotor.Text; camara.SaveChanges(); //Torna as textboxes possiveis de se escrever tbxNomePromotor.ReadOnly = false; tbxNIFPromotor.ReadOnly = false; tbxMoradaPromotor.ReadOnly = false; tbxEmailPromotor.ReadOnly = false; tbxTelemovelPromotor.ReadOnly = false; tbxCodigoAcessoPromotor.ReadOnly = false; tbxSenhaPromotor.ReadOnly = false; //torna a propriedade UseSystemPassordChar off tbxCodigoAcessoPromotor.UseSystemPasswordChar = false; tbxSenhaPromotor.UseSystemPasswordChar = false; //preencher as textboxes com os valores nulos tbxNomePromotor.Text = ""; tbxNIFPromotor.Text = ""; tbxMoradaPromotor.Text = ""; tbxEmailPromotor.Text = ""; tbxTelemovelPromotor.Text = ""; tbxCodigoAcessoPromotor.Text = ""; tbxSenhaPromotor.Text = ""; btnAdicionar.Enabled = true; btnEliminar.Enabled = true; lerDados(); //Torna o botao atualizar invivivel e disabled btnAtualizar.Enabled = false; btnAtualizar.Visible = false; //camara.Dispose(); }
public Processo(DateTime data, Promotor promotor, EstadoProcesso estadoprocesso) { DataInicio = data; Promotor = promotor; EstadoProcesso = estadoprocesso; }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { if (listBox1.SelectedIndex != -1) { Promotor promotor = (Promotor)listBox1.SelectedItem; //preencher as textboxes com os valores da base de dados tbxNomePromotor.Text = promotor.Nome; tbxNIFPromotor.Text = Convert.ToString(promotor.NIF); tbxMoradaPromotor.Text = promotor.Morada; tbxEmailPromotor.Text = promotor.Email; tbxTelemovelPromotor.Text = promotor.Telemovel; tbxCodigoAcessoPromotor.Text = promotor.CodigoAcesso; tbxSenhaPromotor.Text = promotor.Senha; //altera o icon para bloqueado btnDesbloquear.BackgroundImage = Properties.Resources._lock; //Torna as textboxes impossiveis de se escrever tbxNomePromotor.ReadOnly = true; tbxNIFPromotor.ReadOnly = true; tbxMoradaPromotor.ReadOnly = true; tbxEmailPromotor.ReadOnly = true; tbxTelemovelPromotor.ReadOnly = true; tbxCodigoAcessoPromotor.ReadOnly = true; tbxSenhaPromotor.ReadOnly = true; //torna a propriedade UseSystemPassordChar on tbxCodigoAcessoPromotor.UseSystemPasswordChar = true; tbxSenhaPromotor.UseSystemPasswordChar = true; //alterar o text do botão adicionar btnAdicionar.Text = "Limpar Dados"; //amara.Dispose(); } else { //preencher as textboxes com os valores nulos tbxNomePromotor.Text = ""; tbxNIFPromotor.Text = ""; tbxMoradaPromotor.Text = ""; tbxEmailPromotor.Text = ""; tbxTelemovelPromotor.Text = ""; tbxCodigoAcessoPromotor.Text = ""; tbxSenhaPromotor.Text = ""; //altera o icon para desbloqueado btnDesbloquear.BackgroundImage = Properties.Resources.unlock; //Torna as textboxes possiveis de se escrever tbxNomePromotor.ReadOnly = false; tbxNIFPromotor.ReadOnly = false; tbxMoradaPromotor.ReadOnly = false; tbxEmailPromotor.ReadOnly = false; tbxTelemovelPromotor.ReadOnly = false; tbxCodigoAcessoPromotor.ReadOnly = false; tbxSenhaPromotor.ReadOnly = false; //torna a propriedade UseSystemPassordChar off tbxCodigoAcessoPromotor.UseSystemPasswordChar = false; tbxSenhaPromotor.UseSystemPasswordChar = false; //alterar o text do botão adicionar btnAdicionar.Text = "Adicionar"; //desceleciona o Item selecionado } }