This commit is contained in:
255
Nomina/ChecadorAsistencia.aspx.cs
Normal file
255
Nomina/ChecadorAsistencia.aspx.cs
Normal file
@@ -0,0 +1,255 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Extensiones;
|
||||
|
||||
public partial class Nomina_ChecadorAsistencia : ClsPaginas
|
||||
{
|
||||
private DataTable dtper
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ViewState["dtper"] == null) { return null; }
|
||||
else { return (DataTable)ViewState["dtper"]; }
|
||||
}
|
||||
set { ViewState["dtper"] = value; }
|
||||
}
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
CargaTiposPeriodo();
|
||||
TxtRpdFechaInicio.Text = "01/09/2021";
|
||||
TxtRpdFechaFin.Text = "15/09/2021";
|
||||
DdlTipoAsistencias.DataSource = GlobalDTAsistenciasInasistencias.FiltraParametros(string.Format("CveEmpresa = {0}", UsuarioActual.CveEmpresa));
|
||||
DdlTipoAsistencias.DataBind();
|
||||
|
||||
|
||||
DdlMotivoHoraExtra.DataSource = GlobalDTMotivosHorasExtras.FiltraParametros(string.Format("CveEmpresa = {0}", UsuarioActual.CveEmpresa));
|
||||
DdlMotivoHoraExtra.DataBind();
|
||||
|
||||
CargarCentrosDeCosto(DdlAsisProyecto, DdlAsisSubProyecto, LblAsisProyecto, LblAsisSubProyecto);
|
||||
PnlProyecto.Visible = DdlAsisProyecto.Visible;
|
||||
if (PnlProyecto.Visible)
|
||||
{
|
||||
PnlSubProyecto.CssClass = "col-md-6";
|
||||
}
|
||||
}
|
||||
}
|
||||
private void CargaTiposPeriodo()
|
||||
{
|
||||
DdlTipoPeriodo.DataSource = GlobalDTTipoPeriodo.FiltraParametros("Estatus = 'Activo'");
|
||||
DdlTipoPeriodo.DataBind();
|
||||
DdlTipoPeriodo.Items.Insert(0, new ListItem("Todos", "-1"));
|
||||
if (DdlTipoPeriodo.Items.Count > 0)
|
||||
{
|
||||
DdlTipoPeriodo.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
private DataTable generateTable()
|
||||
{
|
||||
DateTime FechaI = TxtRpdFechaInicio.Text.ToDateTime();
|
||||
DateTime FechaF = TxtRpdFechaFin.Text.ToDateTime();
|
||||
DataTable dtCon = new DataTable();
|
||||
dtCon.Columns.Add(new DataColumn("Codigo", typeof(string)));
|
||||
dtCon.Columns.Add(new DataColumn("Empleado", typeof(string)));
|
||||
DateTime CFecha = FechaI;
|
||||
while (FechaF > CFecha)
|
||||
{
|
||||
string Fecha = string.Format("{0:yyyyMMdd}", CFecha);
|
||||
string FechaCol = string.Format("{0:dd-MM-yyyy}", CFecha);
|
||||
dtCon.Columns.Add(new DataColumn(FechaCol, typeof(string)) { });
|
||||
CFecha = CFecha.AddDays(1);
|
||||
}
|
||||
using (ClsNominas objnom = new ClsNominas())
|
||||
{
|
||||
if (objnom.GetchecadorAdistencia(FechaI, FechaF, UsuarioActual.CveEmpresa))
|
||||
{
|
||||
DataTable dtASis = objnom.DTSetResultados.Tables[0];
|
||||
dtper = objnom.DTSetResultados.Tables[1];
|
||||
foreach (DataRow item in dtper.Rows)
|
||||
{
|
||||
DataRow drow = dtCon.NewRow();
|
||||
drow["Codigo"] = item["Codigo"];
|
||||
drow["Empleado"] = item["NombreCompleto"];
|
||||
CFecha = FechaI;
|
||||
while (FechaF > CFecha)
|
||||
{
|
||||
int Fecha = string.Format("{0:yyyyMMdd}", CFecha).ToEntero();
|
||||
string FechaCol = string.Format("{0:dd-MM-yyyy}", CFecha);
|
||||
string TipoAsis = "(Faltó)";
|
||||
DataRow drfec = dtASis.FiltroPrimero(string.Format("CvePersonal={0} AND Agrupador ={1}", item["CvePersonal"], Fecha), "Salida");
|
||||
if (drfec != null)
|
||||
{
|
||||
DataTable dtx = dtASis.FiltraParametros(string.Format("CvePersonal={0} AND Agrupador ={1}", item["CvePersonal"], Fecha), "Salida");
|
||||
|
||||
|
||||
string asistencia2 = "";
|
||||
string Horas2 = "";
|
||||
if (dtx.Rows.Count > 1)
|
||||
{
|
||||
Horas2 = drfec["Horas"].ToString();
|
||||
DataRow drf = dtx.Rows[1];
|
||||
asistencia2 = "<i class='fa fa-check-square' style=\"color:green;\"></i>";
|
||||
TipoAsis = drf["TipoAsistencia"].ToString();
|
||||
switch (drfec["Tipo"].ToString().ToEntero())
|
||||
{
|
||||
case 1:
|
||||
asistencia2 = "<i class='fa fa-check-square' style=\"color:green;\"></i>";
|
||||
break;
|
||||
case 2:
|
||||
asistencia2 = "<i class='fa fa-clock-o' style=\"color:orange;\" aria-hidden='true'></i>";
|
||||
break;
|
||||
case 3:
|
||||
asistencia2 = "<i class='fa fa-clock-o' style=\"color:orange;\" aria-hidden='true'></i>";
|
||||
break;
|
||||
case 4:
|
||||
asistencia2 = "<i class='fa fa-clock-o' style=\"color:red;\" aria-hidden='true'></i>";
|
||||
break;
|
||||
case 5:
|
||||
asistencia2 = "<i class='fa fa-clock-o' style=\"color:red;\" aria-hidden='true'></i>";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
string asistencia = "<i class='fa fa-check-square' style=\"color:green;\"></i>";
|
||||
TipoAsis = drfec["TipoAsistencia"].ToString();
|
||||
switch (drfec["Tipo"].ToString().ToEntero())
|
||||
{
|
||||
case 1:
|
||||
asistencia = "<i class='fa fa-check-square' style=\"color:green;\"></i>";
|
||||
break;
|
||||
case 2:
|
||||
asistencia = "<i class='fa fa-clock-o' style=\"color:orange;\" aria-hidden='true'></i>";
|
||||
break;
|
||||
case 3:
|
||||
asistencia = "<i class='fa fa-clock-o' style=\"color:orange;\" aria-hidden='true'></i>";
|
||||
break;
|
||||
case 4:
|
||||
asistencia = "<i class='fa fa-clock-o' style=\"color:red;\" aria-hidden='true'></i>";
|
||||
break;
|
||||
case 5:
|
||||
asistencia = "<i class='fa fa-clock-o' style=\"color:red;\" aria-hidden='true'></i>";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
drow[FechaCol] = string.Format("<div style='display:inline-block'>{0}<br>{1}</div><div style='display:inline-block'>{2}<br>{3}</div>", asistencia, drfec["Horas"], asistencia2, Horas2);
|
||||
//drow[FechaCol] = string.Format("{0}<br>{1:HH}:{1:mm} - {2:HH}:{2:mm}", asistencia, drfec["Entrada"], drfec["Salida"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CFecha.DayOfWeek == DayOfWeek.Sunday)
|
||||
{
|
||||
drow[FechaCol] = "<i class='fa fa-sun-o' style=\"color:green;\"></i>";
|
||||
TipoAsis = "(Descanso)";
|
||||
}
|
||||
else
|
||||
{
|
||||
drow[FechaCol] = "<div style=\"color:red;\">❌</div>";
|
||||
}
|
||||
}
|
||||
drow[FechaCol] = string.Format("<div class\" Widthall \" onclick=\"OpenModal('{2}',{3}) \">{0}<br>{1}</div>", drow[FechaCol], TipoAsis, FechaCol, item["CvePersonal"]);
|
||||
//dtCon.Columns.Add(new DataColumn(FechaCol, typeof(string)));Widthall
|
||||
CFecha = CFecha.AddDays(1);
|
||||
}
|
||||
dtCon.Rows.Add(drow);
|
||||
}
|
||||
}
|
||||
}
|
||||
//dtCon.Columns.Add(new DataColumn("LabelValorP", typeof(string)));
|
||||
//dtCon.Columns.Add(new DataColumn("CveConceptoP", typeof(int)));
|
||||
//dtCon.Columns.Add(new DataColumn("ImporteP", typeof(double)));
|
||||
return dtCon;
|
||||
}
|
||||
protected void LnkConsultar_Click(object sender, EventArgs e)
|
||||
{
|
||||
DataTable dtCon = generateTable();
|
||||
GvNominas.DataSource = dtCon;
|
||||
GvNominas.DataBind();
|
||||
UpDatos.Update();
|
||||
}
|
||||
|
||||
protected void GvNominas_RowDataBound(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
|
||||
if (e.Row.RowType == DataControlRowType.DataRow)
|
||||
{
|
||||
for (int j = 0; j < e.Row.Cells.Count; j++)
|
||||
{
|
||||
string encoded = e.Row.Cells[j].Text;
|
||||
e.Row.Cells[j].Text = Context.Server.HtmlDecode(encoded);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void BtnOpenModal_Click(object sender, EventArgs e)
|
||||
{
|
||||
DateTime fechai = TxtFecha.Text.ToDateTime();
|
||||
DateTime fechaf = fechai.AddDays(1);
|
||||
int CvePersonal = TxtCvePersonal.Text.ToEntero();
|
||||
TxtFechalabel.Text = string.Format("{0:dd/MM/yyyy}", fechai);
|
||||
using (ClsRH objRH = new ClsRH())
|
||||
{
|
||||
if (objRH.PreAsistenciaRegistrosGet(fechai, fechaf, -1, UsuarioActual.Empresa.CveEmpresa))
|
||||
{
|
||||
GvDetalleDias.DataSource = objRH.DtResultados.FiltraParametros(string.Format("FechaRegistro >='{0:yyyy/MM/dd HH:mm}' AND FechaRegistro <='{1:yyyy/MM/dd HH:mm}' AND CvePersonal = {2}", fechai.AddHours(6), fechaf.AddHours(6), CvePersonal), "FechaRegistro");
|
||||
GvDetalleDias.DataBind();
|
||||
}
|
||||
DdlTipoAsistencias.Enabled = GvDetalleDias.Rows.Count > 0;
|
||||
if (objRH.GetAsistencias(CvePersonal, -1, -1, -1, -1, -1, fechai, fechai, UsuarioActual.CveEmpresa))
|
||||
{
|
||||
if (objRH.DtResultados.Rows.Count > 0)
|
||||
{
|
||||
DataRow dr = objRH.DtResultados.Rows[0];
|
||||
DdlTipoAsistencias.SelectedValueExist(dr["CveAsistenciasInasistencias"].ToString());
|
||||
DdlAsisSubProyecto.SelectedValueExist(dr["CveSubProyecto"].ToString());
|
||||
TxtPorPago.Text = dr["PorcentajePago"].ToString();
|
||||
TxtHorasDobles.Text = dr["HorasDobles"].ToString();
|
||||
TxtHorasTriples.Text = dr["HorasTriples"].ToString();
|
||||
DdlMotivoHoraExtra.SelectedValueExist(dr["CveMotivoHoraExtra"].ToString());
|
||||
TxtObservaciones.Text = dr["Observacion"].ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
DataRow drow = dtper.FiltroPrimero(string.Format("CvePersonal = {0}", CvePersonal));
|
||||
if(drow != null)
|
||||
{
|
||||
TxtCodigolabel.Text = drow["Codigo"].ToString();
|
||||
TxtEmpleadolabel.Text = drow["NombreCompleto"].ToString();
|
||||
}
|
||||
|
||||
UpDetallesDia.Update();
|
||||
|
||||
RegistraScript("$('#divDetallesDia').modal();");
|
||||
}
|
||||
|
||||
protected void BtnEstusAsistenciaModal_Click(object sender, EventArgs e)
|
||||
{
|
||||
DateTime fecha = TxtFecha.Text.ToDateTime();
|
||||
int CvePersonal = TxtCvePersonal.Text.ToEntero();
|
||||
|
||||
//int CvePersonal = TxtasiscvePersonal.Text.ToEntero();
|
||||
//DateTime fecha = TxtasisFecha.Text.ToDate();
|
||||
using (ClsRH objpersonal = new ClsRH())
|
||||
{
|
||||
|
||||
if (objpersonal.AddAsistencia(CvePersonal, -1, DdlAsisSubProyecto.SelectedValue.ToEntero(), fecha, DdlTipoAsistencias.SelectedValue.ToEntero(), TxtPorPago.Text.Trim().ToDouble(), TxtHorasDobles.Text.Trim().ToDouble(),
|
||||
TxtHorasTriples.Text.Trim().ToDouble(), DdlMotivoHoraExtra.SelectedValue.ToEntero(), TxtObservaciones.Text.Trim(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
|
||||
{
|
||||
//Alert(string.Format("se ha guardado la asistencia satisfactoriamente <br/>{0}<br/>{1:dd/MM/yyyy}", TxtPersonal.Text, TxtasisFecha.Text.ToDate()), TipoMensaje.ToastInformacion);
|
||||
Alert("Se ha guardado la asistencia satisfactoriamente");
|
||||
RegistraScript("$('#DModalModAsistencia').modal('hide');");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user