265 lines
8.4 KiB
C#
265 lines
8.4 KiB
C#
using BLL;
|
|
using DAL;
|
|
using MLL;
|
|
using Modelo;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace IBRCAD
|
|
{
|
|
public partial class frm_caddecisao : Form
|
|
{
|
|
private string operacao = "";
|
|
private string motivodescisao = "";
|
|
public void alterabotoes(int op)
|
|
{
|
|
pn_dados.Enabled = false;
|
|
btn_inserir.Enabled = false;
|
|
btn_localizar.Enabled = false;
|
|
btn_alterar.Enabled = false;
|
|
btn_excluir.Enabled = false;
|
|
btn_cancel.Enabled = false;
|
|
btn_print.Enabled = false;
|
|
this.txtOutros.Visible = false;
|
|
this.lbloutros.Visible = false;
|
|
|
|
if (op == 1)
|
|
{
|
|
btn_inserir.Enabled = true;
|
|
btn_localizar.Enabled = true;
|
|
}
|
|
if (op == 2)
|
|
{
|
|
pn_dados.Enabled = true;
|
|
btn_print.Enabled = true;
|
|
btn_cancel.Enabled = true;
|
|
}
|
|
if (op == 3)
|
|
{
|
|
btn_alterar.Enabled = true;
|
|
btn_excluir.Enabled = true;
|
|
btn_cancel.Enabled = true;
|
|
}
|
|
}//end alterabotões
|
|
void cleanDisplay()
|
|
{
|
|
this.txtCod.Text = string.Empty;
|
|
this.txtnome.Text = string.Empty;
|
|
this.cb_estcivil.Text = "";
|
|
this.txt_nasc.Text = string.Empty;
|
|
this.cb_sexo.Text = "";
|
|
this.txtprof.Text = string.Empty;
|
|
this.txtCep.Text = string.Empty;
|
|
this.txtRua.Text = string.Empty;
|
|
this.txtNum.Text = string.Empty;
|
|
this.txtBairro.Text = string.Empty;
|
|
this.txtCidade.Text = string.Empty;
|
|
this.cb_uf.Text = "";
|
|
this.txtcomp.Text = string.Empty;
|
|
this.txtDataDecisao.Text = string.Empty;
|
|
this.txtVisitas.Text = string.Empty;
|
|
this.txtAcomp.Text = string.Empty;
|
|
this.txtConse.Text = string.Empty;
|
|
this.txtOutros.Text = string.Empty;
|
|
this.chmemb.Checked = false;
|
|
this.txtCel.Text = string.Empty;
|
|
this.checkedListBox1.SetItemChecked(0,false);
|
|
this.checkedListBox1.SetItemChecked(1, false);
|
|
this.checkedListBox1.SetItemChecked(2, false);
|
|
this.checkedListBox1.SetItemChecked(3, false);
|
|
this.txtDataBatismo.Text = string.Empty;
|
|
}
|
|
public frm_caddecisao()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void pb_exit_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
|
|
}//end close
|
|
|
|
void enablecamps(int op)
|
|
{
|
|
if (op == 0)
|
|
{
|
|
this.pn_dados.Enabled = false;
|
|
}
|
|
else
|
|
{
|
|
this.pn_dados.Enabled = true;
|
|
}
|
|
}//end enable camps
|
|
|
|
private void frm_caddecisao_Load(object sender, EventArgs e)
|
|
{
|
|
this.enablecamps(0);
|
|
this.alterabotoes(1);
|
|
}
|
|
|
|
private void btn_inserir_Click(object sender, EventArgs e)
|
|
{
|
|
this.operacao = "inserir";
|
|
this.alterabotoes(2);
|
|
}//end inserir
|
|
|
|
private void btn_cancel_Click(object sender, EventArgs e)
|
|
{
|
|
this.cleanDisplay();
|
|
this.alterabotoes(1);
|
|
|
|
}
|
|
|
|
private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
foreach (var item in checkedListBox1.CheckedItems)
|
|
{
|
|
string selectedItemText = item.ToString();
|
|
if (selectedItemText == "Outros")
|
|
{
|
|
|
|
this.txtOutros.Visible = true;
|
|
this.lbloutros.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
this.txtOutros.Visible = false;
|
|
this.lbloutros.Visible = false;
|
|
}
|
|
if(selectedItemText == "Reconciliação")
|
|
{
|
|
motivodescisao = "Reconciliação";
|
|
|
|
}
|
|
if (selectedItemText == "Batismo")
|
|
{
|
|
motivodescisao = "Batismo";
|
|
|
|
}
|
|
if(selectedItemText == "Aceitação a Cristo")
|
|
{
|
|
motivodescisao = "Aceitação a Cristo";
|
|
|
|
}
|
|
}
|
|
|
|
}//end checklist
|
|
|
|
private void chmemb_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
if (chmemb.Checked)
|
|
{
|
|
txtDataBatismo.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
txtDataBatismo.Enabled = false;
|
|
}
|
|
}
|
|
|
|
private void btn_localizar_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void btn_alterar_Click(object sender, EventArgs e)
|
|
{
|
|
this.alterabotoes(2);
|
|
this.operacao = "alterar";
|
|
}//end alterar
|
|
|
|
private void btn_excluir_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DialogResult d = MessageBox.Show("Deseja excluir o registro?", "Aviso", MessageBoxButtons.YesNo);
|
|
if (d.ToString() == "Yes")
|
|
{
|
|
DALLconexao cx = new DALLconexao(DadosDaConexao.StringDeConexao);
|
|
BLLFornecedor bll = new BLLFornecedor(cx);
|
|
bll.Excluir(Convert.ToInt32(txtCod.Text));
|
|
this.cleanDisplay();
|
|
this.alterabotoes(1);
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
MessageBox.Show("Impossível excluir o registro. \n O registro esta sendo utilizado em outro local.");
|
|
this.alterabotoes(3);
|
|
}
|
|
}//end delete
|
|
|
|
private void btn_save_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
////leitura dos dados
|
|
ModeloDescisao modelo = new ModeloDescisao();
|
|
modelo.Desc_nome = txtnome.Text;
|
|
modelo.Desc_civil = Convert.ToString(cb_estcivil.SelectedItem);
|
|
modelo.Desc_nasc = txt_nasc.Text;
|
|
modelo.Desc_sexo = Convert.ToString(cb_sexo.SelectedItem);
|
|
modelo.Desc_prof = txtprof.Text;
|
|
modelo.Desc_cep = txtCep.Text;
|
|
modelo.Desc_rua = txtRua.Text;
|
|
modelo.Desc_num = txtNum.Text;
|
|
modelo.Desc_bairro = txtBairro.Text;
|
|
modelo.Desc_cidade = txtCidade.Text;
|
|
modelo.Desc_estado = Convert.ToString(cb_uf.SelectedItem);
|
|
modelo.Desc_cel = txtCel.Text;
|
|
bool whats = cbwhats.Checked;
|
|
string whatsapp;
|
|
if (whats)
|
|
{
|
|
whatsapp = "Sim";
|
|
}
|
|
else
|
|
{
|
|
whatsapp = "Não";
|
|
}
|
|
modelo.Desc_whats = whatsapp;
|
|
modelo.Desc_desc = motivodescisao;
|
|
modelo.Desc_data = txtDataDecisao.Text;
|
|
modelo.Desc_visi = txtVisitas.Text;
|
|
modelo.Desc_acomp = txtAcomp.Text;
|
|
modelo.Desc_conse = txtConse.Text;
|
|
modelo.Desc_batis = txtDataBatismo.Text;
|
|
//obj para gravar os dados no banco
|
|
DALLconexao cx = new DALLconexao(DadosDaConexao.StringDeConexao);
|
|
BLLdescisao bll = new BLLdescisao(cx);
|
|
if (this.operacao == "inserir")
|
|
{
|
|
//cadastrar uma categoria
|
|
bll.Incluir(modelo);
|
|
MessageBox.Show("Cadastro efetuado: Código " + modelo.Desc_cod.ToString());
|
|
|
|
}
|
|
else
|
|
{
|
|
//alterar uma categoria
|
|
modelo.Desc_cod = Convert.ToInt32(txtCod.Text);
|
|
bll.Alterar(modelo);
|
|
MessageBox.Show("Cadastro alterado");
|
|
}
|
|
this.cleanDisplay();
|
|
this.alterabotoes(1);
|
|
}
|
|
catch (Exception erro)
|
|
{
|
|
MessageBox.Show(erro.Message);
|
|
}
|
|
}//end save
|
|
|
|
|
|
}
|
|
}
|