private void btnAceptar_Click(object sender, EventArgs e)
        {
            try
            {
                validarEntidad();

                HorarioService s = new HorarioService();

                if (this.horario.Id != 0)
                {
                    s.Update(horario);
                }
                else
                {
                    s.Insert(horario);
                }

                CommonHelper.ShowInfo("Horario guardado con éxito.");
                this.DialogResult = DialogResult.OK;
            }
            catch (WarningException ex)
            {
                CommonHelper.ShowWarning(ex.Message);
            }
            catch (Exception ex)
            {
                CommonHelper.ShowError(ex.Message);
            }
        }
Exemplo n.º 2
0
        private void btnAsignarHorario_Click(object sender, EventArgs e)
        {
            try
            {
                validarHorario();

                HorarioService s = new HorarioService();

                var aux = s.GetAll().Find(x => x.HoraInicio == horario.HoraInicio &&
                                          x.HoraFin == horario.HoraFin &&
                                          x.DiaSemana == horario.DiaSemana);

                if (aux == null)
                {
                    horario.Id = s.Insert(horario);
                }
                else
                {
                    horario = aux;
                }


                new ComisionService().AsignarHorario(comision.Id, horario.Id);

                cargarGrilla();
            }
            catch (WarningException ex)
            {
                CommonHelper.ShowWarning(ex.Message);
            }
            catch (Exception ex)
            {
                CommonHelper.ShowError(ex.Message);
            }
        }
Exemplo n.º 3
0
 private void inserir()
 {
     if (validar())
     {
         PreencherHorario();
         if (servico.Insert(horarioExpediente))
         {
             MetroFramework.MetroMessageBox.Show(this, "Foi inserido o horário de entrada: " + horarioExpediente.Entrada + " e de saída: " + horarioExpediente.Saida +
                                                 " no funcionário: " + horarioExpediente.Funcionario.Nome + ".", "Cadastrado com sucesso!", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Question);
             limparTela();
             this.Dispose();
         }
     }
 }
Exemplo n.º 4
0
        public void LerXml(string caminho)
        {
            servicoHorario     = new HorarioService(context);
            servicoFuncionario = new FuncionarioService(context);
            XmlDocument doc = new XmlDocument();

            doc.Load(caminho);

            XmlNodeList xmlHorarios = doc.GetElementsByTagName("Horarios");

            //Usando for para imprimir na tela

            for (int x = 0; x < xmlHorarios.Count; x++)
            {
                HorarioExpediente horarioExpediente = new HorarioExpediente();

                //Preenchendo Objeto.
                horarioExpediente.Funcionario.Id   = int.Parse(xmlHorarios[x]["IdFuncionario"].InnerText);
                horarioExpediente.Funcionario.Nome = xmlHorarios[x]["NomeFuncionario"].InnerText;
                horarioExpediente.Funcionario.CPF  = xmlHorarios[x]["CPFFuncionario"].InnerText;
                horarioExpediente.Data             = Convert.ToDateTime(xmlHorarios[x]["Data"].InnerText);
                horarioExpediente.Entrada          = Convert.ToDateTime(xmlHorarios[x]["Entrada"].InnerText);
                horarioExpediente.Saida            = Convert.ToDateTime(xmlHorarios[x]["Saida"].InnerText);

                if (servicoFuncionario.GetFuncionarioCPFExiste(horarioExpediente.Funcionario.CPF))
                {
                    if (servicoHorario.GetHorarioArquivo(horarioExpediente.Funcionario.CPF, horarioExpediente.Data, horarioExpediente.Entrada))
                    {
                        servicoHorario.Insert(horarioExpediente);
                    }
                    else
                    {
                        MetroFramework.MetroMessageBox.Show(this, "Esse arquivo já foi processado no sistema.", "Atenção!", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand);
                        return;
                    }
                }
                else
                {
                    MetroFramework.MetroMessageBox.Show(this, "O Funcionário: " + horarioExpediente.Funcionario.Nome.ToString() + ", " + "com CPF: " + horarioExpediente.Funcionario.Nome.ToString() + " não está cadastrado no banco principal, cadastre e leia o arquivo novamente", "Atenção!", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand);
                    return;
                }
            }

            MetroFramework.MetroMessageBox.Show(this, "O arquivo foi processado com sucesso.", "Processado com sucesso!", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Question);
        }
Exemplo n.º 5
0
        public void OnComplete(object Capture, string ReaderSerialNumber, Sample Sample)
        {
            this.Invoke(new Function(delegate() { this.imgDigital.Enabled = true; }));
            this.Invoke(new Function(delegate() { this.Cursor = Cursors.WaitCursor; }));
            sp.ConvertToPicture(Sample, ref img);
            FuncionarioService funServ = new FuncionarioService(context);

            funcionarios = new List <Funcionario>();
            funcionarios = funServ.GetFuncionarios();
            byte[] bytes = Sample.Bytes;
            Process(Sample);

            if (impressaoLocalizada)
            {
                if (funcionario != null)
                {
                    if (funcionario.Id == 0)
                    {
                        return;
                    }

                    if ((impressaoLocalizada) &&
                        (funcionarioAnterior != null))
                    {
                        if (funcionarioAnterior.Id == 0)
                        {
                            impressaoLocalizada = false;
                        }

                        if (funcionario.Id == funcionarioAnterior.Id)
                        {
                            HorarioExpediente horarioExpediente = new HorarioExpediente();
                            HorarioService    serviceHorario    = new HorarioService(context);
                            horarioExpediente.Data = DateTime.Now.Date;
                            HorarioExpediente ultimoHorario = serviceHorario.GetLastHorario(funcionario.Id);
                            horarioExpediente.Funcionario = funcionario;

                            if (ultimoHorario == null)
                            {
                                horarioExpediente.Entrada = DateTime.Now;
                                horarioExpediente.Saida   = new DateTime();
                                serviceHorario.Insert(horarioExpediente);
                                updateStatus("Horário de entrada lançado com sucesso...");
                            }
                            else
                            {
                                if ((ultimoHorario.Entrada != DateTime.MinValue) &&
                                    (ultimoHorario.Saida == DateTime.MinValue))
                                {
                                    ultimoHorario.Saida = DateTime.Now;
                                    serviceHorario.Update(ultimoHorario);
                                    updateStatus("Horário de saída lançado com sucesso...");
                                }
                                else
                                {
                                    horarioExpediente.Entrada = DateTime.Now;
                                    horarioExpediente.Saida   = new DateTime();
                                    serviceHorario.Insert(horarioExpediente);
                                    updateStatus("Horário de entrada lançado com sucesso...");
                                }
                            }

                            funcionario         = new Funcionario();
                            funcionarioAnterior = funcionario;
                            this.Invoke(new Function(delegate() { limparTela(); }));
                            cp.StopCapture();
                            cp = new DPFP.Capture.Capture();
                            cp.StartCapture();
                            cp.EventHandler = this;
                        }
                    }
                    if ((impressaoLocalizada == false) ||
                        (funcionarioAnterior == null))
                    {
                        PreencherTela();
                        updateStatus("Impressão digital localizada. \nPara efetuar o lançamento do ponto e coloque novamente o mesmo dedo no leitor.");
                        funcionarioAnterior = funcionario;
                        impressaoLocalizada = true;
                    }
                    else
                    {
                        impressaoLocalizada = false;
                    }
                }
                else
                {
                    updateStatus("Impressão digital não localizada. \nTente novamente.");
                    funcionarioAnterior = null;
                    impressaoLocalizada = false;
                }
            }
            else
            {
                funcionario         = new Funcionario();
                funcionarioAnterior = funcionario;
                this.Invoke(new Function(delegate() { limparTela(); }));
                cp.StopCapture();
                cp = new DPFP.Capture.Capture();
                cp.StartCapture();
                cp.EventHandler = this;
                this.Invoke(new Function(delegate() { limparTela(); }));
            }
            this.Invoke(new Function(delegate() { this.Cursor = Cursors.Default; }));

            this.Invoke(new Function(delegate() { this.imgDigital.Enabled = false; }));
        }