private string Grabar(string strDatosBasicos, string strFiguras) { string sResul = ""; int nID = -1; string[] aDatosBasicos = null; #region abrir conexión y transacción try { oConn = Conexion.Abrir(); tr = Conexion.AbrirTransaccionSerializable(oConn); } catch (Exception ex) { if (oConn.State == ConnectionState.Open) { Conexion.Cerrar(oConn); } sResul = "Error@#@" + Errores.mostrarError("Error al abrir la conexión", ex); return(sResul); } #endregion try { #region Datos Generales if (strDatosBasicos != "")//No se ha modificado nada de la pestaña general { aDatosBasicos = Regex.Split(strDatosBasicos, "##"); ///aDatosBasicos[0] = ID ///aDatosBasicos[1] = Denominacion ///aDatosBasicos[2] = IDResponsable ///aDatosBasicos[3] = Activo ///aDatosBasicos[4] = Orden ///aDatosBasicos[5] = IdEstructura if (aDatosBasicos[0] == "0") //insert { switch (sNivel) { case "0": nID = CDP.Insert(tr, Utilidades.unescape(aDatosBasicos[1]), int.Parse(aDatosBasicos[5]), int.Parse(aDatosBasicos[2]), (aDatosBasicos[3] == "1") ? true : false, byte.Parse(aDatosBasicos[4])); break; case "1": nID = CSN1P.Insert(tr, Utilidades.unescape(aDatosBasicos[1]), int.Parse(aDatosBasicos[5]), int.Parse(aDatosBasicos[2]), (aDatosBasicos[3] == "1") ? true : false, byte.Parse(aDatosBasicos[4])); break; case "2": nID = CSN2P.Insert(tr, Utilidades.unescape(aDatosBasicos[1]), int.Parse(aDatosBasicos[5]), int.Parse(aDatosBasicos[2]), (aDatosBasicos[3] == "1") ? true : false, byte.Parse(aDatosBasicos[4])); break; case "3": nID = CSN3P.Insert(tr, Utilidades.unescape(aDatosBasicos[1]), int.Parse(aDatosBasicos[5]), int.Parse(aDatosBasicos[2]), (aDatosBasicos[3] == "1") ? true : false, byte.Parse(aDatosBasicos[4])); break; case "4": nID = CSN4P.Insert(tr, Utilidades.unescape(aDatosBasicos[1]), int.Parse(aDatosBasicos[5]), int.Parse(aDatosBasicos[2]), (aDatosBasicos[3] == "1") ? true : false, byte.Parse(aDatosBasicos[4])); break; } } else //update { nID = int.Parse(aDatosBasicos[0]); switch (sNivel) { case "0": CDP.Update(tr, nID, Utilidades.unescape(aDatosBasicos[1]), int.Parse(aDatosBasicos[5]), int.Parse(aDatosBasicos[2]), (aDatosBasicos[3] == "1") ? true : false, byte.Parse(aDatosBasicos[4])); break; case "1": CSN1P.Update(tr, nID, Utilidades.unescape(aDatosBasicos[1]), int.Parse(aDatosBasicos[5]), int.Parse(aDatosBasicos[2]), (aDatosBasicos[3] == "1") ? true : false, byte.Parse(aDatosBasicos[4])); break; case "2": CSN2P.Update(tr, nID, Utilidades.unescape(aDatosBasicos[1]), int.Parse(aDatosBasicos[5]), int.Parse(aDatosBasicos[2]), (aDatosBasicos[3] == "1") ? true : false, byte.Parse(aDatosBasicos[4])); break; case "3": CSN3P.Update(tr, nID, Utilidades.unescape(aDatosBasicos[1]), int.Parse(aDatosBasicos[5]), int.Parse(aDatosBasicos[2]), (aDatosBasicos[3] == "1") ? true : false, byte.Parse(aDatosBasicos[4])); break; case "4": CSN4P.Update(tr, nID, Utilidades.unescape(aDatosBasicos[1]), int.Parse(aDatosBasicos[5]), int.Parse(aDatosBasicos[2]), (aDatosBasicos[3] == "1") ? true : false, byte.Parse(aDatosBasicos[4])); break; } } } #endregion #region Datos Figuras if (strFiguras != "")//No se ha modificado nada de la pestaña de Figuras { string[] aUsuarios = Regex.Split(strFiguras, "///"); foreach (string oUsuario in aUsuarios) { if (oUsuario == "") { continue; } string[] aFig = Regex.Split(oUsuario, "##"); ///aFig[0] = bd ///aFig[1] = idUsuario ///aFig[2] = Figuras switch (sNivel) { case "0": if (aFig[0] == "D") { FIGURASCDP.DeleteUsuario(tr, nID, int.Parse(aFig[1])); } else { string[] aFiguras = Regex.Split(aFig[2], ","); foreach (string oFigura in aFiguras) { if (oFigura == "") { continue; } //FIGURASCDP.Insert(tr, nID, int.Parse(aFig[1]), oFigura); string[] aFig2 = Regex.Split(oFigura, "@"); ///aFig2[0] = bd ///aFig2[1] = Figura if (aFig2[0] == "D") { FIGURASCDP.Delete(tr, nID, int.Parse(aFig[1]), aFig2[1]); } else { FIGURASCDP.Insert(tr, nID, int.Parse(aFig[1]), aFig2[1]); } } } break; case "1": if (aFig[0] == "D") { FIGURASCSN1P.DeleteUsuario(tr, nID, int.Parse(aFig[1])); } else { string[] aFiguras = Regex.Split(aFig[2], ","); foreach (string oFigura in aFiguras) { if (oFigura == "") { continue; } //FIGURASCSN1P.Insert(tr, nID, int.Parse(aFig[1]), oFigura); string[] aFig2 = Regex.Split(oFigura, "@"); ///aFig2[0] = bd ///aFig2[1] = Figura if (aFig2[0] == "D") { FIGURASCSN1P.Delete(tr, nID, int.Parse(aFig[1]), aFig2[1]); } else { FIGURASCSN1P.Insert(tr, nID, int.Parse(aFig[1]), aFig2[1]); } } } break; case "2": if (aFig[0] == "D") { FIGURASCSN2P.DeleteUsuario(tr, nID, int.Parse(aFig[1])); } else { string[] aFiguras = Regex.Split(aFig[2], ","); foreach (string oFigura in aFiguras) { if (oFigura == "") { continue; } //FIGURASCSN2P.Insert(tr, nID, int.Parse(aFig[1]), oFigura); string[] aFig2 = Regex.Split(oFigura, "@"); ///aFig2[0] = bd ///aFig2[1] = Figura if (aFig2[0] == "D") { FIGURASCSN2P.Delete(tr, nID, int.Parse(aFig[1]), aFig2[1]); } else { FIGURASCSN2P.Insert(tr, nID, int.Parse(aFig[1]), aFig2[1]); } } } break; case "3": if (aFig[0] == "D") { FIGURASCSN3P.DeleteUsuario(tr, nID, int.Parse(aFig[1])); } else { string[] aFiguras = Regex.Split(aFig[2], ","); foreach (string oFigura in aFiguras) { if (oFigura == "") { continue; } //FIGURASCSN3P.Insert(tr, nID, int.Parse(aFig[1]), oFigura); string[] aFig2 = Regex.Split(oFigura, "@"); ///aFig2[0] = bd ///aFig2[1] = Figura if (aFig2[0] == "D") { FIGURASCSN3P.Delete(tr, nID, int.Parse(aFig[1]), aFig2[1]); } else { FIGURASCSN3P.Insert(tr, nID, int.Parse(aFig[1]), aFig2[1]); } } } break; case "4": if (aFig[0] == "D") { FIGURASCSN4P.DeleteUsuario(tr, nID, int.Parse(aFig[1])); } else { string[] aFiguras = Regex.Split(aFig[2], ","); foreach (string oFigura in aFiguras) { if (oFigura == "") { continue; } //FIGURASCSN4P.Insert(tr, nID, int.Parse(aFig[1]), oFigura); string[] aFig2 = Regex.Split(oFigura, "@"); ///aFig2[0] = bd ///aFig2[1] = Figura if (aFig2[0] == "D") { FIGURASCSN4P.Delete(tr, nID, int.Parse(aFig[1]), aFig2[1]); } else { FIGURASCSN4P.Insert(tr, nID, int.Parse(aFig[1]), aFig2[1]); } } } break; } } } #endregion Conexion.CommitTransaccion(tr); sResul = "OK@#@" + nID.ToString("#,###"); } catch (Exception ex) { Conexion.CerrarTransaccion(tr); sResul = "Error@#@" + Errores.mostrarError("Error al grabar los datos del cualificador", ex, false); } finally { Conexion.Cerrar(oConn); } return(sResul); }
private string obtenerFigurasCualificador(string sPestana, string sCualificador) { StringBuilder sb = new StringBuilder(); StringBuilder sbuilder = new StringBuilder(); sbuilder.Append(" aFigIni = new Array();"); int i = 0; try { SqlDataReader dr = null; switch (sNivel) { case "0": dr = FIGURASCDP.CatalogoFiguras(int.Parse(sCualificador)); break; case "1": dr = FIGURASCSN1P.CatalogoFiguras(int.Parse(sCualificador)); break; case "2": dr = FIGURASCSN2P.CatalogoFiguras(int.Parse(sCualificador)); break; case "3": dr = FIGURASCSN3P.CatalogoFiguras(int.Parse(sCualificador)); break; case "4": dr = FIGURASCSN4P.CatalogoFiguras(int.Parse(sCualificador)); break; } sb.Append("<TABLE id='tblFiguras2' class='texto MM' style='WIDTH: 420px; ' mantenimiento='1'>"); sb.Append("<colgroup><col style='width: 20px' /><col style='width: 20px' /><col style='width: 280px;' /><col style='width: 100px;' /></colgroup>"); sb.Append("<tbody>"); int nUsuario = 0; bool bHayFilas = false; while (dr.Read()) { bHayFilas = true; sbuilder.Append("aFigIni[" + i.ToString() + "] = {idUser:\"" + dr["t314_idusuario"].ToString() + "\"," + "sFig:\"" + dr["figura"].ToString() + "\"};"); i++; if ((int)dr["t314_idusuario"] != nUsuario) { if (nUsuario != 0) { sb.Append("</ul></div></td>"); sb.Append("</tr>"); } sb.Append("<tr id='" + dr["t314_idusuario"].ToString() + "' bd='' style='height:20px;' onclick='mm(event)' onmousedown='DD(event);' "); //sb.Append(" title=\"cssbody=[dvbdy] cssheader=[dvhdr] header=[<img src='../../../images/info.gif' style='vertical-align:middle'> Información] body=[<label style='width:70px;'>Profesional:</label>" + dr["Profesional"].ToString().Replace((char)34, (char)39) + "<br><label style='width:70px;'>Usuario:</label>" + int.Parse(dr["t314_idusuario"].ToString()).ToString("#,###") + "<br><label style='width:70px;'>" + Estructura.getDefCorta(Estructura.sTipoElem.NODO) + ":</label>" + dr["t303_denominacion"].ToString().Replace((char)34, (char)39) + "<br><label style='width:70px;'>Empresa:</label>" + dr["empresa"].ToString().Replace((char)34, (char)39) + "] hideselects=[off]\""); sb.Append(" title=\"cssbody=[dvbdy] cssheader=[dvhdr] header=[<img src='../../../images/info.gif' style='vertical-align:middle'> Información] body=[<label style='width:70px;'>Profesional:</label>" + dr["Profesional"].ToString().Replace((char)34, (char)39) + "<br><label style='width:70px;'>Usuario:</label>" + int.Parse(dr["t314_idusuario"].ToString()).ToString("#,###") + "<br><label style='width:70px;'>" + Estructura.getDefCorta(Estructura.sTipoElem.NODO) + ":</label>" + dr["t303_denominacion"].ToString().Replace((char)34, (char)39) + "] hideselects=[off]\""); sb.Append("><td><img src='../../../images/imgFN.gif'></td>"); sb.Append("<td style='text-align:center;'>"); if (dr["t001_sexo"].ToString() == "V") { //sb.Append("<img src='../../../images/imgUsuIV.gif'>"); switch (dr["tipo"].ToString()) { case "P": sb.Append("<img src='../../../images/imgUsuPV.gif'>"); break; case "E": sb.Append("<img src='../../../images/imgUsuEV.gif'>"); break; case "F": sb.Append("<img src='../../../images/imgUsuFV.gif'>"); break; } } else { //sb.Append("<img src='../../../images/imgUsuIM.gif'>"); switch (dr["tipo"].ToString()) { case "P": sb.Append("<img src='../../../images/imgUsuPM.gif'>"); break; case "E": sb.Append("<img src='../../../images/imgUsuEM.gif'>"); break; case "F": sb.Append("<img src='../../../images/imgUsuFM.gif'>"); break; } } sb.Append("</td><td><nobr class='NBR W280'>" + dr["Profesional"].ToString() + "</nobr></td>"); //Figuras sb.Append("<td><div style='height:20px;'><ul id='box-" + dr["t314_idusuario"].ToString() + "'>"); switch (dr["figura"].ToString()) { case "D": sb.Append("<li id='D' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgDelegado.gif' title='Delegado' /></li>"); break; case "I": sb.Append("<li id='I' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgInvitado.gif' title='Invitado' /></li>"); break; case "G": sb.Append("<li id='G' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgGestor.gif' title='Gestor' /></li>"); break; } nUsuario = (int)dr["t314_idusuario"]; } else { switch (dr["figura"].ToString()) { case "D": sb.Append("<li id='D' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgDelegado.gif' title='Delegado' /></li>"); break; case "I": sb.Append("<li id='I' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgInvitado.gif' title='Invitado' /></li>"); break; case "G": sb.Append("<li id='G' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgGestor.gif' title='Gestor' /></li>"); break; } } } dr.Close(); dr.Dispose(); if (bHayFilas) { sb.Append("</ul></div></td>"); sb.Append("</tr>"); } sb.Append("</tbody>"); sb.Append("</table>"); return("OK@#@" + sPestana + "@#@" + sb.ToString() + "///" + sbuilder.ToString()); } catch (Exception ex) { return("Error@#@" + Errores.mostrarError("Error al obtener la relación de figuras.", ex)); } }