Пример #1
0
        private void atendimentoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TipoAtendimento tipoAtendimento = new TipoAtendimento();
            TipoReclamacao  tipoReclamacao  = new TipoReclamacao();
            SGAPContexto    contexto        = new SGAPContexto();

            int contadorTipoReclamacao  = contexto.TipoReclamacao.Count(x => x.id > 0);
            int contadorTipoAtendimento = contexto.TipoAtendimento.Count(x => x.id > 0);

            if (contadorTipoAtendimento == 0 && contadorTipoReclamacao == 0)
            {
                MessageBox.Show("Cadastre pelo menos um Tipo Atendimento e um Tipo Reclamação para acessar Atendimento/CIP");
            }
            else if (contadorTipoAtendimento == 0 && contadorTipoReclamacao > 0)
            {
                MessageBox.Show("Cadastre pelo menos um Tipo Atendimento para acessar Atendimento/CIP");
            }
            else if (contadorTipoAtendimento > 0 && contadorTipoReclamacao == 0)
            {
                MessageBox.Show("Cadastre pelo menos um Tipo Reclamação para acessar Atendimento/CIP");
            }
            else
            {
                if (atendimentoAberto != 1)
                {
                    atendimentoAberto = 1;
                    frmAtendimento frmAtend = new frmAtendimento(this);
                    frmAtend.MdiParent = this;
                    frmAtend.Show();
                    frmAtend.BringToFront();
                }
            }
        }
Пример #2
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();
                }
            }
        }
Пример #3
0
        private void lbNovo_Click(object sender, EventArgs e)
        {
            limparCampos();
            cmbTipoAtendimento.ResetText();
            habilitaCampos(true);
            txtId.Text = "-1";
            txtnumeroProcon.Focus();
            btnAndamentos.Visible = false;
            lbEncaminhar.Visible  = false;

            //dtpInicio.Text = DateTime.Now.ToShortDateString().ToString();


            dtpInicio.Text = DateTime.Now.ToShortDateString();

            AlteracaoAtendimento alteracaoAtendimento = new AlteracaoAtendimento();
            SGAPContexto         contexto             = new SGAPContexto();

            alteracaoAtendimento = contexto.AlteracaoAtendimento.OrderByDescending(x => x.id).FirstOrDefault(x => x.usuario.Equals(menu.usuario) && x.TipoAtendimento.descricao.ToLower().Trim().Equals("atendimento"));

            if (alteracaoAtendimento == null)
            {
                txtnumeroProcon.Text = "001-" + DateTime.Now.Year + "-" + menu.usuario;
            }
            else if (alteracaoAtendimento.dataInicio.Year != DateTime.Now.Year)
            {
                txtnumeroProcon.Text = "001-" + DateTime.Now.Year + "-" + menu.usuario;
            }
            else
            {
                txtnumeroProcon.Text = (Convert.ToInt32(alteracaoAtendimento.numeroProcon.Substring(0, 3)) + 1).ToString("000") + "-" + DateTime.Now.Year + "-" + menu.usuario;
            }
        }
Пример #4
0
        public static bool tratamentoCpfFornecedor(TextBox txt)
        {
            if (txt.Text != "")
            {
                string cpf = txt.Text.Replace(".", "").Replace("-", "").Replace("/", "");

                if (ValidaCpf.IsCpf(txt.Text) != true)
                {
                    MessageBox.Show("CPF ou CNPJ inválido", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txt.Focus();
                    return(false);
                }
                else
                {
                    txt.Text = Convert.ToUInt64(cpf).ToString(@"000\.000\.000\-00");
                    SGAP.Modelo.SGAPContexto contexto = new SGAPContexto();
                    cpf = txt.Text;
                    Fornecedor forn = contexto.Fornecedor.ToList().FirstOrDefault(t => t.cnpj.CompareTo(cpf) == 0);
                    if (forn != null)
                    {
                        MessageBox.Show("Este CPF já está cadastrado no sistema!", "Alerta!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txt.Focus();
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            else
            {
                return(true);
            }
        }
Пример #5
0
 public static bool tratamentoCpnjFornecedor(TextBox txt)
 {
     if (txt.Text != "")
     {
         string cnpj = txt.Text.Replace(".", "").Replace("-", "").Replace("/", "");
         if (ValidaCpf.IsCnpj(txt.Text) != true)
         {
             //MessageBox.Show("CNPJ inválido", "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Information);
             //txt.Focus();
             //return false;
             return(FuncGeral.tratamentoCpfFornecedor(txt));
         }
         else
         {
             txt.Text = Convert.ToUInt64(cnpj).ToString(@"00\.000\.000\/0000\.00");
             SGAP.Modelo.SGAPContexto contexto = new SGAPContexto();
             cnpj = txt.Text;
             Fornecedor fornecedor = contexto.Fornecedor.ToList().FirstOrDefault(t => t.cnpj.CompareTo(cnpj) == 0);
             if (fornecedor != null)
             {
                 MessageBox.Show("Já existe um fornecedor cadastrado com este CNPJ!", "Alerta!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txt.Focus();
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
     }
     else
     {
         return(true);
     }
 }
Пример #6
0
        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();
            }
        }
Пример #7
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);
            }
        }
Пример #8
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();
                }
            }
        }
Пример #9
0
        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);
            }
        }
Пример #10
0
        private void frmCopiaBackup_Load(object sender, EventArgs e)
        {
            SGAPContexto contexto = new SGAPContexto();
            string       folder   = @"C:\Relatorio\";

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            folder += "Copia";
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            fbd.SelectedPath = folder;
            txtPath.Text     = folder;

            DateTime data = DateTime.Today;

            txtNomeArquivo.Text = "BACKUP_" + "PROCON" + "_" + data.Day + "." + data.Month + "." + data.Year;
        }
Пример #11
0
        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();
        }
Пример #12
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            Usuario      login    = new Usuario();
            SGAPContexto contexto = new SGAPContexto();

            login.usuario = txtUsuario.Text;
            login.senha   = txtSenha.Text;

            Usuario verificaLogin = new Usuario();

            verificaLogin = contexto.Login.FirstOrDefault(x => x.usuario.Equals(login.usuario) && x.senha.Equals(login.senha));

            if (verificaLogin == null)
            {
                MessageBox.Show("O usuário ou senha são inválidos", "Login", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                menu.usuario = verificaLogin.usuario;
                this.Close();
            }
        }
Пример #13
0
        public static void prazoFornecedor()
        {
            SGAPContexto contexto = new SGAPContexto();
            string       folder   = @"c:\Relatórios";
            string       arquivo  = @"C:\Relatórios\Prazo Fornecedores " + DateTime.Now.ToString("dd-MM-yyyy") + ".xlsx";

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            try
            {
                if (File.Exists(arquivo))
                {
                    File.Delete(arquivo);
                }


                List <Andamento> lstAndamentos = new List <Andamento>();

                lstAndamentos = contexto.Andamento.Where(x => x.Atendimento.dataEncerramento == null).OrderBy(x => x.prazo).ToList();

                FileInfo     caminhoNomeArquivo = new FileInfo(arquivo);
                ExcelPackage arquivoExcel       = new ExcelPackage(caminhoNomeArquivo);

                ExcelWorksheet planilha = arquivoExcel.Workbook.Worksheets.Add("Plan1");

                planilha.Cells["A1"].Value           = "RELATÓRIOS DE PRAZOS DE FORNECEDORES (ATENDIMENTOS ATIVOS)";
                planilha.Cells["A1"].Style.Font.Bold = true;
                planilha.Cells["A1"].Style.Font.Size = 14;
                planilha.Row(1).Height = 32;
                planilha.Cells["A1"].Style.VerticalAlignment = ExcelVerticalAlignment.Center;

                planilha.Cells["A1:A2"].Style.Font.Color.SetColor(Color.FromArgb(0, 112, 192));

                planilha.Cells["A2"].Value  = "Período: " + DateTime.Now.ToShortDateString();
                planilha.View.ShowGridLines = false;

                int linha  = 3;
                int coluna = 1;

                //INSERINDO VALORES NA PRIMEIRA LINHA
                planilha.Cells[++linha, coluna].Value = "PRAZO";
                planilha.Cells[linha, ++coluna].Value = "DESCRIÇÃO";
                planilha.Cells[linha, ++coluna].Value = "NÚMERO ATENDIMENTO";
                planilha.Cells[linha, ++coluna].Value = "DATA INSERÇÃO";

                planilha.Cells["A4:D4"].Style.Fill.PatternType = ExcelFillStyle.Solid;
                planilha.Cells["A4:D4"].Style.Fill.BackgroundColor.SetColor(Color.FromArgb(128, 128, 128));

                //DEFININDO COR DA FONTE
                planilha.Cells["A4:D4"].Style.Font.Color.SetColor(Color.FromArgb(255, 255, 255));

                //DEFININDO NEGRITO
                planilha.Cells["A4:D4"].Style.Font.Bold = true;

                foreach (Andamento andamento in lstAndamentos)
                {
                    planilha.Cells[++linha, coluna = 1].Value = andamento.prazo;
                    planilha.Cells[linha, ++coluna].Value     = andamento.descricao;
                    planilha.Cells[linha, ++coluna].Value     = andamento.Atendimento.numeroProcon;
                    planilha.Cells[linha, ++coluna].Value     = andamento.data;
                }

                planilha.Cells["A4:D" + linha].Style.Border.Top.Style    = ExcelBorderStyle.Thin;
                planilha.Cells["A4:D" + linha].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
                planilha.Cells["A4:D" + linha].Style.Border.Left.Style   = ExcelBorderStyle.Thin;
                planilha.Cells["A4:D" + linha].Style.Border.Right.Style  = ExcelBorderStyle.Thin;

                if (linha < 5)
                {
                    linha = 5;
                }

                //CENTRALIZANDO
                planilha.Cells["A4:D4"].Style.HorizontalAlignment        = ExcelHorizontalAlignment.Center;
                planilha.Cells["A5:A" + linha].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                planilha.Cells["C5:D" + linha].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;

                //TRATANDO FORMATO DE CELULA
                planilha.Cells["A5:A" + linha].Style.Numberformat.Format = "dd/MM/yyyy";
                planilha.Cells["D5:D" + linha].Style.Numberformat.Format = "dd/MM/yyyy";

                //CODIGOS FINAIS
                planilha.Cells[planilha.Dimension.Address].AutoFitColumns();
                planilha.Column(1).Width = 23;


                arquivoExcel.Save();
                arquivoExcel.Dispose();

                System.Diagnostics.Process.Start(arquivo);
            }
            catch (System.IO.IOException)
            {
                MessageBox.Show("Arquivo existente aberto. Feche e tente gerar novamente!", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #14
0
 //Escluir depois
 private Consumidor cpfExist(string cpf) //CPF e CNPJ FUNCIONA
 {
     SGAP.Modelo.SGAPContexto contexto = new SGAPContexto();
     return(contexto.Consumidor.ToList().FirstOrDefault(t => t.cpf.CompareTo(cpf) == 0));
 }