protected void gridBuscarEmpGral_RowDataBound(object sender, GridViewRowEventArgs e) { int bandera; string opcionBusquedaGral = DDBusquedaGral.SelectedItem.Text; if (opcionBusquedaGral.Trim() == "Terminado") // si es 2 es de estatus terminada { if (e.Row.RowType == DataControlRowType.DataRow) { string idempleado = e.Row.Cells[1].Text.ToString(); string opcioneva = opcestatus.SelectedItem.Text; // PARA SACAR la plantilla using (SqlConnection cnx2 = new SqlConnection(connectionString)) { cnx2.Open(); string query = "SELECT id_plantilla FROM EVA_PLANTILLAS WHERE (vigencia_plant = '1')"; SqlCommand cmd = new SqlCommand(query, cnx2); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { idplantilla.Text = dr["id_plantilla"].ToString(); Session["idplantilla"] = idplantilla.Text; } } } // cierre de la conn using (SqlConnection cnx = new SqlConnection(connectionString)) { cnx.Open(); string query2 = " SELECT a.id_eva as ideva, a.id_emp, a.id_jefe, a.id_categoria_emp, a.id_banda_emp, a.estatus, a.fecha_captura, " + " DATEDIFF(day, a.fecha_captura, GETDATE()) AS diastranscurridos, a.ptos_ftes as ptos, a.necesidades, a.comentarios " + " FROM EVA_C_EVALUACION as a INNER JOIN EVA_D_EVALUACION as d ON a.id_eva=d.id_eva " + " WHERE (a.id_emp = @noempleado) and d.id_plantilla=@idplantilla " + " ORDER BY a.fecha_captura"; SqlCommand cmd2 = new SqlCommand(query2, cnx); cmd2.Parameters.AddWithValue("@noempleado", idempleado); cmd2.Parameters.AddWithValue("@idplantilla", Session["idplantilla"]); SqlDataReader dr2 = cmd2.ExecuteReader(); if (dr2.HasRows) { while (dr2.Read()) { ideva.Text = dr2["ideva"].ToString(); estatus.Text = dr2["estatus"].ToString(); fecaptura.Text = dr2["fecha_captura"].ToString(); idbanda.Text = dr2["id_banda_emp"].ToString(); string noevaluacion = ideva.Text; // PARA SACAR ELPUNTAJE TOTAL using (SqlConnection cnx2 = new SqlConnection(connectionString)) { cnx2.Open(); string query = " SELECT SUM(calificacion_val_jefe) AS total_puntaje " + " FROM EVA_D_EVALUACION " + " WHERE (id_eva = '" + ideva.Text + "') "; SqlCommand cmd = new SqlCommand(query, cnx2); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { puntaje.Text = dr["total_puntaje"].ToString(); } } } // cierre de la conn // PARA SACAR PONDERACION using (SqlConnection cnx2 = new SqlConnection(connectionString)) { cnx2.Open(); string query = " SELECT desc_pond as descripcion_pondera " + " FROM EVA_PONDERA " + " WHERE ('" + puntaje.Text + "' BETWEEN min_pond AND max_pond) "; SqlCommand cmd = new SqlCommand(query, cnx2); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { ponderacion.Text = dr["descripcion_pondera"].ToString(); } } } // cierre de la conn // PARA SACAR BANDA using (SqlConnection cnx3 = new SqlConnection(connectionString)) { cnx3.Open(); string query3 = " SELECT id_banda, banda FROM EVA_BANDA where id_banda='" + idbanda.Text + "' "; SqlCommand cmd3 = new SqlCommand(query3, cnx3); SqlDataReader dr3 = cmd3.ExecuteReader(); if (dr3.HasRows) { while (dr3.Read()) { banda.Text = dr3["banda"].ToString(); } } } // cierre de la conn //---PARA SACAR la calificacion kpis using (SqlConnection cnx4 = new SqlConnection(connectionString)) { cnx4.Open(); string querykpi = " select {fn IFNULL(SUM(ponderacion_ind_jefe),0)} AS total_puntaje_indicadores " + " from EVA_C_EVALUACION as e, EVA_D_INDICADORES as d " + " where e.id_eva='" + ideva.Text + "' and e.estatus='2' and d.id_plantilla='" + idplantilla.Text + "' " + " and e.id_eva=d.id_eva "; SqlCommand cmd = new SqlCommand(querykpi, cnx4); SqlDataReader drk = cmd.ExecuteReader(); if (drk.HasRows) { while (drk.Read()) { total_valores_ind.Text = drk["total_puntaje_indicadores"].ToString(); } } else { total_valores_ind.Text = "No se pudo sacar el puntaje"; } } // cierre de la conn // para sacar la calificacion en Letra using (SqlConnection cnx5 = new SqlConnection(connectionString)) { cnx5.Open(); string query5 = " SELECT ponderacion_kpi, calificacion_kpi, descripcion_kpi " + " FROM EVA_C_CALIFICACION_KPI " + " WHERE ponderacion_kpi <= '" + total_valores_ind.Text + "' order by 1 "; SqlCommand cmd5 = new SqlCommand(query5, cnx5); SqlDataReader dr5 = cmd5.ExecuteReader(); if (dr5.HasRows) { while (dr5.Read()) { cal_indicador.Text = dr5["calificacion_kpi"].ToString(); } } else { //MensajeError("No se encontro Calificacion"); //return; } //DEVUELVE LOS VALORES DEL EBS this.capitalhumano = new NegocioCapitalHumano(); TablaEmpleados empleadosEbs = new TablaEmpleados(); try { List<Employee> listaEmpleados = capitalhumano.ListaEmpleados(idempleado, "%", "%", "%", "%", "%", "%", "%", "%", "%", "%", Convert.ToDateTime("01/Jan/1950"), Convert.ToDateTime("01/Jan/9999")); if (listaEmpleados != null) { nombreemp.Text = listaEmpleados[0].NombreCompleto.ToString(); } else { MensajeError(capitalhumano.Log); nombreemp.Text = idempleado; } } catch (Exception e3) { throw e3; } //empnec.Text = idempleado + "<br>" + nombreemp.Text; empnec.Text = nombreemp.Text; } if (int.Parse(estatus.Text) == 0) { e.Row.Cells[1].Text = "PENDIENTE DE TERMINAR EVALUACION"; e.Row.Cells[2].Text = "-"; e.Row.Cells[3].Text = "-"; e.Row.Cells[4].Text = "-"; e.Row.Cells[5].Text = "-"; e.Row.Cells[6].Text = "-"; e.Row.Cells[7].Text = "-"; e.Row.Cells[8].Text = "-"; e.Row.Cells[9].Text = "-"; e.Row.Cells[10].Text = "-"; bandera = 1; } if (int.Parse(estatus.Text) == 1) { e.Row.Cells[1].Text = "TERMINADA POR EMPLEADO FALTA EVALUACION JEFE INMEDIATO"; e.Row.Cells[2].Text = "-"; e.Row.Cells[3].Text = "-"; e.Row.Cells[4].Text = "-"; e.Row.Cells[5].Text = "-"; e.Row.Cells[6].Text = "-"; e.Row.Cells[7].Text = "-"; e.Row.Cells[8].Text = "-"; e.Row.Cells[9].Text = "-"; e.Row.Cells[10].Text = "-"; bandera = 1; } if (int.Parse(estatus.Text) == 2) { e.Row.Cells[0].Text = empnec.Text; e.Row.Cells[1].Text = "EVALUACION LIBERADA"; e.Row.Cells[2].Text = puntaje.Text; e.Row.Cells[3].Text = ponderacion.Text; e.Row.Cells[4].Text = cal_indicador.Text; e.Row.Cells[5].Text = fecaptura.Text; e.Row.Cells[6].Text = banda.Text; e.Row.Cells[7].Text = ideva.Text; //DEVUELVE LOS VALORES DEL EBS this.capitalhumano = new NegocioCapitalHumano(); TablaEmpleados empleadosEbs = new TablaEmpleados(); List<Employee> listaEmpleados = capitalhumano.ListaPersona(idempleado); if (listaEmpleados != null) { personaid.Text = listaEmpleados[0].Supervisor.ToString(); List<Employee> listaEmpleados2 = capitalhumano.ListaPersonaName(personaid.Text); if (listaEmpleados2 != null) { gerente.Text = listaEmpleados2[0].SupervisorName.ToString(); //TextBox1.Text = listaEmpleados2[0].SupervisorNoemp.ToString(); e.Row.Cells[8].Text = gerente.Text; bandera = 1; } else { MensajeErrorFiltros(capitalhumano.Log); } } else { MensajeErrorFiltros(capitalhumano.Log); } //================================PARA SACAR RESULTADO DE LA CALIFICION GRAL============ if ((Convert.ToInt32(puntaje.Text) >= 1) && ((Convert.ToInt32(puntaje.Text.Trim())) <= 22)) { if (cal_indicador.Text.Trim() == "A" || cal_indicador.Text.Trim() == "B") { calificacion_total.Text = "CRITICO"; } if (cal_indicador.Text.Trim() == "C-" || cal_indicador.Text.Trim() == "C") { calificacion_total.Text = "NECESITA CAPACITAR/ENTRENAR"; } if (cal_indicador.Text.Trim() == "C+" || cal_indicador.Text.Trim() == "D") { calificacion_total.Text = "NECESITA CAPACITAR/ENTRENAR"; } } else { if ((Convert.ToInt32(puntaje.Text) >= 23) && (Convert.ToInt32(puntaje.Text.Trim()) <= 50)) { if (cal_indicador.Text.Trim() == "A" || cal_indicador.Text.Trim() == "B") { calificacion_total.Text = "NECESITA CAPACITAR/ENTRENAR"; } if (cal_indicador.Text.Trim() == "C-" || cal_indicador.Text.Trim() == "C") { calificacion_total.Text = "RECONOCER Y DESARROLLAR"; } if (cal_indicador.Text.Trim() == "C+" || cal_indicador.Text.Trim() == "D") { calificacion_total.Text = "RECONOCER Y DESARROLLAR"; } } else { if ((Convert.ToInt32(puntaje.Text) >= 51) && (Convert.ToInt32(puntaje.Text.Trim()) <= 54)) { if (cal_indicador.Text.Trim() == "A" || cal_indicador.Text.Trim() == "B") { calificacion_total.Text = "NECESITA CAPACITAR/ENTRENAR"; } if (cal_indicador.Text.Trim() == "C-" || cal_indicador.Text.Trim() == "C") { calificacion_total.Text = "RECONOCER Y DESARROLLAR"; } if (cal_indicador.Text.Trim() == "C+" || cal_indicador.Text.Trim() == "D") { calificacion_total.Text = "RETENER"; } } } } e.Row.Cells[9].Text = calificacion_total.Text; //====================================================================================== LinkButton button = (LinkButton)e.Row.FindControl("LinkButton1"); //string desc = DataBinder.Eval(e.Row.DataItem, "employee_number").ToString(); string desc = ideva.Text; button.Attributes.Add("onclick", string.Format("userSelected('{0}')", desc)); } } } } } // if del grid del RowDataBound } else { // TODOS LOS EMPLEADOS CON ESTATUS TERMINADO if (opcionBusquedaGral.Trim() == "Pendiente") // si es 2 es de estatus terminada { if (e.Row.RowType == DataControlRowType.DataRow) { string idempleado = e.Row.Cells[1].Text.ToString(); string opcioneva = opcestatus.SelectedItem.Text; // PARA SACAR la plantilla using (SqlConnection cnx2 = new SqlConnection(connectionString)) { cnx2.Open(); string query = "SELECT id_plantilla FROM EVA_PLANTILLAS WHERE (vigencia_plant = '1')"; SqlCommand cmd = new SqlCommand(query, cnx2); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { idplantilla.Text = dr["id_plantilla"].ToString(); Session["idplantilla"] = idplantilla.Text; } } } // cierre de la conn using (SqlConnection cnx = new SqlConnection(connectionString)) { cnx.Open(); string query2 = " SELECT a.id_eva as ideva, a.id_emp, a.id_jefe, a.id_categoria_emp, a.id_banda_emp, a.estatus, a.fecha_captura, " + " DATEDIFF(day, a.fecha_captura, GETDATE()) AS diastranscurridos, a.ptos_ftes as ptos, a.necesidades, a.comentarios " + " FROM EVA_C_EVALUACION as a INNER JOIN EVA_D_EVALUACION as d ON a.id_eva=d.id_eva " + " WHERE (a.id_emp = @noempleado) and d.id_plantilla= @idplantilla " + " ORDER BY a.fecha_captura "; SqlCommand cmd2 = new SqlCommand(query2, cnx); cmd2.Parameters.AddWithValue("@noempleado", idempleado); cmd2.Parameters.AddWithValue("@idplantilla", Session["idplantilla"]); SqlDataReader dr2 = cmd2.ExecuteReader(); if (dr2.HasRows) { while (dr2.Read()) { ideva.Text = dr2["ideva"].ToString(); estatus.Text = dr2["estatus"].ToString(); fecaptura.Text = dr2["fecha_captura"].ToString(); idbanda.Text = dr2["id_banda_emp"].ToString(); string noevaluacion = ideva.Text; } } else { estatus.Text = "8"; } } string puestoregistrado = ""; string mesContratacion = ""; //DEVUELVE LOS VALORES DEL EBS this.capitalhumano = new NegocioCapitalHumano(); TablaEmpleados empleadosEbs = new TablaEmpleados(); try { List<Employee> listaEmpleados = capitalhumano.ListaEmpleados(idempleado, "%", "%", "%", "%", "%", "%", "%", "%", "%", "%", Convert.ToDateTime("01/Jan/1950"), Convert.ToDateTime("01/Jan/9999")); if (listaEmpleados != null) { nombreemp.Text = listaEmpleados[0].NombreCompleto.ToString(); ubicacion.Text = listaEmpleados[0].Ubicacion.ToString(); puesto.Text = listaEmpleados[0].Puesto.ToString(); fechacontratacion.Text = listaEmpleados[0].FechaContratacion.ToString(); mesContratacion = listaEmpleados[0].mesContratacion.ToString(); } else { MensajeError(capitalhumano.Log); } } catch (Exception e3) { throw e3; } //empnec.Text = idempleado + "<br>" + nombreemp.Text; empnec.Text = nombreemp.Text; // para revisar si tiene justificacion por no realizar la evaluacion para no mostrarlo using (SqlConnection cnx5 = new SqlConnection(connectionString)) { cnx5.Open(); string query5 = " SELECT id_observacion, id_plantilla, id_emp, observacion " + " FROM EVA_D_OBSERVACIONES " + " WHERE (id_emp = '" + idempleado + "') and id_plantilla='" + idplantilla.Text + "' "; SqlCommand cmd5 = new SqlCommand(query5, cnx5); SqlDataReader dr5 = cmd5.ExecuteReader(); if (dr5.HasRows) { while (dr5.Read()) { justificacion.Text = dr5["observacion"].ToString(); } } else { justificacion.Text = "-"; } } string puestosinno = ""; if (puesto.Text != string.Empty) { puestoregistrado = puesto.Text; string[] parts = puestoregistrado.Split('.'); puestosinno = parts[2]; } if (puestosinno == "RESIDENTE") { justificacion.Text = "RESIDENTE"; } //para quitar a los q tengan menos de 3 meses decimal antiguedadm; antiguedadm = 0; if (mesContratacion != string.Empty) { antiguedadm = Convert.ToDecimal(mesContratacion); } if ((antiguedadm <= 3) && (justificacion.Text == "-")) { justificacion.Text = "Antiguedad menos de 3 meses: " + fechacontratacion.Text; } ////DEVUELVE LOS VALORES DEL EBS //this.capitalhumano = new RecursosHumanos(); //TablaEmpleados empleadosEbs = new TablaEmpleados(); //try //{ // List<Employee> listaEmpleados = capitalhumano.ListaEmpleados(idempleado, "%", "%", "%", "%", "%", "%", "%", "%", "%", "%", Convert.ToDateTime("01/Jan/1950"), Convert.ToDateTime("01/Jan/9999")); // if (listaEmpleados != null) // { // nombreemp.Text = listaEmpleados[0].NombreCompleto.ToString(); // //supervisor.Text = listaEmpleados[0].SupervisorNoemp.ToString(); // List<Employee> listaEmpleados2 = capitalhumano.ListaPersonaName(personaid.Text); // if (listaEmpleados2 != null) // { // gerente.Text = listaEmpleados2[0].SupervisorName.ToString(); // //TextBox1.Text = listaEmpleados2[0].SupervisorNoemp.ToString(); // e.Row.Cells[8].Text = gerente.Text; // bandera = 1; // } // else // { // MensajeErrorFiltros(capitalhumano.Log); // } // } // else // { // MensajeError(capitalhumano.Log); // } //} //catch (Exception e3) //{ // throw e3; //} //empnec.Text = idempleado + "<br>" + nombreemp.Text; //empnec.Text = idempleado; if (int.Parse(estatus.Text) == 8) { e.Row.Cells[0].Text = empnec.Text; e.Row.Cells[1].Text = "NO HA REALIZADO LA EVALUACION"; e.Row.Cells[2].Text = ubicacion.Text; e.Row.Cells[3].Text = puesto.Text; e.Row.Cells[4].Text = fechacontratacion.Text; e.Row.Cells[5].Text = "-"; e.Row.Cells[6].Text = "-"; e.Row.Cells[7].Text = "-"; // e.Row.Cells[8].Text = "-"; //DEVUELVE LOS VALORES DEL EBS List<Employee> listaEmpleados = capitalhumano.ListaPersona(idempleado); if (listaEmpleados != null) { personaid.Text = listaEmpleados[0].Supervisor.ToString(); List<Employee> listaEmpleados2 = capitalhumano.ListaPersonaName(personaid.Text); if (listaEmpleados2 != null) { gerente.Text = listaEmpleados2[0].SupervisorName.ToString(); //TextBox1.Text = listaEmpleados2[0].SupervisorNoemp.ToString(); e.Row.Cells[8].Text = gerente.Text; bandera = 1; } else { MensajeErrorFiltros(capitalhumano.Log); } } else { MensajeErrorFiltros(capitalhumano.Log); } } if (int.Parse(estatus.Text) == 0) { e.Row.Cells[0].Text = empnec.Text; e.Row.Cells[1].Text = "PENDIENTE DE TERMINAR EVALUACION"; e.Row.Cells[2].Text = ubicacion.Text; e.Row.Cells[3].Text = puesto.Text; e.Row.Cells[4].Text = fechacontratacion.Text; e.Row.Cells[5].Text = "-"; e.Row.Cells[6].Text = "-"; e.Row.Cells[7].Text = "-"; //e.Row.Cells[8].Text = "-"; List<Employee> listaEmpleados = capitalhumano.ListaPersona(idempleado); if (listaEmpleados != null) { personaid.Text = listaEmpleados[0].Supervisor.ToString(); List<Employee> listaEmpleados2 = capitalhumano.ListaPersonaName(personaid.Text); if (listaEmpleados2 != null) { gerente.Text = listaEmpleados2[0].SupervisorName.ToString(); //TextBox1.Text = listaEmpleados2[0].SupervisorNoemp.ToString(); e.Row.Cells[8].Text = gerente.Text; bandera = 1; } else { MensajeErrorFiltros(capitalhumano.Log); } } else { MensajeErrorFiltros(capitalhumano.Log); } } if (int.Parse(estatus.Text) == 1) { e.Row.Cells[0].Text = empnec.Text; e.Row.Cells[1].Text = "TERMINADA POR EMPLEADO FALTA EVALUACION JEFE INMEDIATO"; e.Row.Cells[2].Text = ubicacion.Text; e.Row.Cells[3].Text = puesto.Text; e.Row.Cells[4].Text = fechacontratacion.Text; e.Row.Cells[5].Text = "-"; e.Row.Cells[6].Text = "-"; e.Row.Cells[7].Text = "-"; //e.Row.Cells[8].Text = "-"; List<Employee> listaEmpleados = capitalhumano.ListaPersona(idempleado); if (listaEmpleados != null) { personaid.Text = listaEmpleados[0].Supervisor.ToString(); List<Employee> listaEmpleados2 = capitalhumano.ListaPersonaName(personaid.Text); if (listaEmpleados2 != null) { gerente.Text = listaEmpleados2[0].SupervisorName.ToString(); //TextBox1.Text = listaEmpleados2[0].SupervisorNoemp.ToString(); e.Row.Cells[8].Text = gerente.Text; bandera = 1; } else { MensajeErrorFiltros(capitalhumano.Log); } } else { MensajeErrorFiltros(capitalhumano.Log); } } if (int.Parse(estatus.Text) == 2) { //e.Row.Cells[0].Text = empnec.Text; //e.Row.Cells[1].Text = "TERMINO CICLO DE LA EVALUACION "; //e.Row.Cells[2].Text = ubicacion.Text; //e.Row.Cells[3].Text = puesto.Text; //e.Row.Cells[4].Text = fechacontratacion.Text; //e.Row.Cells[5].Text = "-"; //e.Row.Cells[6].Text = "-"; //e.Row.Cells[7].Text = "-"; //e.Row.Cells[8].Text = ""; //e.Row.Cells[9].Text = ""; e.Row.Cells[0].Visible = false; e.Row.Cells[1].Visible = false; e.Row.Cells[2].Visible = false; e.Row.Cells[3].Visible = false; e.Row.Cells[4].Visible = false; e.Row.Cells[5].Visible = false; e.Row.Cells[6].Visible = false; e.Row.Cells[7].Visible = false; e.Row.Cells[8].Visible = false; e.Row.Cells[9].Visible = false; e.Row.Cells[10].Visible = false; } if (justificacion.Text != "-") //para empleados que no pudieron realizar su evaluacion { e.Row.Cells[1].Text = "NO REALIZO EVALUACION - OBSERVACION"; e.Row.Cells[2].Text = justificacion.Text; e.Row.Cells[3].Text = "-"; e.Row.Cells[4].Text = "-"; e.Row.Cells[5].Text = "-"; e.Row.Cells[6].Text = "-"; e.Row.Cells[7].Text = "-"; e.Row.Cells[8].Text = "-"; e.Row.Cells[9].Text = "-"; e.Row.Cells[10].Text = "-"; bandera = 1; } } } } }
public void InsertaNuevo(string noEmpleado) { IDEmpleado.Text = noEmpleado; this.capitalHumano = new NegocioCapitalHumano(); TablaEmpleados empleadosEbs = new TablaEmpleados(); try { List<Employee> listaEmpleados_insert = capitalHumano.ListaEmpleados(noEmpleado, "%", "%", "%", "%", "%", "%", "%", "%", "%", "%", Convert.ToDateTime("01/Jan/1950"), Convert.ToDateTime("01/Jan/9999")); TxtPuesto.Text = listaEmpleados_insert[0].Puesto.ToString(); TxtDepto.Text = listaEmpleados_insert[0].Organizacion.ToString(); Banda.Text = listaEmpleados_insert[0].Grado.ToString(); TxtEmpleado.Text = listaEmpleados_insert[0].NombreCompleto.ToString(); antiguedadmes.Text = listaEmpleados_insert[0].mesContratacion.ToString(); } catch (Exception e3) { throw e3; } string separarpto = TxtPuesto.Text; if (separarpto == null || separarpto == "") { MensajeError("No se encuentra asignado su Puesto o Depto en BD, consulte con Capital Humano"); return; } else { // Split separator string[] parts = separarpto.Split('.'); Depto.Text = parts[0]; Pto.Text = parts[1]; } TablaEmpleados empleadosEbs2 = new TablaEmpleados(); List<Employee> listaEmpleados2 = capitalHumano.ListaPersona(IDEmpleado.Text); //----para validar que no venga vacio los datos y marque error if (listaEmpleados2 == null) { TextBox1.Text = ""; MensajeError(capitalHumano.Log + " / o No se encuentra asignado su Jefe en BD, consulte con Capital Humano"); return; } else { TextBox1.Text = listaEmpleados2[0].Supervisor.ToString(); // antiguedadmes.Text = listaEmpleados2[0].mesContratacion.ToString(); } decimal antiguedadm; antiguedadm = Convert.ToDecimal(antiguedadmes.Text); if (antiguedadm <= 3) { MensajeError("No puedes realizar la AutoEvaluacion hasta que cumpla 3 Meses Laborando, consulte a Capital Humano"); return; } string connectionString = ConfigurationManager.ConnectionStrings["conexionAPPS"].ConnectionString; using (SqlConnection cnx = new SqlConnection(connectionString)) { cnx.Open(); string query = "SELECT id_plantilla FROM EVA_PLANTILLAS WHERE (vigencia_plant = '1')"; SqlCommand cmd = new SqlCommand(query, cnx); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { lbPlantilla.Text = dr["id_plantilla"].ToString(); } } else { //lbPlantilla.Text = "No se encontro plantilla autorizada"; lbPlantilla.Text = "1"; } } // cierre de la conn //--------------------------------PARA SACAR LA CATEGORIA POR LA BANDA lbidcategoria.Text = Banda.Text; using (SqlConnection cnx = new SqlConnection(connectionString)) { cnx.Open(); string query = "SELECT id_cat, banda, d_categoria FROM EVA_CATEGORIA " + "WHERE d_categoria= '" + Banda.Text + "' "; SqlCommand cmd = new SqlCommand(query, cnx); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { ban.Text = dr["banda"].ToString(); } } else { ban.Text = "No se encontro categoria"; } } //PARA SACAR LA BANDA using (SqlConnection cnxban = new SqlConnection(connectionString)) { cnxban.Open(); string queryb = "SELECT id_banda, banda FROM EVA_BANDA WHERE (id_banda = '" + ban.Text + "')"; SqlCommand cmdb = new SqlCommand(queryb, cnxban); SqlDataReader drb = cmdb.ExecuteReader(); if (drb.HasRows) { while (drb.Read()) { Banda.Text = drb["banda"].ToString(); } } } // cierre de la conn List<Employee> listaEmpleados3 = capitalHumano.ListaPersonaName(TextBox1.Text); if (listaEmpleados3 != null) { TxtJefeDir.Text = listaEmpleados3[0].SupervisorName.ToString(); lbl_id_empAutoriza.Text = listaEmpleados3[0].SupervisorNoemp.ToString(); } else { MensajeError(capitalHumano.Log + " NO se encuentra actualizado su Jefe en BD, consulte con Capital Humano"); return; } // ULTIMO FOLIO USADO using (SqlConnection cnx = new SqlConnection(ConfigurationManager.ConnectionStrings["conexionAPPS"].ToString())) { cnx.Open(); string query = "SELECT MAX(id_eva) AS ultimofolio FROM EVA_FOLIOS"; SqlCommand cmd = new SqlCommand(query, cnx); //cmd.Parameters.AddWithValue("@banda", Banda.Text); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { lbFolioeva.Text = dr["ultimofolio"].ToString(); } } else { lbFolioeva.Text = "No rows found"; } } // cierre de la conn SumaFolio(lbFolioeva.Text, 1); //INCREMENTO FOLIO lbFolioevanew.Text = SumaFolio(lbFolioeva.Text, 1); // para saber cual fue su ultima evaluacion o si es la primera vez que entra using (SqlConnection cnx = new SqlConnection(ConfigurationManager.ConnectionStrings["conexionAPPS"].ToString())) { cnx.Open(); string query = " SELECT distinct(c.id_eva) as eva, c.id_emp, c.id_jefe, c.id_categoria_emp, c.id_banda_emp, c.estatus, c.fecha_captura, " + " DATEDIFF(day, c.fecha_captura, GETDATE()) AS diastranscurridos , d.id_plantilla " + " FROM EVA_C_EVALUACION as c, EVA_D_EVALUACION as d " + " WHERE (c.id_emp = @noempleado) and c.id_eva=d.id_eva and d.id_plantilla= @idplantilla and c.estatus<>'3'" + " ORDER BY c.fecha_captura"; SqlCommand cmd = new SqlCommand(query, cnx); cmd.Parameters.AddWithValue("@noempleado", IDEmpleado.Text); cmd.Parameters.AddWithValue("@idplantilla", lbPlantilla.Text); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { diastranscurridos.Text = dr["diastranscurridos"].ToString(); idestatus.Text = dr["estatus"].ToString(); opcion.Text = "-"; int diastras = Convert.ToInt32(diastranscurridos.Text); } } else { opcion.Text = "nuevo"; int diastras = 0; } } // cierre de la conn if (opcion.Text == "nuevo") { // inserto // si es mayor crear una nueva evaluacion e insertar valores e indicadores en tabla detalles DatoEvaluacion DatEvaluacion = new DatoEvaluacion(); if (DatEvaluacion.InsertEvaluaciones(lbFolioevanew.Text, Convert.ToInt32(IDEmpleado.Text), Convert.ToInt32(lbl_id_empAutoriza.Text), lbidcategoria.Text, ban.Text, "1") > 0) { //inserto en tabla detalle los valores nuvoil primero saco los datos a consultar using (SqlConnection cnx = new SqlConnection(ConfigurationManager.ConnectionStrings["conexionAPPS"].ToString())) { cnx.Open(); string query = "SELECT a.c_seccion as seccion, a.c_valor as valor, a.c_comportamiento as comp " + "FROM EVA_D_VALORES AS a INNER JOIN EVA_C_VALORES AS b ON a.c_comportamiento = b.c_valor " + "WHERE a.c_banda = '" + ban.Text + "' and a.id_plantilla = '" + lbPlantilla.Text + "' "; SqlCommand cmd = new SqlCommand(query, cnx); cmd.Parameters.AddWithValue("@banda", Banda.Text); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { seccion.Text = dr["seccion"].ToString(); valor.Text = dr["valor"].ToString(); comportamiento.Text = dr["comp"].ToString(); DatoDeteva DatDeteva = new DatoDeteva(); if (DatDeteva.InsertDetEvaluacion(lbFolioevanew.Text, Convert.ToInt32(lbPlantilla.Text), seccion.Text, valor.Text, comportamiento.Text, 0) > 0) { //se ha insertado exitosamente } } } else { seccion.Text = "No hay seccion"; } } // cierre de la using } // del if de guardado de cabecera de evaluacion //ACTUALIZO EL FOLIO using (SqlConnection cnx2 = new SqlConnection(ConfigurationManager.ConnectionStrings["conexionAPPS"].ToString())) { cnx2.Open(); string query = "UPDATE EVA_FOLIOS set fecha=GETDATE(), idempleado='" + Convert.ToInt32(IDEmpleado.Text) + "', id_eva= '" + lbFolioevanew.Text + "'"; SqlCommand cmd = new SqlCommand(query, cnx2); SqlDataReader dr = cmd.ExecuteReader(); } } // del if del if (opcion.Text == "nuevo") //if (idestatus.Text == "0") //{ // using (SqlConnection cnx = new SqlConnection(ConfigurationManager.ConnectionStrings["conexionAPPS"].ToString())) // { // cnx.Open(); // string query2 = " SELECT id_eva as ideva, id_emp, id_jefe, id_categoria_emp, id_banda_emp, estatus, fecha_captura, " + // " DATEDIFF(day, fecha_captura, GETDATE()) AS diastranscurridos, ptos_ftes as ptos, necesidades, comentarios " + // " FROM EVA_C_EVALUACION " + // " WHERE (id_emp = @noempleado) " + // " ORDER BY fecha_captura"; // SqlCommand cmd2 = new SqlCommand(query2, cnx); // cmd2.Parameters.AddWithValue("@noempleado", IDEmpleado.Text); // SqlDataReader dr2 = cmd2.ExecuteReader(); // if (dr2.HasRows) // { // while (dr2.Read()) // { // foliopendiente.Text = dr2["ideva"].ToString(); // lbFolioevanew.Text = foliopendiente.Text; // } // } // } //} // del if (idestatus.Text=="0") { //----------- para insertar indicadores //inserto si es la primera vez que va capturar sino solo consulto los resultados using (SqlConnection cnx = new SqlConnection(ConfigurationManager.ConnectionStrings["conexionAPPS"].ToString())) { cnx.Open(); string query = " SELECT d.id_eva as ideva, d.id_plantilla as idplantilla, d.depto as depto, d.puesto as puesto, d.id_linea as idlinea, d.resultado_logrado as reslogrado, " + " d.ptos, d.ponderacion_ind as ponderacionind, c.descripcion_kpi as descripcion_kpi, c.unidad_medida as umedida, c.porcentaje_pondera as porcentaje_pondera, " + " c.meta_minima as meta_minima, c.meta_satisfactoria as meta_satisfactoria, c.meta_excelente as meta_excelente, d.calificacion_ind as calind " + " FROM EVA_D_INDICADORES as d, EVA_C_INDICADORES as c " + " WHERE left(d.depto,3)=left(c.depto,3) and left(d.puesto,3)=left(c.puesto,3) and d.id_plantilla=c.id_plantilla and " + " d.id_linea=c.id_linea and (d.id_eva = '" + lbFolioevanew.Text + "') and d.id_plantilla='" + lbPlantilla.Text + "' and " + " left(d.depto,3)='" + Depto.Text + "' and left(d.puesto,3)='" + Pto.Text + "' "; SqlCommand cmd = new SqlCommand(query, cnx); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { ban_existe_eva.Text = "1"; } } else { ban_existe_eva.Text = "0"; } } if (ban_existe_eva.Text == "0") { // busco los indicadores que le corresponde por su puesto y depto y plantilla cuando es la 1 vez using (SqlConnection cnx = new SqlConnection(ConfigurationManager.ConnectionStrings["conexionAPPS"].ToString())) { cnx.Open(); string query = " SELECT id_plantilla, depto, puesto, id_linea, descripcion_kpi, unidad_medida, porcentaje_pondera, meta_minima, meta_satisfactoria, meta_excelente " + " FROM EVA_C_INDICADORES " + " WHERE id_plantilla='" + lbPlantilla.Text + "' and " + " left(puesto,3)='" + Pto.Text + "' and left(depto,3)='" + Depto.Text + "' "; SqlCommand cmd = new SqlCommand(query, cnx); SqlDataReader dr2 = cmd.ExecuteReader(); if (dr2.HasRows) { while (dr2.Read()) { idlinea.Text = dr2["id_linea"].ToString(); desckpi.Text = dr2["descripcion_kpi"].ToString(); umedida.Text = dr2["unidad_medida"].ToString(); ppondera.Text = dr2["porcentaje_pondera"].ToString(); metaminima.Text = dr2["meta_minima"].ToString(); metasat.Text = dr2["meta_satisfactoria"].ToString(); metaexc.Text = dr2["meta_excelente"].ToString(); using (SqlConnection cnx2 = new SqlConnection(ConfigurationManager.ConnectionStrings["conexionAPPS"].ToString())) { cnx2.Open(); string query2 = " INSERT EVA_D_INDICADORES (id_eva, id_plantilla, depto, puesto, id_linea, fecha_captura_ind, resultado_logrado, ptos, ponderacion_ind, resultado_logrado_jefe, ptos_jefe, ponderacion_ind_jefe) " + " values ('" + lbFolioevanew.Text + "', '" + lbPlantilla.Text + "', '" + Depto.Text + "','" + Pto.Text + "', '" + idlinea.Text + "', GETDATE(), 0, 0, 0, 0, 0, 0 )"; SqlCommand cmd2 = new SqlCommand(query2, cnx2); SqlDataReader dr3 = cmd2.ExecuteReader(); //MensajeExito("Se ha guardado con Exito tu Evaluacion"); } } } else { MensajeError("No se puede insertar el detalle de indicador, revise con Capital Humano si tiene indicadores en su puesto"); return; } } } }
protected void gridBuscarEmp_RowDataBound(object sender, GridViewRowEventArgs e) { int bandera = 0; if (e.Row.RowType == DataControlRowType.DataRow) { string idempleado = e.Row.Cells[1].Text.ToString(); string opcioneva = opcestatus.SelectedItem.Text; // PARA SACAR la plantilla using (SqlConnection cnx2 = new SqlConnection(connectionString)) { cnx2.Open(); string query = "SELECT id_plantilla FROM EVA_PLANTILLAS WHERE (vigencia_plant = '1')"; SqlCommand cmd = new SqlCommand(query, cnx2); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { idplantilla.Text = dr["id_plantilla"].ToString(); Session["idplantilla"] = idplantilla.Text; } } } // cierre de la conn using (SqlConnection cnx = new SqlConnection(connectionString)) { cnx.Open(); string query2 = " SELECT a.id_eva as ideva, a.id_emp, a.id_jefe, a.id_categoria_emp, a.id_banda_emp, a.estatus, a.fecha_captura, " + " DATEDIFF(day, a.fecha_captura, GETDATE()) AS diastranscurridos, a.ptos_ftes as ptos, a.necesidades, a.comentarios " + " FROM EVA_C_EVALUACION as a INNER JOIN EVA_D_EVALUACION as d ON a.id_eva=d.id_eva " + " WHERE (a.id_emp = @noempleado) and d.id_plantilla=@idplantilla " + " ORDER BY a.fecha_captura"; SqlCommand cmd2 = new SqlCommand(query2, cnx); cmd2.Parameters.AddWithValue("@noempleado", idempleado); cmd2.Parameters.AddWithValue("@idplantilla", Session["idplantilla"]); SqlDataReader dr2 = cmd2.ExecuteReader(); if (dr2.HasRows) { while (dr2.Read()) { ideva.Text = dr2["ideva"].ToString(); estatus.Text = dr2["estatus"].ToString(); fecaptura.Text = dr2["fecha_captura"].ToString(); idbanda.Text = dr2["id_banda_emp"].ToString(); string noevaluacion = ideva.Text; // PARA SACAR ELPUNTAJE TOTAL using (SqlConnection cnx2 = new SqlConnection(connectionString)) { cnx2.Open(); string query = " SELECT SUM(calificacion_val_jefe) AS total_puntaje " + " FROM EVA_D_EVALUACION " + " WHERE (id_eva = '" + ideva.Text + "') and id_plantilla= '" + Session["idplantilla"] + "' "; SqlCommand cmd = new SqlCommand(query, cnx2); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { puntaje.Text = dr["total_puntaje"].ToString(); } } } // cierre de la conn // PARA SACAR PONDERACION using (SqlConnection cnx2 = new SqlConnection(connectionString)) { cnx2.Open(); string query = " SELECT desc_pond as descripcion_pondera " + " FROM EVA_PONDERA " + " WHERE ('" + puntaje.Text + "' BETWEEN min_pond AND max_pond) "; SqlCommand cmd = new SqlCommand(query, cnx2); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { ponderacion.Text = dr["descripcion_pondera"].ToString(); } } } // cierre de la conn // PARA SACAR BANDA using (SqlConnection cnx3 = new SqlConnection(connectionString)) { cnx3.Open(); string query3 = " SELECT id_banda, banda FROM EVA_BANDA where id_banda='" + idbanda.Text + "' "; SqlCommand cmd3 = new SqlCommand(query3, cnx3); SqlDataReader dr3 = cmd3.ExecuteReader(); if (dr3.HasRows) { while (dr3.Read()) { banda.Text = dr3["banda"].ToString(); } } } // cierre de la conn //---PARA SACAR la calificacion kpis using (SqlConnection cnx4 = new SqlConnection(connectionString)) { cnx4.Open(); string querykpi = " select {fn IFNULL(SUM(ponderacion_ind_jefe),0)} AS total_puntaje_indicadores " + " from EVA_C_EVALUACION as e, EVA_D_INDICADORES as d " + " where e.id_eva='" + ideva.Text + "' and e.estatus='2' and d.id_plantilla='" + idplantilla.Text + "' " + " and e.id_eva=d.id_eva "; SqlCommand cmd = new SqlCommand(querykpi, cnx4); SqlDataReader drk = cmd.ExecuteReader(); if (drk.HasRows) { while (drk.Read()) { total_valores_ind.Text = drk["total_puntaje_indicadores"].ToString(); } } else { total_valores_ind.Text = "No se pudo sacar el puntaje"; } } // cierre de la conn // para sacar la calificacion en Letra using (SqlConnection cnx5 = new SqlConnection(connectionString)) { cnx5.Open(); string query5 = " SELECT ponderacion_kpi, calificacion_kpi, descripcion_kpi " + " FROM EVA_C_CALIFICACION_KPI " + " WHERE ponderacion_kpi <= '" + total_valores_ind.Text + "' order by 1 "; SqlCommand cmd5 = new SqlCommand(query5, cnx5); SqlDataReader dr5 = cmd5.ExecuteReader(); if (dr5.HasRows) { while (dr5.Read()) { cal_indicador.Text = dr5["calificacion_kpi"].ToString(); } } else { //MensajeError("No se encontro Calificacion"); //return; } } if (int.Parse(estatus.Text) == 0) { e.Row.Cells[1].Text = "PENDIENTE DE TERMINAR EVALUACION"; e.Row.Cells[2].Text = "-"; e.Row.Cells[3].Text = "-"; e.Row.Cells[4].Text = "-"; e.Row.Cells[5].Text = "-"; e.Row.Cells[6].Text = "-"; e.Row.Cells[7].Text = "-"; e.Row.Cells[8].Text = "-"; e.Row.Cells[9].Text = "-"; e.Row.Cells[10].Text = "-"; bandera = 1; } if (int.Parse(estatus.Text) == 1) { e.Row.Cells[1].Text = "TERMINADA POR EMPLEADO FALTA EVALUACION JEFE INMEDIATO"; e.Row.Cells[2].Text = "-"; e.Row.Cells[3].Text = "-"; e.Row.Cells[4].Text = "-"; e.Row.Cells[5].Text = "-"; e.Row.Cells[6].Text = "-"; e.Row.Cells[7].Text = "-"; e.Row.Cells[8].Text = "-"; e.Row.Cells[9].Text = "-"; e.Row.Cells[10].Text = "-"; bandera = 1; } if (int.Parse(estatus.Text) == 2) { e.Row.Cells[1].Text = "EVALUACION LIBERADA"; e.Row.Cells[2].Text = puntaje.Text; e.Row.Cells[3].Text = ponderacion.Text; e.Row.Cells[4].Text = cal_indicador.Text; e.Row.Cells[5].Text = fecaptura.Text; e.Row.Cells[6].Text = banda.Text; e.Row.Cells[7].Text = ideva.Text; //DEVUELVE LOS VALORES DEL EBS this.capitalhumano = new NegocioCapitalHumano(); TablaEmpleados empleadosEbs = new TablaEmpleados(); List<Employee> listaEmpleados = capitalhumano.ListaPersona(idempleado); personaid.Text = listaEmpleados[0].Supervisor.ToString(); List<Employee> listaEmpleados2 = capitalhumano.ListaPersonaName(personaid.Text); gerente.Text = listaEmpleados2[0].SupervisorName.ToString(); //TextBox1.Text = listaEmpleados2[0].SupervisorNoemp.ToString(); e.Row.Cells[8].Text = gerente.Text; bandera = 1; //-------------------------------PARA SACAR LA CALIFICACION TOTAL----------------------- if ((Convert.ToInt32(puntaje.Text) >= 1) && ((Convert.ToInt32(puntaje.Text.Trim())) <= 22)) { if (cal_indicador.Text.Trim() == "A" || cal_indicador.Text.Trim() == "B") { calificacion_total.Text = "CRITICO"; } if (cal_indicador.Text.Trim() == "C-" || cal_indicador.Text.Trim() == "C") { calificacion_total.Text = "NECESITA CAPACITAR/ENTRENAR"; } if (cal_indicador.Text.Trim() == "C+" || cal_indicador.Text.Trim() == "D") { calificacion_total.Text = "NECESITA CAPACITAR/ENTRENAR"; } } else { if ((Convert.ToInt32(puntaje.Text) >= 23) && (Convert.ToInt32(puntaje.Text.Trim()) <= 50)) { if (cal_indicador.Text.Trim() == "A" || cal_indicador.Text.Trim() == "B") { calificacion_total.Text = "NECESITA CAPACITAR/ENTRENAR"; } if (cal_indicador.Text.Trim() == "C-" || cal_indicador.Text.Trim() == "C") { calificacion_total.Text = "RECONOCER Y DESARROLLAR"; } if (cal_indicador.Text.Trim() == "C+" || cal_indicador.Text.Trim() == "D") { calificacion_total.Text = "RECONOCER Y DESARROLLAR"; } } else { if ((Convert.ToInt32(puntaje.Text) >= 51) && (Convert.ToInt32(puntaje.Text.Trim()) <= 54)) { if (cal_indicador.Text.Trim() == "A" || cal_indicador.Text.Trim() == "B") { calificacion_total.Text = "NECESITA CAPACITAR/ENTRENAR"; } if (cal_indicador.Text.Trim() == "C-" || cal_indicador.Text.Trim() == "C") { calificacion_total.Text = "RECONOCER Y DESARROLLAR"; } if (cal_indicador.Text.Trim() == "C+" || cal_indicador.Text.Trim() == "D") { calificacion_total.Text = "RETENER"; } } } } e.Row.Cells[9].Text = calificacion_total.Text; LinkButton button = (LinkButton)e.Row.FindControl("LinkButton1"); //string desc = DataBinder.Eval(e.Row.DataItem, "employee_number").ToString(); string desc = ideva.Text; //button.Attributes.Add("onclick", string.Format("userSelected('{0}')", desc)); } } } } if (bandera == 0) { e.Row.Cells[1].Text = "NO HA REALIZADO LA EVALUACION"; e.Row.Cells[1].ForeColor = System.Drawing.Color.Red; e.Row.Cells[2].Text = "-"; e.Row.Cells[3].Text = "-"; e.Row.Cells[4].Text = "-"; e.Row.Cells[5].Text = "-"; e.Row.Cells[6].Text = "-"; e.Row.Cells[7].Text = "-"; e.Row.Cells[8].Text = "-"; e.Row.Cells[9].Text = "-"; } //---------------------------------------------------------------------------------------------------------------------------------------------------------- } }
protected void Page_Load(object sender, EventArgs e) { ValidadSession(); TxtEmpleado.Text = (string)(Session["Nombre"]); TxtPuesto.Text = (string)(Session["Puesto"]); IDEmpleado.Text = (string)(Session["ClaveJDE"]); lbFolioeva.Text = Request.QueryString[0]; //DEVUELVE LOS VALORES DEL EBS this.capitalHumano = new NegocioCapitalHumano(); TablaEmpleados empleadosEbs = new TablaEmpleados(); try { List<Employee> listaEmpleados = capitalHumano.ListaEmpleados(IDEmpleado.Text, "%", "%", "%", "%", "%", "%", "%", "%", "%", "%", Convert.ToDateTime("01/Jan/1950"), Convert.ToDateTime("01/Jan/9999")); TxtPuesto.Text = listaEmpleados[0].Puesto.ToString(); //Banda.Text = listaEmpleados[0].Grado.ToString(); TxtDepto.Text = listaEmpleados[0].Organizacion.ToString(); TxtEmpleado.Text = listaEmpleados[0].NombreCompleto.ToString(); } catch (Exception e3) { throw e3; } TablaEmpleados empleadosEbs2 = new TablaEmpleados(); List<Employee> listaEmpleados2 = capitalHumano.ListaPersona(IDEmpleado.Text); lbSupervisor.Text = listaEmpleados2[0].Supervisor.ToString(); if (string.IsNullOrEmpty(lbSupervisor.Text)) { MensajeError("No se encuentra asignado su Jefe en BD, consulte con Capital Humano"); //lbBanda.Text = "No se encuentra asignado su Jefe en BD, consulte con Capital Humano"; return; } else { List<Employee> listaEmpleados3 = capitalHumano.ListaPersonaName(lbSupervisor.Text); TxtJefeDir.Text = listaEmpleados3[0].SupervisorName.ToString(); NombrejefeBS.Text = listaEmpleados3[0].SupervisorNoemp.ToString(); } //--------------------------------PARA SACAR LA PLANTILLA AUTORIZADA ACTUALMENTE using (SqlConnection cnx = new SqlConnection(ConfigurationManager.ConnectionStrings["conexionAPPS"].ToString())) { cnx.Open(); string query = "SELECT id_plantilla FROM EVA_PLANTILLAS WHERE (vigencia_plant = '1')"; SqlCommand cmd = new SqlCommand(query, cnx); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { lbPlantilla.Text = dr["id_plantilla"].ToString(); } } else { lbPlantilla.Text = "No se encontro plantilla autorizada"; } } // cierre de la conn //--------------------------------PARA SACAR LA PLANTILLA AUTORIZADA ACTUALMENTE //using (SqlConnection cnx = new SqlConnection(ConfigurationManager.ConnectionStrings["conexionAPPS"].ToString())) //{ // cnx.Open(); // string query = " SELECT DISTINCT(c.id_eva) as evaluacion, c.id_emp, c.id_jefe, c.id_categoria_emp, " + // " c.id_banda_emp, c.estatus, c.fecha_captura, d.id_plantilla " + // " FROM EVA_C_EVALUACION as c, EVA_D_EVALUACION as d " + // " WHERE c.id_emp='" + IDEmpleado.Text + "' and c.id_eva=d.id_eva and d.id_plantilla='" + lbPlantilla.Text + "' "; // SqlCommand cmd = new SqlCommand(query, cnx); // SqlDataReader dr = cmd.ExecuteReader(); // if (dr.HasRows) // { // while (dr.Read()) // { // lbFolioeva.Text = dr["evaluacion"].ToString(); // } // } // else // { // MensajeError("No se encontro Evaluacion anterior realizada"); // return; // } //} // cierre de la conn // para separar el puesto y depto string separarpto = TxtPuesto.Text; // Split on directory separator string[] parts = separarpto.Split('.'); Depto.Text = parts[0]; Pto.Text = parts[1]; des_puesto.Text = parts[2]; //inserto si es la primera vez que va capturar sino solo consulto los resultados using (SqlConnection cnx = new SqlConnection(ConfigurationManager.ConnectionStrings["conexionAPPS"].ToString())) { cnx.Open(); string query = " SELECT d.id_eva as ideva, d.id_plantilla as idplantilla, d.depto as depto, d.puesto as puesto, d.id_linea as idlinea, d.resultado_logrado as reslogrado, " + " d.ptos, d.ponderacion_ind as ponderacionind, c.descripcion_kpi as descripcion_kpi, c.unidad_medida as umedida, c.porcentaje_pondera as porcentaje_pondera, " + " c.meta_minima as meta_minima, c.meta_satisfactoria as meta_satisfactoria, c.meta_excelente as meta_excelente, d.calificacion_ind as calind " + " FROM EVA_D_INDICADORES as d, EVA_C_INDICADORES as c " + " WHERE left(d.depto,3)=left(c.depto,3) and left(d.puesto,3)=left(c.puesto,3) and d.id_plantilla=c.id_plantilla and " + " d.id_linea=c.id_linea and (d.id_eva = '" + lbFolioeva.Text + "') and d.id_plantilla='" + lbPlantilla.Text + "' and " + " left(d.depto,3)='" + Depto.Text + "' and left(d.puesto,3)='" + Pto.Text + "' "; SqlCommand cmd = new SqlCommand(query, cnx); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { ban_existe_eva.Text = "1"; } } else { ban_existe_eva.Text = "0"; } } if (ban_existe_eva.Text == "0") { // busco los indicadores que le corresponde por su puesto y depto y plantilla cuando es la 1 vez using (SqlConnection cnx = new SqlConnection(ConfigurationManager.ConnectionStrings["conexionAPPS"].ToString())) { cnx.Open(); string query = " SELECT id_plantilla, depto, puesto, id_linea, descripcion_kpi, unidad_medida, porcentaje_pondera, meta_minima, meta_satisfactoria, meta_excelente " + " FROM EVA_C_INDICADORES " + " WHERE id_plantilla='" + lbPlantilla.Text + "' and " + " left(puesto,3)='" + Pto.Text + "' and left(depto,3)='" + Depto.Text + "' "; SqlCommand cmd = new SqlCommand(query, cnx); SqlDataReader dr2 = cmd.ExecuteReader(); if (dr2.HasRows) { while (dr2.Read()) { idlinea.Text = dr2["id_linea"].ToString(); desckpi.Text = dr2["descripcion_kpi"].ToString(); umedida.Text = dr2["unidad_medida"].ToString(); ppondera.Text = dr2["porcentaje_pondera"].ToString(); metaminima.Text = dr2["meta_minima"].ToString(); metasat.Text = dr2["meta_satisfactoria"].ToString(); metaexc.Text = dr2["meta_excelente"].ToString(); using (SqlConnection cnx2 = new SqlConnection(ConfigurationManager.ConnectionStrings["conexionAPPS"].ToString())) { cnx2.Open(); string query2 = " INSERT EVA_D_INDICADORES (id_eva, id_plantilla, depto, puesto, id_linea, fecha_captura_ind, resultado_logrado, ptos, ponderacion_ind, resultado_logrado_jefe, ptos_jefe, ponderacion_ind_jefe) " + " values ('" + lbFolioeva.Text + "', '" + lbPlantilla.Text + "', '" + Depto.Text + "','" + Pto.Text + "', '" + idlinea.Text + "', GETDATE(), 0, 0, 0, 0, 0, 0 )"; SqlCommand cmd2 = new SqlCommand(query2, cnx2); SqlDataReader dr3 = cmd2.ExecuteReader(); //MensajeExito("Se ha guardado con Exito tu Evaluacion"); } //DatoDetEvaIndicador DatEvaluacionIndi = new DatoDetEvaIndicador(); //if (DatEvaluacionIndi.InsertEvaIndicador(lbFolioeva.Text, Convert.ToInt32(lbPlantilla.Text), "54", Pto.Text, idlinea.Text) > 0) //{ // //inserta el detalle cuando es nuevo // ban_existe_eva.Text = "1"; //} //else //{ // MensajeError("No se pudo insertar el detalle de indicador, revise si tiene indicadores en su puesto"); // return; //} } } else { MensajeError("No se puede insertar el detalle de indicador, revise con Capital Humano si tiene indicadores en su puesto"); return; } } CreateGrid(); } else { CreateGrid(); } }