private void frmLogin_Load(object sender, EventArgs e) { txtUsuario.Text = "Digite seu usuário..."; txtSenha.Text = "Digite sua senha..."; btnLogin.Focus(); SGAPContexto contexto = new SGAPContexto(); List <Cidade> lstCidade = new List <Cidade>(); lstCidade = contexto.Cidade.ToList(); TipoAtendimento tipoAtendimento = new TipoAtendimento(); if (contexto.TipoAtendimento.FirstOrDefault(x => x.descricao.ToLower().Trim().Equals("atendimento")) == null) { tipoAtendimento.descricao = "Atendimento"; contexto.TipoAtendimento.Add(tipoAtendimento); contexto.SaveChanges(); } if (contexto.TipoAtendimento.FirstOrDefault(x => x.descricao.ToLower().Trim().Equals("cip")) == null) { tipoAtendimento.descricao = "CIP"; contexto.TipoAtendimento.Add(tipoAtendimento); contexto.SaveChanges(); } }
private void dgvAtendimento_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == dgvAtendimento.Columns["btnEncerrar"].Index && e.RowIndex >= 0) { DialogResult result; result = MessageBox.Show("Deseja encerrar o atendimento?", "Encerrar", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (result == DialogResult.Yes) { Atendimento atendimento = new Atendimento(); SGAPContexto contexto = new SGAPContexto(); atendimento.id = Convert.ToInt32(dgvAtendimento.SelectedRows[0].Cells["id"].Value); atendimento.numeroProcon = dgvAtendimento.SelectedRows[0].Cells["numeroProcon"].Value.ToString(); atendimento.consumidorID = Convert.ToInt32(dgvAtendimento.SelectedRows[0].Cells["consumidorID"].Value); atendimento.fornecedorID = Convert.ToInt32(dgvAtendimento.SelectedRows[0].Cells["fornecedorID"].Value); atendimento.tipoAtendimentoID = Convert.ToInt32(dgvAtendimento.SelectedRows[0].Cells["tipoAtendimentoID"].Value); atendimento.tipoReclamacaoID = Convert.ToInt32(dgvAtendimento.SelectedRows[0].Cells["tipoReclamacaoID"].Value); atendimento.problemaPrincipalID = Convert.ToInt32(dgvAtendimento.SelectedRows[0].Cells["problemaPrincipalID"].Value); atendimento.reclamacao = dgvAtendimento.SelectedRows[0].Cells["reclamacao"].Value.ToString(); atendimento.dataInicio = Convert.ToDateTime(dgvAtendimento.SelectedRows[0].Cells["dataInicio"].Value.ToString()); atendimento.dataEncerramento = DateTime.Now; contexto.Entry(atendimento).State = EntityState.Modified; contexto.SaveChanges(); FuncGeral.trigger(atendimento, menu.usuario); carregarGridAtendimento(); } } }
private void btnEditar_Click(object sender, EventArgs e) { if (txtId.Text != "") { redimensionarGride(); btnAdicionar.Enabled = !btnAdicionar.Enabled; btnRemover.Enabled = !btnRemover.Enabled; if (txtAndamento.Visible == false) { SGAPContexto contexto = new SGAPContexto(); Andamento andamento = new Andamento(); andamento.id = Convert.ToInt32(txtId.Text); andamento.descricao = txtAndamento.Text; andamento.data = Convert.ToDateTime(dgvAndamentos.SelectedRows[0].Cells["data"].Value.ToString()); andamento.atendimentoID = Convert.ToInt32(dgvAndamentos.SelectedRows[0].Cells["atendimentoID"].Value.ToString()); try { if (dtpPrazo.Text == " / /") { andamento.prazo = null; } else { andamento.prazo = Convert.ToDateTime(dtpPrazo.Text); } } catch (System.FormatException) { andamento.prazo = null; } contexto.Entry(andamento).State = EntityState.Modified; contexto.SaveChanges(); carregaGrid(andamento.atendimentoID); MessageBox.Show("Andamento editado com sucesso", "Informação!", MessageBoxButtons.OK, MessageBoxIcon.Information); limparCampos(); } else { txtAndamento.Select(txtAndamento.Text.Length, 0); txtAndamento.Focus(); } } else { MessageBox.Show("Nenhum registro foi selecionado para edição", "Alerta!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void lbMovimentar_Click(object sender, EventArgs e) { TipoAtendimento tipoAtendimento = new TipoAtendimento(); int id = Convert.ToInt32(Convert.ToInt32(dgvAtendimento.SelectedRows[0].Cells["tipoAtendimentoID"].Value)); tipoAtendimento = contexto.TipoAtendimento.FirstOrDefault(x => x.id == id); if (tipoAtendimento.descricao.ToLower().Trim() == "cip") { MessageBox.Show("Esse registro ja é uma CIP", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { DialogResult result; result = MessageBox.Show("Deseja transformar o atendimento " + dgvAtendimento.SelectedRows[0].Cells["numeroProcon"].Value.ToString() + " em CIP?", "Encerrar", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (result == DialogResult.Yes) { Atendimento atendimento = new Atendimento(); SGAPContexto contexto = new SGAPContexto(); AlteracaoAtendimento alteracao = new AlteracaoAtendimento(); tipoAtendimento = contexto.TipoAtendimento.First(x => x.descricao.ToLower().Trim().Equals("cip")); atendimento.id = Convert.ToInt32(dgvAtendimento.SelectedRows[0].Cells["id"].Value); // aqui novoCIP(atendimento); atendimento.consumidorID = Convert.ToInt32(dgvAtendimento.SelectedRows[0].Cells["consumidorID"].Value); atendimento.fornecedorID = Convert.ToInt32(dgvAtendimento.SelectedRows[0].Cells["fornecedorID"].Value); atendimento.tipoAtendimentoID = tipoAtendimento.id; atendimento.tipoReclamacaoID = Convert.ToInt32(dgvAtendimento.SelectedRows[0].Cells["tipoReclamacaoID"].Value); atendimento.problemaPrincipalID = Convert.ToInt32(dgvAtendimento.SelectedRows[0].Cells["problemaPrincipalID"].Value); atendimento.reclamacao = dgvAtendimento.SelectedRows[0].Cells["reclamacao"].Value.ToString(); atendimento.dataInicio = Convert.ToDateTime(dgvAtendimento.SelectedRows[0].Cells["dataInicio"].Value.ToString()); atendimento.dataEncerramento = DateTime.Now; contexto.Entry(atendimento).State = EntityState.Modified; contexto.SaveChanges(); FuncGeral.trigger(atendimento, menu.usuario); carregarGridAtendimento(); } } }
private void btnAdicionar_Click(object sender, EventArgs e) { redimensionarGride(); if (txtAndamento.Visible) { limparCampos(); } btnEditar.Enabled = !btnEditar.Enabled; btnRemover.Enabled = !btnRemover.Enabled; txtAndamento.Focus(); //aqui que salva no banco if (txtAndamento.Text != "") { SGAPContexto contexto = new SGAPContexto(); Andamento andamento = new Andamento(); andamento.descricao = txtAndamento.Text; andamento.data = DateTime.Now; andamento.atendimentoID = Convert.ToInt32(frmAtendimento.txtId.Text); try { if (dtpPrazo.Text == " / /") { andamento.prazo = null; } else { andamento.prazo = Convert.ToDateTime(dtpPrazo.Text); } } catch (System.FormatException) { andamento.prazo = null; } contexto.Andamento.Add(andamento); contexto.SaveChanges(); carregaGrid(andamento.atendimentoID); MessageBox.Show("Andamento incluído com sucesso", "Informação!", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public static void trigger(Atendimento atendimento, string usuario) { AlteracaoAtendimento alteracao = new AlteracaoAtendimento(); SGAPContexto contexto = new SGAPContexto(); alteracao.id = -1; alteracao.numeroProcon = atendimento.numeroProcon; alteracao.tipoAtendimentoID = atendimento.tipoAtendimentoID; alteracao.consumidorID = atendimento.consumidorID; alteracao.fornecedorID = atendimento.fornecedorID; alteracao.reclamacao = atendimento.reclamacao; alteracao.dataAlteracao = DateTime.Now; alteracao.usuario = usuario; alteracao.atendimentoID = atendimento.id; alteracao.tipoReclamacaoID = atendimento.tipoReclamacaoID; alteracao.problemaPrincipalID = atendimento.problemaPrincipalID; alteracao.dataInicio = atendimento.dataInicio; alteracao.dataEncerramento = atendimento.dataEncerramento; contexto.AlteracaoAtendimento.Add(alteracao); contexto.SaveChanges(); }