示例#1
0
 public formABCAsistencias(SqlConnection con)
 {
     InitializeComponent();
     this.conexion      = con;
     this.dia           = new DiaLaboral();
     this.diaslaborales = this.dia.ListarDiasLaborales(this.conexion);
 }
示例#2
0
        private void btnCargar_Click(object sender, EventArgs e)
        {
            DiaLaboral dia      = new DiaLaboral();
            Date       fechaIni = new Date(cmbFechaInicio.Value);
            Date       fechaFin = new Date(cmbFechaFin.Value);

            if (ckbxEmpleado.Checked == true)
            {
                if (ckbxAsistencia.Checked == true)
                {
                    int    idemp = (int)cmbEmpleado.SelectedValue;
                    String asist = cmbAsistencia.SelectedItem.ToString();
                    dgvAsistencias.DataSource = dia.reporteEmpleadoAsistencia(idemp, fechaIni, fechaFin, asist, this.conexion);
                }
                else
                {
                    int idemp = (int)cmbEmpleado.SelectedValue;
                    dgvAsistencias.DataSource = dia.reporteEmpleado(idemp, fechaIni, fechaFin, this.conexion);
                }
            }
            else
            {
                if (ckbxAsistencia.Checked == true)
                {
                    String asist = cmbAsistencia.SelectedItem.ToString();
                    dgvAsistencias.DataSource = dia.reporteAsistencia(fechaIni, fechaFin, asist, this.conexion);
                }
                else
                {
                    dgvAsistencias.DataSource = dia.reporteGeneral(fechaIni, fechaFin, this.conexion);
                }
            }
        }
示例#3
0
        private void btnRegistra_Click(object sender, EventArgs e)
        {
            DialogResult rs = MessageBox.Show("¿Realmente desea registrar falta al empleado seleccionado?", "Registro de faltas", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (rs.Equals(DialogResult.OK))
            {
                DiaLaboral dia = new DiaLaboral();
                dia.setFecha(new Date(DateTime.Now));
                dia.setAsistencia(DiaLaboral.Asistencia.Falta);
                dia.setIdEmpleado(this.emp.getClave());
                string etqdia = DateTime.Now.ToString("dddd", new CultureInfo("es-ES"));
                DiaLaboral.DiaSemana etiqueta = new DiaLaboral.DiaSemana();
                switch (etqdia)
                {
                case "domingo": etiqueta = DiaLaboral.DiaSemana.Domingo; break;

                case "lunes": etiqueta = DiaLaboral.DiaSemana.Lunes; break;

                case "martes": etiqueta = DiaLaboral.DiaSemana.Martes; break;

                case "miércoles": etiqueta = DiaLaboral.DiaSemana.Miércoles; break;

                case "jueves": etiqueta = DiaLaboral.DiaSemana.Jueves; break;

                case "viernes": etiqueta = DiaLaboral.DiaSemana.Viernes; break;

                case "sabado": etiqueta = DiaLaboral.DiaSemana.Sabado; break;
                }
                if (etiqueta != this.emp.getDiaLibre())
                {
                    EntradaLaboral ent = new EntradaLaboral();
                    ent.setFechaEnt(new Date(DateTime.Now));
                    ent.setIdEmpleado(this.emp.getClave());
                    ent.setHoraEnt(new Time(0, 0, 0));
                    ent.insertarEntradaBD(this.conexion);
                    ent = new EntradaLaboral(this.emp.getClave(), new Date(DateTime.Now), this.conexion);
                    SalidaLaboral sal = new SalidaLaboral();
                    sal.setFechaSal(new Date(DateTime.Now));
                    sal.setIdEmpleado(this.emp.getClave());
                    sal.setHoraSal(new Time(0, 0, 0));
                    sal.insertarSalidaBD(this.conexion);
                    sal = new SalidaLaboral(this.emp.getClave(), new Date(DateTime.Now), this.conexion);
                    dia.setIdHoraEnt(ent.getIdEntrada());
                    dia.setIdHoraSal(sal.getIdSalida());
                    int n = dia.insertarDiaBD(this.conexion);
                    if (n > 0)
                    {
                        MessageBox.Show("La falta fue registrada exitosamente.", "Mensaje de Exito", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        this.emp = new Empleado();
                    }
                    else
                    {
                        MessageBox.Show("La falta no pudo ser registrada.", "Mensaje de Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                MessageBox.Show("La falta no puede ser registrada en el día de descanso del trabajador.", "Mensaje de Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void dgvDiasLaborales_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dgvDiasLaborales.SelectedCells[0].Value == DBNull.Value)
     {
         int id = dgvDiasLaborales.SelectedCells[0].RowIndex;
         this.dia = this.diaslaborales[id];
         //new formDatosDias(this.dia, this.conexion).ShowDialog();
     }
 }
 private void dgvDiasLaborales_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dgvDiasLaborales.SelectedCells[0].Value == DBNull.Value)
     {
         btnEditar.Enabled = true;
         btnBorrar.Enabled = true;
         int id = dgvDiasLaborales.SelectedCells[0].RowIndex;
         this.dia = this.diaslaborales[id];
     }
 }
示例#6
0
        private void btnBorrar_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("¿Realmente desea eliminar el registro?", "Eliminar registro", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (result.Equals(DialogResult.OK))
            {
                int n = this.dia.borrarDiaBD(this.conexion);
                if (n > 0)
                {
                    MessageBox.Show("El registro fue eliminado satisfactoriamente.", "Mensaje de Exito", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    dgvDiasLaborales.Rows.Clear();
                    actualizarDGV();
                    this.dia = null;
                }
                else
                {
                    MessageBox.Show("El registro no pudo ser eliminado.", "Mensaje de Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
示例#7
0
        private void btnCargar_Click(object sender, EventArgs e)
        {
            DiaLaboral        dia = new DiaLaboral();
            List <DiaLaboral> dias;
            Date fechaIni = new Date(cmbFechaInicio.Value);
            Date fechaFin = new Date(cmbFechaFin.Value);

            if (ckbxEmpleado.Checked == true)
            {
                if (ckbxAsistencia.Checked == true)
                {
                    int    idemp = Convert.ToInt32(cmbEmpleados.SelectedItem.ToString());
                    String asist = cmbAsistencia.SelectedItem.ToString();
                    dias = dia.reporteEmpleadoAsistencia(idemp, fechaIni, fechaFin, asist, this.conexion);
                    carguarDGV(dias);
                }
                else
                {
                    int idemp = Convert.ToInt32(cmbEmpleados.SelectedItem.ToString());
                    dias = dia.reporteEmpleado(idemp, fechaIni, fechaFin, this.conexion);
                    carguarDGV(dias);
                }
            }
            else
            {
                if (ckbxAsistencia.Checked == true)
                {
                    String asist = cmbAsistencia.SelectedItem.ToString();
                    dias = dia.reporteAsistencia(fechaIni, fechaFin, asist, this.conexion);
                    carguarDGV(dias);
                }
                else
                {
                    dias = dia.reporteGeneral(fechaIni, fechaFin, this.conexion);
                    carguarDGV(dias);
                }
            }
        }
示例#8
0
        private void btnRegistrar_Click(object sender, EventArgs e)
        {
            EntradaLaboral ent;
            SalidaLaboral  sal;
            DiaLaboral     dia;

            if (rbtnFacial.Checked == true)
            {
                //if (curp.Equals(this.emp.getCURP()))
                if (true)
                {
                    DialogResult rs = MessageBox.Show("¿Realmente desea registrar la asistencia con el empleado seleccionado?", "Registro de asistencia", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (rs.Equals(DialogResult.OK))
                    {
                        if (DateTime.Now.Hour <= this.emp.getHoraEnt().Hours + 1 && DateTime.Now.Hour <= this.emp.getHoraSal().Hours - 1)
                        {
                            ent = new EntradaLaboral();
                            ent.setFechaEnt(new Date(DateTime.Now));
                            ent.setHoraEnt(new Time(DateTime.Now));
                            ent.setIdEmpleado(this.emp.getClave());
                            int r = ent.insertarEntradaBD(this.conexion);
                            if (r > 0)
                            {
                                MessageBox.Show("La entrada laboral fue registrada satisfactoriamente.", "Mensaje de Exito", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            }
                            else
                            {
                                MessageBox.Show("La entrada no pudo ser registrada.", "Mensaje de Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            if (DateTime.Now.Hour <= this.emp.getHoraSal().Hours + 1 && DateTime.Now.Hour > this.emp.getHoraEnt().Hours + 1)
                            {
                                sal = new SalidaLaboral();
                                sal.setFechaSal(new Date(DateTime.Now));
                                sal.setHoraSal(new Time(DateTime.Now));
                                sal.setIdEmpleado(this.emp.getClave());
                                int r = sal.insertarSalidaBD(this.conexion);
                                if (r > 0)
                                {
                                    MessageBox.Show("La salida laboral fue registrada satisfactoriamente.", "Mensaje de Exito", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                    ent = new EntradaLaboral(this.emp.getClave(), new Date(DateTime.Now), this.conexion);
                                    sal = new SalidaLaboral(this.emp.getClave(), new Date(DateTime.Now), this.conexion);

                                    dia = new DiaLaboral();
                                    dia.setFecha(sal.getFechaSal());
                                    dia.setIdEmpleado(sal.getIdEmpleado());
                                    dia.setIdHoraSal(sal.getIdSalida());
                                    if (ent.getIdEntrada() != 0)
                                    {
                                        dia.setIdHoraEnt(ent.getIdEntrada());
                                        if (ent.getHoraEnt().Minutes > 15)
                                        {
                                            dia.setAsistencia(DiaLaboral.Asistencia.Retardo);
                                            dia.insertarDiaBD(this.conexion);
                                        }
                                        else
                                        {
                                            dia.setAsistencia(DiaLaboral.Asistencia.Presente);
                                            dia.insertarDiaBD(this.conexion);
                                        }
                                    }
                                    else
                                    {
                                        ent = new EntradaLaboral();
                                        ent.setFechaEnt(new Date(DateTime.Now));
                                        ent.setIdEmpleado(this.emp.getClave());
                                        ent.setHoraEnt(new Time(0, 0, 0));
                                        ent.insertarEntradaBD(this.conexion);
                                        ent = new EntradaLaboral(this.emp.getClave(), new Date(DateTime.Now), this.conexion);
                                        dia.setIdHoraEnt(ent.getIdEntrada());
                                        dia.setAsistencia(DiaLaboral.Asistencia.Falta);
                                        dia.insertarDiaBD(this.conexion);
                                        MessageBox.Show("Día laboral registrado como falta por no tener registro de entrada del día.", "Mensaje de Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("La salida no pudo ser registrada.", "Mensaje de Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Es imposible registrar una entrada o salida una hora despues del horario registrado.", "Mensaje de Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Empleado no identificado de manera correcta", "Mesaje de error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                if (lblIdTarjeta.Text.Equals(this.emp.getIdTarjeta()))
                {
                    DialogResult rs = MessageBox.Show("¿Realmente desea registrar la asistencia con el empleado seleccionado?", "Registro de asistencia", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (rs.Equals(DialogResult.OK))
                    {
                        if (DateTime.Now.Hour <= this.emp.getHoraEnt().Hours + 1 && DateTime.Now.Hour <= this.emp.getHoraSal().Hours - 1)
                        {
                            ent = new EntradaLaboral();
                            ent.setFechaEnt(new Date(DateTime.Now));
                            ent.setHoraEnt(new Time(DateTime.Now));
                            ent.setIdEmpleado(this.emp.getClave());
                            int r = ent.insertarEntradaBD(this.conexion);
                            if (r > 0)
                            {
                                MessageBox.Show("La entrada laboral fue registrada satisfactoriamente.", "Mensaje de Exito", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            }
                            else
                            {
                                MessageBox.Show("La entrada no pudo ser registrada.", "Mensaje de Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            if (DateTime.Now.Hour <= this.emp.getHoraSal().Hours + 1 && DateTime.Now.Hour > this.emp.getHoraEnt().Hours + 1)
                            {
                                sal = new SalidaLaboral();
                                sal.setFechaSal(new Date(DateTime.Now));
                                sal.setHoraSal(new Time(DateTime.Now));
                                sal.setIdEmpleado(this.emp.getClave());
                                int r = sal.insertarSalidaBD(this.conexion);
                                if (r > 0)
                                {
                                    MessageBox.Show("La salida laboral fue registrada satisfactoriamente.", "Mensaje de Exito", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                    ent = new EntradaLaboral(this.emp.getClave(), new Date(DateTime.Now), this.conexion);
                                    sal = new SalidaLaboral(this.emp.getClave(), new Date(DateTime.Now), this.conexion);

                                    dia = new DiaLaboral();
                                    dia.setFecha(sal.getFechaSal());
                                    dia.setIdEmpleado(sal.getIdEmpleado());
                                    dia.setIdHoraSal(sal.getIdSalida());
                                    if (ent.getIdEntrada() != 0)
                                    {
                                        dia.setIdHoraEnt(ent.getIdEntrada());
                                        if (ent.getHoraEnt().Minutes > 15)
                                        {
                                            dia.setAsistencia(DiaLaboral.Asistencia.Retardo);
                                            dia.insertarDiaBD(this.conexion);
                                        }
                                        else
                                        {
                                            dia.setAsistencia(DiaLaboral.Asistencia.Presente);
                                            dia.insertarDiaBD(this.conexion);
                                        }
                                    }
                                    else
                                    {
                                        ent = new EntradaLaboral();
                                        ent.setFechaEnt(new Date(DateTime.Now));
                                        ent.setIdEmpleado(this.emp.getClave());
                                        ent.setHoraEnt(new Time(0, 0, 0));
                                        ent.insertarEntradaBD(this.conexion);
                                        ent = new EntradaLaboral(this.emp.getClave(), new Date(DateTime.Now), this.conexion);
                                        dia.setIdHoraEnt(ent.getIdEntrada());
                                        dia.setAsistencia(DiaLaboral.Asistencia.Falta);
                                        dia.insertarDiaBD(this.conexion);
                                        MessageBox.Show("Día laboral registrado como falta por no tener registro de entrada del día.", "Mensaje de Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("La salida no pudo ser registrada.", "Mensaje de Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Es imposible registrar una entrada o salida una hora despues del horario registrado.", "Mensaje de Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Empleado no identificado de manera correcta", "Mesaje de error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
示例#9
0
        public ActionResult Create(Calendario model)
        {
            try
            {
                model.AsignarId();

                model.Estado      = Rp3.AgendaComercial.Models.Constantes.Estado.Activo;
                model.EstadoTabla = Rp3.AgendaComercial.Models.Constantes.Estado.Tabla;
                model.UsrIng      = this.UserLogonName;
                model.FecIng      = this.GetCurrentDateTime();
                model.UsrMod      = this.UserLogonName;
                model.FecMod      = this.GetCurrentDateTime();

                if (model.EsDefault)
                {
                    var modelDefaultAnterior = DataBase.Calendarios.Get(p => p.EsDefault == true).FirstOrDefault();
                    if (modelDefaultAnterior != null)
                    {
                        modelDefaultAnterior.EsDefault = false;
                        DataBase.Calendarios.Update(modelDefaultAnterior);
                    }
                }

                DataBase.Calendarios.Insert(model);

                for (int i = 1; i <= 7; i++)
                {
                    DiaLaboral laboral = new DiaLaboral();
                    laboral.IdCalendario = model.IdCalendario;
                    laboral.IdDia        = i + "";
                    laboral.IdDiaTabla   = Rp3.AgendaComercial.Models.Constantes.DiasSemana.Tabla;

                    laboral.EsLaboral = false;

                    if (Request.Form.Get("eslaboral_" + laboral.IdDia) != null)
                    {
                        laboral.HoraInicio1 = Request.Form.Get("desdeJornada1_" + laboral.IdDia).ToString().Replace(':', 'h');
                        laboral.HoraFin1    = Request.Form.Get("hastaJornada1_" + laboral.IdDia).ToString().Replace(':', 'h');

                        if (!String.IsNullOrEmpty(laboral.HoraInicio1) && !String.IsNullOrEmpty(laboral.HoraFin1))
                        {
                            laboral.EsLaboral = true;

                            if (Request.Form.Get("jornada2_" + laboral.IdDia) != null)
                            {
                                laboral.HoraInicio2 = Request.Form.Get("desdeJornada2_" + laboral.IdDia).ToString().Replace(':', 'h');
                                laboral.HoraFin2    = Request.Form.Get("hastaJornada2_" + laboral.IdDia).ToString().Replace(':', 'h');
                            }

                            if (String.IsNullOrEmpty(laboral.HoraInicio2) || String.IsNullOrEmpty(laboral.HoraFin2))
                            {
                                laboral.HoraInicio2 = null;
                                laboral.HoraFin2    = null;
                            }
                        }
                    }

                    if (!laboral.EsLaboral)
                    {
                        laboral.EsLaboral = false;

                        laboral.HoraInicio1 = null;
                        laboral.HoraInicio1 = null;

                        laboral.HoraInicio2 = null;
                        laboral.HoraFin2    = null;
                    }


                    laboral.UsrIng = this.UserLogonName;
                    laboral.FecIng = this.GetCurrentDateTime();
                    laboral.UsrMod = this.UserLogonName;
                    laboral.FecMod = this.GetCurrentDateTime();
                    DataBase.DiasLaborales.Insert(laboral);
                }

                List <string> valoresNoLaboral = new List <string>();
                for (int g = 0; g < Request.Form.Count; g++)
                {
                    if (Request.Form.GetKey(g).Contains("nolaboral"))
                    {
                        valoresNoLaboral.Add(Request.Form.GetKey(g).Replace("nolaboral", ""));
                    }
                }

                DiasNoLaborable noLaborableId = new DiasNoLaborable();
                noLaborableId.IdCalendario = model.IdCalendario;
                noLaborableId.AsignarId();
                int idNoLaborable = noLaborableId.IdDiaNoLaborable;

                foreach (string id in valoresNoLaboral)
                {
                    if (id.Trim() != "")
                    {
                        DateTime        setter      = DateTime.Parse(Request.Form.Get("nolaboral" + id).ToString());
                        DiasNoLaborable noLaborable = new DiasNoLaborable();
                        noLaborable.IdCalendario     = model.IdCalendario;
                        noLaborable.IdDiaNoLaborable = idNoLaborable;

                        noLaborable.Fecha = setter;
                        //noLaborable.Fecha = setter.ToString("dd/MM");

                        if (Request.Form.Get("esteAnio" + id) != null)
                        {
                            noLaborable.EsteAño = true;
                        }
                        else
                        {
                            noLaborable.EsteAño = false;
                        }

                        if (!String.IsNullOrEmpty(Request.Form.Get("nolabInicio_" + id)) && !String.IsNullOrEmpty(Request.Form.Get("nolabFin_" + id)))
                        {
                            noLaborable.DiaParcial = true;
                            noLaborable.HoraInicio = Request.Form.Get("nolabInicio_" + id);
                            noLaborable.HoraFin    = Request.Form.Get("nolabFin_" + id);
                        }
                        else
                        {
                            noLaborable.DiaParcial = false;
                            noLaborable.HoraInicio = null;
                            noLaborable.HoraFin    = null;
                        }

                        noLaborable.UsrIng = this.UserLogonName;
                        noLaborable.FecIng = this.GetCurrentDateTime();
                        noLaborable.UsrMod = this.UserLogonName;
                        noLaborable.FecMod = this.GetCurrentDateTime();
                        DataBase.DiasNoLaborables.Insert(noLaborable);
                        idNoLaborable++;
                    }
                }


                DataBase.Save();
            }
            catch
            {
                this.AddDefaultErrorMessage();
            }

            return(RedirectToAction("Index"));
        }
 public formDatosDia(DiaLaboral d, SqlConnection con)
 {
     InitializeComponent();
     this.conexion = con;
     this.dia      = d;
 }