// MODO HORIZONTAL private void ReporteHorizontal() { rrhh_listaasistenciaBL BL = new rrhh_listaasistenciaBL(); tb_rrhh_listadeasistencia BE = new tb_rrhh_listadeasistencia(); BE.empresaid = Session["ssEmpresaID"].ToString(); BE.filtro = "1"; BE.FECH1 = Convert.ToDateTime(FECH1.Text); BE.FECH2 = Convert.ToDateTime(FECH2.Text); try { DataTable dt = new DataTable(); dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0]; StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); HtmlTextWriter htw = new HtmlTextWriter(sw); Page page = new Page(); HtmlForm form = new HtmlForm(); page.EnableEventValidation = false; page.DesignerInitialize(); htw.Write("<table>"); htw.Write("<tr>"); htw.Write("<td></td>"); htw.Write("</tr>"); htw.Write("</table>"); htw.Write("<table border='1' style='font:Tahoma; font-size:12px;'>"); htw.Write("<tr style='color: #FFFFFF; font-weight: bold; background-color:#006699;'>"); htw.Write("<td colspan='2' rowspan='2' align='center'> </td>"); htw.Write("<td colspan='5' rowspan='2' align='center' style='font-size:18px;'><strong>LISTADO DE ASISTENCIAS DIARIAS</strong></td>"); htw.Write("<td colspan='3' rowspan='2' align='center'> </td>"); htw.Write("</tr>"); htw.Write("</table>"); htw.Write("<table style='font:Tahoma; font-size:13px;'>"); htw.Write("<tr>"); htw.Write("<td></td>"); htw.Write("</tr>"); htw.Write("<tr>"); htw.Write("<td colspan='10'><strong> DEL:</strong> [" + FECH1.Text.ToString() + "] <strong>AL:</strong> [" + FECH2.Text.ToString() + "]</td>"); htw.Write("</tr>"); htw.Write("<tr>"); htw.Write("<td></td>"); htw.Write("</tr>"); htw.Write("</table>"); foreach (DataRow dr in dt.Rows) { String t_id = Convert.ToString(dt.Rows[0]["IDCC2"].ToString()); String t_nom = Convert.ToString(dt.Rows[0]["NBCC2"].ToString()); if (Equivalencias.Left(IDCC1.Text, 2).Trim() == "**") { BE.IDCC1 = ""; } else { BE.IDCC1 = Equivalencias.Left(IDCC1.Text, 2).Trim(); } BE.IDCC2 = dr["IDCC2"].ToString(); BE.filtro = "2"; BE.FECH1 = Convert.ToDateTime(FECH1.Text); BE.FECH2 = Convert.ToDateTime(FECH2.Text); DataTable dt2 = new DataTable(); dt2 = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0]; if (dt2.Rows.Count > 0) { htw.Write("<table border='1'style='font:Tahoma; font-size:12px;'>"); htw.Write("<tr>"); htw.Write("<td colspan='10'><strong> AREA MATRIZ:</strong> [" + dr["NBCC2"].ToString() + "]</td>"); htw.Write("</tr>"); htw.Write("<tr style='color: #FFFFFF; font-weight: bold; background-color:#006699;'>"); htw.Write("<td width='200' align='center'>DNI</td>"); htw.Write("<td width='250' align='center'>TRABAJADOR</td>"); htw.Write("<td width='150' align='center'>DIA 01</td>"); htw.Write("<td width='150' align='center'>DIA 02</td>"); htw.Write("<td width='150' align='center'>DIA 03</td>"); htw.Write("<td width='150' align='center'>DIA 04</td>"); htw.Write("<td width='150' align='center'>DIA 05</td>"); htw.Write("<td width='150' align='center'>DIA 06</td>"); htw.Write("<td width='150' align='center'>DIA 07</td>"); htw.Write("<td width='150' align='center'>DIA 08</td>"); htw.Write("<td width='150' align='center'>DIA 09</td>"); htw.Write("<td width='150' align='center'>DIA 10</td>"); htw.Write("<td width='150' align='center'>DIA 11</td>"); htw.Write("<td width='150' align='center'>DIA 12</td>"); htw.Write("<td width='150' align='center'>DIA 13</td>"); htw.Write("<td width='150' align='center'>DIA 14</td>"); htw.Write("<td width='150' align='center'>DIA 15</td>"); htw.Write("<td width='150' align='center'>DIA 16</td>"); htw.Write("<td width='150' align='center'>DIA 17</td>"); htw.Write("<td width='150' align='center'>DIA 18</td>"); htw.Write("<td width='150' align='center'>DIA 19</td>"); htw.Write("<td width='150' align='center'>DIA 20</td>"); htw.Write("<td width='150' align='center'>DIA 21</td>"); htw.Write("<td width='150' align='center'>DIA 22</td>"); htw.Write("<td width='150' align='center'>DIA 23</td>"); htw.Write("<td width='150' align='center'>DIA 24</td>"); htw.Write("<td width='150' align='center'>DIA 25</td>"); htw.Write("<td width='150' align='center'>DIA 26</td>"); htw.Write("<td width='150' align='center'>DIA 27</td>"); htw.Write("<td width='150' align='center'>DIA 28</td>"); htw.Write("<td width='150' align='center'>DIA 29</td>"); htw.Write("<td width='150' align='center'>DIA 30</td>"); htw.Write("<td width='150' align='center'>DIA 31</td>"); htw.Write("</tr>"); foreach (DataRow dr2 in dt2.Rows) { htw.Write("<tr>"); htw.Write("<td align='center' class='textmode'>" + dr2["DDNNI"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["NOMBS"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D1"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D2"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D3"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D4"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D5"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D6"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D7"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D8"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D9"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D10"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D11"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D12"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D13"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D14"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D15"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D16"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D17"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D18"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D19"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D20"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D21"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D22"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D23"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D24"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D25"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D26"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D27"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D28"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D29"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D30"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr2["D31"].ToString().Trim() + "</td>"); htw.Write("</tr>"); } htw.Write("</table>"); htw.Write("<table>"); htw.Write("<tr>"); htw.Write("<td></td>"); htw.Write("</tr>"); htw.Write("<tr>"); htw.Write("<td></td>"); htw.Write("</tr>"); htw.Write("</table>"); } } page.RenderControl(htw); string style = @"<style> .textmode { mso-number-format:\@; } .intmode { mso-number-format:'0'; } .decmode { mso-number-format:'\#\,\#\#0\.00'; }</style>"; Response.Clear(); Response.Buffer = true; Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("Content-Disposition", "attachment;filename=Lista_Asistencias.xls"); Response.Charset = "UTF-8"; Response.ContentEncoding = Encoding.Default; // Escribe estilo Response.Write(style); Response.Write(sb.ToString()); Response.End(); //HttpContext.Current.ApplicationInstance.CompleteRequest(); } catch (Exception ex) { this.ClientMessage(ex.Message); } }
protected void btnExcel2_Click(object sender, EventArgs e) { rrhh_listaasistenciaBL BL = new rrhh_listaasistenciaBL(); tb_rrhh_listadeasistencia BE = new tb_rrhh_listadeasistencia(); try { BE.FECH1 = Convert.ToDateTime(FECH1.Text); BE.FECH2 = Convert.ToDateTime(FECH2.Text); } catch (Exception ex) { FECH1.Text = Equivalencias.Left(System.DateTime.Now.Date.ToString(), 10); BE.FECH1 = Convert.ToDateTime(FECH1.Text); } try { BE.FECH2 = Convert.ToDateTime(FECH2.Text); } catch (Exception ex) { FECH2.Text = Equivalencias.Left(System.DateTime.Now.Date.ToString(), 10); BE.FECH2 = Convert.ToDateTime(FECH2.Text); } try { if (Equivalencias.IsNumeric(Equivalencias.Left(NOMBS.Text, 8).Trim())) { BE.DDNNI = Equivalencias.Left(NOMBS.Text, 8).Trim(); BE.NOMBS = ""; } else { BE.DDNNI = ""; BE.NOMBS = NOMBS.Text.ToUpper().Trim(); } } catch (Exception ex) { BE.DDNNI = ""; BE.NOMBS = NOMBS.Text.ToUpper().Trim(); } if (Equivalencias.Left(IDCC1.Text, 2).Trim() == "**") { BE.IDCC1 = ""; } else { BE.IDCC1 = Equivalencias.Left(IDCC1.Text, 2).Trim(); } if (Equivalencias.Left(IDCC2.Text, 3).Trim() == "***") { BE.IDCC2 = ""; } else { BE.IDCC2 = Equivalencias.Left(IDCC2.Text, 3).Trim(); } BE.flvis = false; //******** Exportando a Excel *********** try { DataTable dt = new DataTable(); dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0]; StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); HtmlTextWriter htw = new HtmlTextWriter(sw); Page page = new Page(); HtmlForm form = new HtmlForm(); //Se Deshabilita la validación de eventos, sólo asp.net 2 page.EnableEventValidation = false; //Se Realiza las inicializaciones de la instancia de la clase Page page.DesignerInitialize(); //*** GENERAR REPORTE htw.Write("<table width='10000' border='1' cellpadding='0' cellspacing='0' style='font:Tahoma; font-size:12px;'>"); htw.Write("<tr>"); htw.Write("<td width='79'> </td>"); htw.Write("<td width='205'> </td>"); htw.Write("<td colspan='6' rowspan='2' align='center' style='font-size:18px;'><strong>LISTADO DE ASISTENCIA</strong></td>"); htw.Write("<td width='72'> </td>"); htw.Write("<td width='76'> </td>"); htw.Write("</tr>"); htw.Write("<tr>"); htw.Write("<td> </td>"); htw.Write("<td> </td>"); htw.Write("<td> </td>"); htw.Write("<td> </td>"); htw.Write("</tr>"); htw.Write("<tr>"); htw.Write("<td colspan='10'><strong> DEL:</strong> [" + FECH1.Text.ToString() + "] <strong>AL:</strong> [" + FECH2.Text.ToString() + "]</td>"); htw.Write("</tr>"); htw.Write("<tr>"); htw.Write("<td colspan='10'> </td>"); htw.Write("</tr>"); htw.Write("<tr style='color: #FFFFFF; font-weight: bold; background-color:#006699;'>"); htw.Write("<td width='200' align='center'>FECHA</td>"); htw.Write("<td width='150' align='center'>AREA</td>"); htw.Write("<td width='200' align='center'>DNI</td>"); htw.Write("<td width='250' align='center'>TRABAJADOR</td>"); htw.Write("<td width='100' align='center'>DIA</td>"); htw.Write("<td width='150' align='center'>MARCA</td>"); htw.Write("<td width='150' align='center'>MIN/TRA</td>"); htw.Write("<td width='150' align='center'>GLOSA</td>"); htw.Write("<td width='150' align='center'>RANGO</td>"); htw.Write("</tr>"); foreach (DataRow dr in dt.Rows) { htw.Write("<tr>"); htw.Write("<td align='center'>" + dr["FECHA"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr["NBCC2"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr["DDNNI"].ToString().Trim() + "</td>"); htw.Write("<td class='textmode'>" + dr["NOMBS"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr["NBDIA"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr["MARCA"].ToString().Trim() + "</td>"); htw.Write("<td align='center'>" + dr["HorasTrabajadas"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr["GLOSA"].ToString().Trim() + "</td>"); htw.Write("<td align='center' class='textmode'>" + dr["RANGO"].ToString().Trim() + "</td>"); htw.Write("</tr>"); } htw.Write("</table>"); htw.Write("<table><tr><td></td></tr></table>"); page.RenderControl(htw); string style = @"<style> .textmode { mso-number-format:\@; } .intmode { mso-number-format:'0'; } .decmode { mso-number-format:'\#\,\#\#0\.00'; }</style>"; Response.Clear(); Response.Buffer = true; Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("Content-Disposition", "attachment;filename=ListaAsistencia.xls"); Response.Charset = "UTF-8"; Response.ContentEncoding = Encoding.Default; // Escribe estilo Response.Write(style); Response.Write(sb.ToString()); Response.End(); //HttpContext.Current.ApplicationInstance.CompleteRequest(); } catch (Exception ex) { this.ClientMessage(ex.Message); } }
private void GetList() { rrhh_listaasistenciaBL BL = new rrhh_listaasistenciaBL(); tb_rrhh_listadeasistencia BE = new tb_rrhh_listadeasistencia(); BE.empresaid = Session["ssEmpresaID"].ToString(); try { BE.FECH1 = Convert.ToDateTime(FECH1.Text); BE.FECH2 = Convert.ToDateTime(FECH2.Text); } catch (Exception ex) { FECH1.Text = Equivalencias.Left(System.DateTime.Now.Date.ToString(), 10); BE.FECH1 = Convert.ToDateTime(FECH1.Text); } try { BE.FECH2 = Convert.ToDateTime(FECH2.Text); } catch (Exception ex) { FECH2.Text = Equivalencias.Left(System.DateTime.Now.Date.ToString(), 10); BE.FECH2 = Convert.ToDateTime(FECH2.Text); } //.ANIO1 = Year(Convert.ToDateTime(FECH1.Text)) //.MESS1 = Month(Convert.ToDateTime(FECH1.Text)) //.DIAA1 = Day(Convert.ToDateTime(FECH1.Text)) //.ANIO2 = Year(Convert.ToDateTime(FECH2.Text)) //.MESS2 = Month(Convert.ToDateTime(FECH2.Text)) //.DIAA2 = Day(Convert.ToDateTime(FECH2.Text)) try { if (Equivalencias.IsNumeric(Equivalencias.Left(NOMBS.Text, 8).Trim())) { BE.DDNNI = Equivalencias.Left(NOMBS.Text, 8).Trim(); BE.NOMBS = ""; } else { BE.DDNNI = ""; BE.NOMBS = NOMBS.Text.ToUpper().Trim(); } } catch (Exception ex) { BE.DDNNI = ""; BE.NOMBS = NOMBS.Text.ToUpper().Trim(); } if (Equivalencias.Left(IDCC1.Text, 2).Trim() == "**") { BE.IDCC1 = ""; } else { BE.IDCC1 = Equivalencias.Left(IDCC1.Text, 2).Trim(); } if (Equivalencias.Left(IDCC2.Text, 3).Trim() == "***") { BE.IDCC2 = ""; } else { BE.IDCC2 = Equivalencias.Left(IDCC2.Text, 3).Trim(); } BE.flvis = false; try { GridView1.DataSource = BL.GetAll(Session["ssEmpresaID"].ToString(),BE); GridView1.DataBind(); GridView2.DataSource = BL.GetAll(Session["ssEmpresaID"].ToString(), BE); GridView2.DataBind(); } catch (Exception ex) { ClientMessage(ex.Message); } }
private void Update() { rrhh_listaasistenciaBL BL = new rrhh_listaasistenciaBL(); tb_rrhh_listadeasistencia BE = new tb_rrhh_listadeasistencia(); System.DateTime xfede = default(System.DateTime); System.DateTime xfeha = default(System.DateTime); System.DateTime xfech = default(System.DateTime); int dias = 0; int x = 0; xfede = Convert.ToDateTime(FECH1.Text); xfeha = Convert.ToDateTime(FECH2.Text); TimeSpan t3 = (xfeha - xfede); dias = Convert.ToInt32(t3.TotalDays); for (x = 0; x <= dias; x++) { xfech = xfede.AddDays(x); BE.FECHA = xfech; try { if (BL.Update2(Session["ssEmpresaID"].ToString(),BE)) { //mp.MostrarVentana("Actualizada fecha " & xfech.ToString, Page.ClientScript) } } catch (Exception ex) { ClientMessage(ex.Message); } } ClientMessage("Actualizacion terminada"); }