607 lines
29 KiB
C#
607 lines
29 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
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)
|
|
{
|
|
|
|
DdlTurno.DataSource = GlobalDTTurno.FiltraParametros("CveEmpresa = " + UsuarioActual.CveEmpresa);
|
|
DdlTurno.DataBind();
|
|
|
|
CargaTiposPeriodo();
|
|
TxtRpdFechaInicio.Text = string.Format("{0:dd/MM/yyyy}",DateTime.Now );
|
|
TxtRpdFechaFin.Text = string.Format("{0:dd/MM/yyyy}", DateTime.Now);
|
|
DdlTipoAsistencias.DataSource = GlobalDTAsistenciasInasistencias.FiltraParametros(string.Format("CveEmpresa = {0}", UsuarioActual.CveEmpresa));
|
|
DdlTipoAsistencias.DataBind();
|
|
|
|
|
|
using (ClsRH ObjPersonal = new ClsRH())
|
|
{
|
|
if (ObjPersonal.GetPersonal(-1, UsuarioActual.CveEmpresa))
|
|
{
|
|
DdlmcPersonal.DataSource = ObjPersonal.DtResultados;
|
|
DdlmcPersonal.DataBind();
|
|
}
|
|
}
|
|
DdlMotivoHoraExtra.DataSource = GlobalDTMotivosHorasExtras.FiltraParametros(string.Format("CveEmpresa = {0}", UsuarioActual.CveEmpresa));
|
|
DdlMotivoHoraExtra.DataBind();
|
|
cargaChecadores();
|
|
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(string salto = "<br/>")
|
|
{
|
|
DateTime FechaI = TxtRpdFechaInicio.Text.ToDateTime();
|
|
DateTime FechaF = TxtRpdFechaFin.Text.ToDateTime().AddDays(1);
|
|
DataTable dtCon = new DataTable();
|
|
dtCon.Columns.Add(new DataColumn("Codigo", typeof(string)));
|
|
dtCon.Columns.Add(new DataColumn("Empleado", typeof(string)));
|
|
string strasis = "<i class='fa fa-check-square' style=\"color:green;\"></i>";
|
|
string strdescanso = "<i class='fa fa-sun-o' style=\"color:green;\"></i>";
|
|
string strretardo = "<i class='fa fa-clock-o' style=\"color:orange;\" aria-hidden='true'></i>";
|
|
string strfaltaretardo = "<i class='fa fa-clock-o' style=\"color:red;\" aria-hidden='true'></i>";
|
|
string strfalta = "<div style=\"color:red;\">❌</div>";
|
|
|
|
if (salto == "\r\n")
|
|
{
|
|
strasis = "✅";
|
|
strdescanso = "🌣";
|
|
strretardo = "🕖";
|
|
strfaltaretardo = "❌";
|
|
strfalta = "--";
|
|
}
|
|
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.GetchecadorAsistencia(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);
|
|
if (DdlTipoVista.SelectedValue == "2")
|
|
{
|
|
DataTable Dtb = objnom.DTSetResultados.Tables[4];
|
|
StringBuilder str = new StringBuilder();
|
|
string oldstr = "";
|
|
string newstr = "";
|
|
foreach (DataRow dfechas in Dtb.Select(string.Format("Agrupador ={0} AND CvePersonal={1}", Fecha, item["CvePersonal"])))
|
|
{
|
|
newstr = string.Format("{0:HH}:{0:mm}{1}", dfechas["Fecha"], salto);
|
|
if (!oldstr.Equals(newstr))
|
|
{
|
|
str.Append(newstr);
|
|
}
|
|
oldstr = newstr;
|
|
}
|
|
drow[FechaCol] = str.ToString();
|
|
}
|
|
else
|
|
{
|
|
string TipoAsis = "--";
|
|
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 = "";
|
|
string HoraExtraPorAutorizar2 = "";
|
|
if (dtx.Rows.Count > 1)
|
|
{
|
|
DataRow drf = dtx.Rows[1];
|
|
asistencia2 = "<i class='fa fa-check-square' style=\"color:green;\"></i>";
|
|
TipoAsis = drf["TipoAsistencia"].ToString();
|
|
Horas2 = drf["Horas"].ToString();
|
|
HoraExtraPorAutorizar2 = drf["HoraExtraPorAutorizar"].ToString().ToEntero() > 0 ? string.Format("({0:0.##})", drf["HoraExtraPorAutorizar"]) : "";
|
|
switch (drf["Tipo"].ToString().ToEntero())
|
|
{
|
|
case 1:
|
|
asistencia2 = strasis;
|
|
break;
|
|
case 2:
|
|
asistencia2 = strretardo;
|
|
break;
|
|
case 3:
|
|
asistencia2 = strretardo;
|
|
break;
|
|
case 4:
|
|
asistencia2 = strfaltaretardo;
|
|
break;
|
|
case 5:
|
|
asistencia2 = strfaltaretardo;
|
|
break;
|
|
case 6:
|
|
asistencia2 = strfalta;
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
string asistencia = "<i class='fa fa-check-square' style=\"color:green;\"></i>";
|
|
TipoAsis = drfec["TipoAsistencia"].ToString();
|
|
string HoraExtraPorAutorizar = drfec["HoraExtraPorAutorizar"].ToString().ToEntero() > 0 ? string.Format("({0:0.##})", drfec["HoraExtraPorAutorizar"]) : "";
|
|
switch (drfec["Tipo"].ToString().ToEntero())
|
|
{
|
|
case 1:
|
|
asistencia = strasis;
|
|
break;
|
|
case 2:
|
|
asistencia = strretardo;
|
|
break;
|
|
case 3:
|
|
asistencia = strretardo;
|
|
break;
|
|
case 4:
|
|
asistencia = strfaltaretardo;
|
|
break;
|
|
case 5:
|
|
asistencia = strfaltaretardo;
|
|
break;
|
|
case 6:
|
|
asistencia = strfalta;
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
if (salto == "\r\n")
|
|
{
|
|
drow[FechaCol] = string.Format("{0}{1}", asistencia, asistencia2, salto);
|
|
//drow[FechaCol] = string.Format("{0}{6}{1}{2}{3}{6}{4}{5}", asistencia, drfec["Horas"], HoraExtraPorAutorizar, asistencia2, Horas2, HoraExtraPorAutorizar2, salto);
|
|
}
|
|
else
|
|
{
|
|
drow[FechaCol] = string.Format("<div style='display:inline-block'>{0}{6}{1}{2}</div><div style='display:inline-block'>{3}{6}{4}{5}</div>", asistencia, drfec["Horas"], HoraExtraPorAutorizar, asistencia2, Horas2, HoraExtraPorAutorizar2, salto);
|
|
}
|
|
//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] = strdescanso;
|
|
TipoAsis = "(Descanso)";
|
|
}
|
|
else
|
|
{
|
|
drow[FechaCol] = salto; // "<div style=\"color:red;\">❌</div>";
|
|
}
|
|
}
|
|
if (salto == "\r\n")
|
|
{
|
|
drow[FechaCol] = string.Format("{0}{4}{1}", drow[FechaCol], TipoAsis, FechaCol, item["CvePersonal"], salto);
|
|
}
|
|
else
|
|
{
|
|
drow[FechaCol] = string.Format("<div class\" Widthall \" onclick=\"OpenModal('{2}',{3}) \">{0}{4}{1}</div>", drow[FechaCol], TipoAsis, FechaCol, item["CvePersonal"], salto);
|
|
}
|
|
//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();
|
|
DateTime fechai = TxtRpdFechaInicio.Text.ToDateTime();
|
|
DateTime fechaf = TxtRpdFechaFin.Text.ToDateTime().AddDays(1);
|
|
using (ClsGenerales ObjGral = new ClsGenerales())
|
|
{
|
|
if (ObjGral.GetHistorialBitacora(-1, -1, -1, -1, -1, -1, -1, UsuarioActual.CveEmpresa, FechaInicio: fechai.ToString("yyyy/MM/dd"), FechaFin: fechaf.ToString("yyyy/MM/dd")))
|
|
{
|
|
//Alert("Entre");
|
|
GvBitacora.DataSource = ObjGral.DtResultados;
|
|
GvBitacora.DataBind();
|
|
}
|
|
|
|
}
|
|
/*
|
|
|
|
If CvePersonal > 0 Then
|
|
Dim ObjGral As New ClsGenerales()
|
|
If ObjGral.GetHistorialBitacora(-1, -1, -1, -1, -1, -1, -1, UsuarioActual.CveEmpresa, CvePersonal:=CvePersonal) Then
|
|
GvBitacora.DataSource = ObjGral.DtResultados
|
|
End If
|
|
ObjGral.Dispose()
|
|
GvBitacora.DataBind()
|
|
UpHistorialModificacion.Update()
|
|
End If
|
|
*/
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
}
|
|
private void cargaChecadores()
|
|
{
|
|
ClsRH ObjRH = new ClsRH();
|
|
if (ObjRH.GetChecadores(-1, UsuarioActual.CveEmpresa))
|
|
{
|
|
DdlChecador.DataSource = ObjRH.DtResultados;
|
|
}
|
|
ObjRH.Dispose();
|
|
DdlChecador.DataBind();
|
|
}
|
|
protected void BtnOpenModal_Click(object sender, EventArgs e)
|
|
{
|
|
DateTime fechai = TxtFecha.Text.ToDateTime();
|
|
DateTime fechaf = fechai.AddDays(1);
|
|
int CvePersonal = TxtCvePersonal.Text.ToEntero();
|
|
DataRow drow = dtper.FiltroPrimero(string.Format("CvePersonal = {0}", CvePersonal));
|
|
if (drow != null)
|
|
{
|
|
TxtCodigolabel.Text = drow["Codigo"].ToString();
|
|
TxtEmpleadolabel.Text = drow["NombreCompleto"].ToString();
|
|
DdlTurno.SelectedValueExist(drow["CveTurno"].ToString());
|
|
}
|
|
TxtFechalabel.Text = string.Format("{0:dd/MM/yyyy}", fechai);
|
|
DataTable dtTurno = GlobalDTTurno.FiltraParametros(string.Format("CveEmpresa = {0}", UsuarioActual.CveEmpresa));
|
|
|
|
using (ClsNominas objnom = new ClsNominas())
|
|
{
|
|
if (objnom.AsistenciaDetallePorTurnoGet(fechai, fechai, UsuarioActual.CveEmpresa, CvePersonal))
|
|
{
|
|
GvAsistenciaUp.DataSource = objnom.DTSetResultados.Tables[0];
|
|
GvAsistenciaUp.DataBind();
|
|
}
|
|
}
|
|
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();
|
|
LnkAgregarRegistro.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
LnkAgregarRegistro.Visible = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
UpDetallesDia.Update();
|
|
|
|
RegistraScript("$('#divDetallesDia').modal();");
|
|
}
|
|
|
|
|
|
protected void LnkAgregarRegistro_Click(object sender, EventArgs e)
|
|
{
|
|
DateTime fechaing = string.Format("{0:dd-MM-yyyy} {0:HH}:{0:mm}:{1:00}", TxtFechaIngreso.Text.ToDateTimeExcat(), TxtSegundos.Text.ToEntero()).ToDateTimeExcat("dd-MM-yyyy HH:mm:ss");
|
|
DateTime fechasal = string.Format("{0:dd-MM-yyyy} {0:HH}:{0:mm}:{1:00}", TxtFechaSalida.Text.ToDateTimeExcat(), TxtSegundosFechaSalida.Text.ToEntero()).ToDateTimeExcat("dd-MM-yyyy HH:mm:ss");
|
|
bool continuar = false;
|
|
List<RequestAddChecadorRegistro> items = new List<RequestAddChecadorRegistro>();
|
|
items.Add(new RequestAddChecadorRegistro() { CveChecador = DdlChecador.SelectedValue.ToEntero(), CvePersonal = DdlmcPersonal.SelectedValue.ToEntero(), ChecadorID = -1, Fecha = fechaing });
|
|
items.Add(new RequestAddChecadorRegistro() { CveChecador = DdlChecador.SelectedValue.ToEntero(), CvePersonal = DdlmcPersonal.SelectedValue.ToEntero(), ChecadorID = -1, Fecha = fechasal });
|
|
using (ClsRH objrh = new ClsRH())
|
|
{
|
|
objrh.IniciaTransacSQL();
|
|
if (objrh.AddChecadorRegistro(UsuarioActual.CveEmpresa, items))
|
|
{
|
|
continuar = true;
|
|
}
|
|
if (continuar)
|
|
{
|
|
objrh.Commit();
|
|
}
|
|
else
|
|
{
|
|
objrh.RollBack();
|
|
}
|
|
}
|
|
if (continuar)
|
|
{
|
|
|
|
using (ClsClaseBase objbase = new ClsClaseBase())
|
|
{
|
|
/*
|
|
|
|
INSERT INTO Gral_HistorialBitacora(CvePersonal,CveConceptoHistorialBitacora,Descripcion,Motivo,CveUsuario,CveEmpresa,Fecha,Actual)
|
|
SELECT CvePersonal, 384,'se ingreso asistencia manual','se ingreso asistencia manual',100,@CveEmpresa,MIN(CAST(Fecha AS DATE))
|
|
*/
|
|
objbase.runQuerystr(string.Format("INSERT INTO Gral_HistorialBitacora(CvePersonal,CveConceptoHistorialBitacora,Descripcion,Motivo,CveUsuario,CveEmpresa,Fecha,Actual)SELECT {0}, 384,'SE INGRESO ASISTENCIA MANUAL','SE INGRESO ASISTENCIA MANUAL',{3},{2},'{1:yyyy/MM/dd}','Asistió'",
|
|
DdlmcPersonal.SelectedValue.ToEntero(), fechaing, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario));
|
|
|
|
}
|
|
Alert(string.Format("La asistencia se a agregado ({0:dd-MM-yyyy HH:mm:ss}).", fechaing), ModExtensiones.TipoMensaje.ToastInformacion);
|
|
}
|
|
if (!chkcontinuarAgregando.Checked)
|
|
{
|
|
LnkConsultar_Click(null, null);
|
|
RegistraScript("$('#DivAgregarRegistro').modal('hide');");
|
|
}
|
|
}
|
|
|
|
protected void GvAsistenciaUp_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
//CveAsistenciaDetalle,CvePersonal,CveSubProyecto,CveProyecto,CveTurno,Fecha
|
|
int CveAsistenciasInasistencias = e.Row.DataKey("CveAsistenciasInasistencias").ToEntero();
|
|
int CveProyecto = e.Row.DataKey("CveProyecto").ToEntero();
|
|
int CveSubProyecto = e.Row.DataKey("CveSubProyecto").ToEntero();
|
|
DropDownList DdlTipoAsistenciasB = (DropDownList)e.Row.FindControl("DdlTipoAsistencias");
|
|
DropDownList DdlAsisProyectoB = (DropDownList)e.Row.FindControl("DdlAsisProyecto");
|
|
DropDownList DdlAsisSubProyectoB = (DropDownList)e.Row.FindControl("DdlAsisSubProyecto");
|
|
Label LblAsisProyectoB = (Label)e.Row.FindControl("LblAsisProyecto");
|
|
//Label LblAsisSubProyectoB = (Label)e.Row.FindControl("LblAsisSubProyecto");
|
|
Panel PnlProyectoB = (Panel)e.Row.FindControl("PnlProyecto");
|
|
|
|
DdlTipoAsistenciasB.DataSource = GlobalDTAsistenciasInasistencias.FiltraParametros(string.Format("CveEmpresa = {0}", UsuarioActual.CveEmpresa));
|
|
DdlTipoAsistenciasB.DataBind();
|
|
DdlTipoAsistenciasB.SelectedValueExist(CveAsistenciasInasistencias);
|
|
if (DdlTipoAsistenciasB.SelectedIndex == 0)
|
|
{
|
|
DdlTipoAsistenciasB.Enabled = false;
|
|
}
|
|
else
|
|
{
|
|
DdlTipoAsistenciasB.DataSource = GlobalDTAsistenciasInasistencias.FiltraParametros(string.Format("CveEmpresa = {0} AND CveAsistenciasInasistencias IN({1},{2})", UsuarioActual.CveEmpresa, DdlTipoAsistenciasB.Items[0].Value, DdlTipoAsistenciasB.SelectedValue));
|
|
DdlTipoAsistenciasB.DataBind();
|
|
DdlTipoAsistenciasB.Enabled = true;
|
|
}
|
|
/*
|
|
DdlAsisProyectoB.DataSource = DdlAsisProyecto.DataSource;
|
|
DdlAsisProyectoB.DataBind();
|
|
DdlAsisSubProyectoB.DataSource = DdlAsisSubProyecto.DataSource;
|
|
DdlAsisSubProyectoB.DataBind();
|
|
LblAsisProyectoB.Text = LblAsisProyecto.Text;
|
|
LblAsisSubProyectoB.Text = LblAsisSubProyecto.Text;
|
|
*/
|
|
|
|
CargarCentrosDeCosto(DdlAsisProyectoB, DdlAsisSubProyectoB, LblAsisProyectoB, LblAsisSubProyecto);
|
|
PnlProyectoB.Visible = PnlProyecto.Visible;
|
|
DdlAsisProyectoB.SelectedValueExist(CveProyecto);
|
|
DdlAsisSubProyectoB.SelectedValueExist(CveSubProyecto);
|
|
}
|
|
}
|
|
|
|
|
|
protected void BtnEstusAsistenciaModal_Click(object sender, EventArgs e)
|
|
{
|
|
bool continuar = true;
|
|
DateTime fecha = TxtFecha.Text.ToDateTime();
|
|
int CvePersonal = TxtCvePersonal.Text.ToEntero();
|
|
List<RequestUpAsistenciaDetalle> registros = new List<RequestUpAsistenciaDetalle>();
|
|
int CveTurnoNEW = DdlTurno.SelectedValue.ToEntero();
|
|
using (ClsClaseBase objbase = new ClsClaseBase())
|
|
{
|
|
objbase.runQuerystr(string.Format("UPDATE RH_Personal SET CveTurno={1} WHERE CvePersonal ={0}", CvePersonal, CveTurnoNEW));
|
|
|
|
}
|
|
foreach (GridViewRow row in GvAsistenciaUp.Rows)
|
|
{
|
|
int CveTurno = row.DataKey("CveTurno").ToEntero();
|
|
string Fecha = row.DataKey("Fecha");
|
|
int CveAsistenciaDetalle = row.DataKey("CveAsistenciaDetalle").ToEntero();
|
|
int CveAsistenciasInasistencias = row.DataKey("CveAsistenciasInasistencias").ToEntero();
|
|
int CveProyecto = row.DataKey("CveProyecto").ToEntero();
|
|
int CveSubProyecto = row.DataKey("CveSubProyecto").ToEntero();
|
|
DropDownList DdlTipoAsistenciasB = (DropDownList)row.FindControl("DdlTipoAsistencias");
|
|
DropDownList DdlAsisProyectoB = (DropDownList)row.FindControl("DdlAsisProyecto");
|
|
DropDownList DdlAsisSubProyectoB = (DropDownList)row.FindControl("DdlAsisSubProyecto");
|
|
TextBox TxtMotivo = (TextBox)row.FindControl("TxtMotivo");
|
|
RequestUpAsistenciaDetalle obj = new RequestUpAsistenciaDetalle();
|
|
obj.CveAsistenciaDetalle = CveAsistenciaDetalle;
|
|
obj.CveAsistenciasInasistencias = DdlTipoAsistenciasB.SelectedValue.ToEntero();
|
|
obj.CveSubProyecto = DdlAsisSubProyectoB.SelectedValue.ToEntero();
|
|
obj.CvePersonal = CvePersonal;
|
|
obj.Fecha = fecha;
|
|
obj.Motivo = TxtMotivo.Text.Trim();
|
|
if (CveTurno != CveTurnoNEW)
|
|
{
|
|
using (ClsClaseBase objbase = new ClsClaseBase())
|
|
{
|
|
objbase.runQuerystr(string.Format("UPDATE RH_PersonalAsistenciasDetalle SET CveTurno={1} WHERE CveAsistenciaDetalle ={0}", CveAsistenciaDetalle, CveTurnoNEW));
|
|
objbase.runQuerystr(string.Format("UPDATE D SET CveTurno={1} FROM RH_PersonalAsistencias A INNER JOIN RH_PersonalAsistenciasDetalle D ON D.CveAsistencia =A.CveAsistencia AND D.CveTurno = {2} WHERE A.Fecha > '{0}' AND A.CvePersonal ={3}", Fecha, CveTurnoNEW, CveTurno, CvePersonal));
|
|
|
|
}
|
|
}
|
|
if (obj.Motivo.Length == 0 && CveAsistenciasInasistencias != obj.CveAsistenciasInasistencias)
|
|
{
|
|
continuar = false;
|
|
break;
|
|
}
|
|
registros.Add(obj);
|
|
}
|
|
if (continuar)
|
|
{
|
|
using (ClsRH objRH = new ClsRH())
|
|
{
|
|
if (objRH.UpAsistenciaDetalle(UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, registros))
|
|
{
|
|
Alert("Se ha guardado la asistencia satisfactoriamente");
|
|
RegistraScript("$('#divDetallesDia').modal('hide');");
|
|
LnkConsultar_Click(null, null);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
Alert("El campo motivo es requerido favor de llenarlo", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
//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);
|
|
|
|
|
|
// }
|
|
//}
|
|
}
|
|
|
|
protected void LnkFormato_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
DataTable dtCon = generateTable("\r\n");
|
|
|
|
|
|
ClosedXML.Excel.XLWorkbook wb = new ClosedXML.Excel.XLWorkbook();
|
|
var libro = wb.AddWorksheet(dtCon, "Asistencia");
|
|
|
|
//string strinicio;
|
|
//string strfin;
|
|
//ClosedXML.Excel.IXLFontBase fini;
|
|
//for (int r = 2; r < dtCon.Rows.Count + 2; r++)
|
|
//{
|
|
// for (int c = 3; c < dtCon.Columns.Count + 1; c++)
|
|
// {
|
|
// var ccell = libro.Cell(r, c);
|
|
|
|
// if (ccell.Value.ToString().Substring(0, 1) != "")
|
|
// {
|
|
// //ccell.RichText.Substring(0, 1).SetFontColor(ClosedXML.Excel.XLColor.Green);
|
|
// strinicio = ccell.Value.ToString().Substring(0, 1);
|
|
// switch (strinicio)
|
|
// {
|
|
// case "✅":
|
|
// //ccell.RichText.Substring(0, 1).SetFontColor(ClosedXML.Excel.XLColor.Green);
|
|
// //ccell.RichText.AddText(ccell.RichText);
|
|
// //ClosedXML.Excel.IXLFontBase ffin = new ClosedXML.Excel.XLFontBase();
|
|
// ccell.RichText.SetFontColor(ClosedXML.Excel.XLColor.Green);
|
|
// break;
|
|
// case "🌣":
|
|
// //ccell.RichText.Substring(0, 1).SetFontColor(ClosedXML.Excel.XLColor.Green);
|
|
// ccell.RichText.SetFontColor(ClosedXML.Excel.XLColor.Green);
|
|
// break;
|
|
// case "🕖":
|
|
// //ccell.RichText.Substring(0, 1).SetFontColor(ClosedXML.Excel.XLColor.Orange);
|
|
// ccell.RichText.SetFontColor(ClosedXML.Excel.XLColor.Orange);
|
|
// break;
|
|
// case "❌":
|
|
// //ccell.RichText.Substring(0, 1).SetFontColor(ClosedXML.Excel.XLColor.Red);
|
|
// ccell.RichText.SetFontColor(ClosedXML.Excel.XLColor.Red);
|
|
// break;
|
|
// default:
|
|
// break;
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
//}
|
|
|
|
libro.Tables.FirstOrDefault().ShowAutoFilter = false;
|
|
libro.SheetView.Freeze(1, 2);
|
|
libro.ColumnsUsed().AdjustToContents();
|
|
libro.Range(1, 3, dtCon.Rows.Count, dtCon.Columns.Count).Style.Alignment.Horizontal = ClosedXML.Excel.XLAlignmentHorizontalValues.Center;
|
|
|
|
|
|
|
|
System.IO.Stream fs = new System.IO.MemoryStream();
|
|
wb.SaveAs(fs);
|
|
fs.Position = 0;
|
|
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
|
|
using (System.IO.Stream input = fs)
|
|
|
|
{
|
|
input.CopyTo(memoryStream);
|
|
}
|
|
memoryStream.Position = 0;
|
|
|
|
Response.Clear();
|
|
Response.Buffer = true;
|
|
|
|
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
Response.AddHeader("content-disposition", string.Format("attachment;filename={0} del {1} al {2}.xlsx", "Asistencia", TxtRpdFechaInicio.Text.Replace("/", "-"), TxtRpdFechaFin.Text.Replace("/", "-")));
|
|
Response.BinaryWrite(memoryStream.ToArray());
|
|
Response.End();
|
|
}
|
|
} |