private void bsQuestPergun_PositionChanged(object sender, EventArgs e) { if (bsQuestPergun.Current == null) { return; } bsPerguRespos.DataSource = TCN_Pergunta_X_Resposta.Buscar((bsQuestPergun.Current as TRegistro_Questionario_X_Pergunta).Id_perguntastr, string.Empty, null); }
private void BB_NovoR_Click(object sender, EventArgs e) { if (((ToolStripLabel)sender).Name.Equals("BB_NovoR")) { if (string.IsNullOrEmpty(novoDescr())) { return; } TCN_Resposta.Gravar(new TRegistro_Resposta() { Ds_resposta = desc }, null); desc = string.Empty; atualizarRespostas(); } else if (bsRespostas.Current == null) { return; } else if (((ToolStripLabel)sender).Name.Equals("BB_AlterarR")) { if (string.IsNullOrEmpty(novoDescr())) { return; } (bsRespostas.Current as TRegistro_Resposta).Ds_resposta = desc; TCN_Resposta.Gravar((bsRespostas.Current as TRegistro_Resposta), null); desc = string.Empty; atualizarRespostas(); } else if (((ToolStripLabel)sender).Name.Equals("BB_ExcluirR")) { try { TCN_Resposta.Excluir((bsRespostas.Current as TRegistro_Resposta), null); MessageBox.Show("Excluído com sucesso.", "Informativo", MessageBoxButtons.OK, MessageBoxIcon.Error); desc = string.Empty; atualizarRespostas(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (((ToolStripLabel)sender).Name.Equals("BB_AdicionarR") && bsQuestPergun.Current != null) { try { TCN_Pergunta_X_Resposta.Gravar(new TRegistro_Pergunta_x_Resposta() { Id_perguntastr = (bsQuestPergun.Current as TRegistro_Questionario_X_Pergunta).Id_perguntastr, Id_respostastr = (bsRespostas.Current as TRegistro_Resposta).Id_respostastr }, null); atualizarPergunResp(); MessageBox.Show("Adicionado com sucesso.", "Informativo", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void toolStripLabel1_Click(object sender, EventArgs e) { if (((ToolStripLabel)sender).Name.Equals("BB_NovoQuest")) { if (string.IsNullOrEmpty(novoDescr())) { return; } TCN_CadQuestionario.Gravar(new TRegistro_Questionario() { Ds_questionario = desc }, null); desc = string.Empty; atualizarQuestionario(); } else if (bsQuestionario.Current == null) { return; } else if (((ToolStripLabel)sender).Name.Equals("BB_AlterarQuest")) { if (string.IsNullOrEmpty(novoDescr())) { return; } (bsQuestionario.Current as TRegistro_Questionario).Ds_questionario = desc; TCN_CadQuestionario.Gravar((bsQuestionario.Current as TRegistro_Questionario), null); desc = string.Empty; atualizarQuestionario(); } else if (((ToolStripLabel)sender).Name.Equals("BB_ExcluirQuest")) { try { TCN_CadQuestionario.Excluir((bsQuestionario.Current as TRegistro_Questionario), null); MessageBox.Show("Excluído com sucesso.", "Informativo", MessageBoxButtons.OK, MessageBoxIcon.Error); desc = string.Empty; atualizarQuestionario(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //Questionario_X_Pergunta else if (bsQuestPergun.Current == null) { return; } else if (((ToolStripLabel)sender).Name.Equals("BB_ExcluirQPerg")) { try { TCN_Questionario_X_Pergunta.Excluir((bsQuestPergun.Current as TRegistro_Questionario_X_Pergunta), null); MessageBox.Show("Excluído com sucesso.", "Informativo", MessageBoxButtons.OK, MessageBoxIcon.Error); desc = string.Empty; atualizarPerguQuest(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //Pergunta_x_Resposta else if (bsPerguRespos.Current == null) { return; } else if (((ToolStripLabel)sender).Name.Equals("BB_ExcluirPResp")) { try { TCN_Pergunta_X_Resposta.Excluir((bsPerguRespos.Current as TRegistro_Pergunta_x_Resposta), null); MessageBox.Show("Excluído com sucesso.", "Informativo", MessageBoxButtons.OK, MessageBoxIcon.Error); desc = string.Empty; atualizarPergunResp(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void atualizarPergunResp() { bsPerguRespos.DataSource = TCN_Pergunta_X_Resposta.Buscar((bsQuestPergun.Current as TRegistro_Questionario_X_Pergunta).Id_perguntastr, string.Empty, null); bsPerguRespos.ResetBindings(true); }