예제 #1
0
        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();
                }
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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();
                }
            }
        }