private string Grabar(string strDatosBasicos, string strFiguras, string strFigurasV) { 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] = IDPadre ///aDatosBasicos[6] = t313_idempresa /// if (aDatosBasicos[0] == "") //insert { nID = SUBNODO.Insert(tr, Utilidades.unescape(aDatosBasicos[1]), int.Parse(aDatosBasicos[5]), int.Parse(aDatosBasicos[4]), (aDatosBasicos[3] == "1") ? true : false, 0, int.Parse(aDatosBasicos[2]), (aDatosBasicos[6] == "")? null : (int?)int.Parse(aDatosBasicos[6]) ); } else //update { nID = int.Parse(aDatosBasicos[0].Replace(".", "")); SUBNODO.Update(tr, nID, Utilidades.unescape(aDatosBasicos[1]), int.Parse(aDatosBasicos[5]), int.Parse(aDatosBasicos[4]), (aDatosBasicos[3] == "1") ? true : false, int.Parse(aDatosBasicos[2]), (aDatosBasicos[6] == "") ? null : (int?)int.Parse(aDatosBasicos[6]) ); } } #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 //FIGURASUBNODO.DeleteUsuario(tr, nID, int.Parse(aFig[1])); //if (aFig[0] != "D") //{ // string[] aFiguras = Regex.Split(aFig[2], ","); // foreach (string oFigura in aFiguras) // { // if (oFigura == "") continue; // FIGURASUBNODO.Insert(tr, nID, int.Parse(aFig[1]), oFigura); // } //} if (aFig[0] == "D") { FIGURASUBNODO.DeleteUsuario(tr, nID, int.Parse(aFig[1])); } else { string[] aFiguras = Regex.Split(aFig[2], ","); foreach (string oFigura in aFiguras) { if (oFigura == "") { continue; } string[] aFig2 = Regex.Split(oFigura, "@"); ///aFig2[0] = bd ///aFig2[1] = Figura if (aFig2[0] == "D") { FIGURASUBNODO.Delete(tr, nID, int.Parse(aFig[1]), aFig2[1]); } else { FIGURASUBNODO.Insert(tr, nID, int.Parse(aFig[1]), aFig2[1]); } } } } } #endregion #region Datos Figuras Virtuales if (strFigurasV != "")//No se ha modificado nada de la pestaña de Figuras virtuales { string[] aUsuariosV = Regex.Split(strFigurasV, "///"); foreach (string oUsuarioV in aUsuariosV) { if (oUsuarioV == "") { continue; } string[] aFigV = Regex.Split(oUsuarioV, "##"); ///aFig[0] = bd ///aFig[1] = idUsuario ///aFig[2] = Figuras if (aFigV[0] == "D") { FIGURAPSN_SUBNODO.DeleteUsuario(tr, nID, int.Parse(aFigV[1])); } else { string[] aFigurasV = Regex.Split(aFigV[2], ","); foreach (string oFiguraV in aFigurasV) { if (oFiguraV == "") { continue; } string[] aFig2V = Regex.Split(oFiguraV, "@"); ///aFig2[0] = bd ///aFig2[1] = Figura if (aFig2V[0] == "D") { FIGURAPSN_SUBNODO.Delete(tr, nID, int.Parse(aFigV[1]), aFig2V[1]); } else { FIGURAPSN_SUBNODO.Insert(tr, nID, int.Parse(aFigV[1]), aFig2V[1]); } } } } } #endregion Conexion.CommitTransaccion(tr); sResul = "OK@#@" + nID.ToString("#,###"); } catch (Exception ex) { Conexion.CerrarTransaccion(tr); sResul = "Error@#@" + Errores.mostrarError("Error al grabar los datos del elemento de estructura", ex); } finally { Conexion.Cerrar(oConn); } return(sResul); }
private string obtenerFigurasPSN_SubNodo(string sPestana, string sIDItem) { StringBuilder sb = new StringBuilder(); StringBuilder sbuilder = new StringBuilder(); sbuilder.Append(" aFigIniV = new Array();"); int i = 0; try { SqlDataReader dr = FIGURAPSN_SUBNODO.CatalogoFiguras(int.Parse(sIDItem.Replace(".", ""))); sb.Append("<TABLE id='tblFiguras2V' class='texto MM' style='WIDTH: 420px;' mantenimiento='1'>"); sb.Append("<colgroup>"); sb.Append(" <col style='width: 10px' />"); sb.Append(" <col style='width: 20px' />"); sb.Append(" <col style='width: 290px;' />"); sb.Append(" <col style='width: 100px;' />"); sb.Append("</colgroup>"); int nUsuario = 0; bool bHayFilas = false; string sColor = "black"; while (dr.Read()) { bHayFilas = true; sbuilder.Append("aFigIniV[" + i.ToString() + "] = {idUser:\"" + dr["t314_idusuario"].ToString() + "\"," + "sFig:\"" + dr["figura"].ToString() + "\"};"); i++; sColor = "black"; if ((int)dr["t314_idusuario"] != nUsuario) { if (nUsuario != 0) { sb.Append("</ul></div></td>"); sb.Append("</tr>"); } if (dr["baja"].ToString() == "1") { sColor = "red"; } sb.Append("<tr id='" + dr["t314_idusuario"].ToString() + "' bd='' style='height:22px;color:" + sColor + "' "); sb.Append("sexo='" + dr["t001_sexo"].ToString() + "' "); sb.Append("tipo='" + dr["tipo"].ToString() + "' "); //if (dr["t303_denominacion"].ToString() == "") sb.Append("tipo='E' "); //else sb.Append("tipo='I' "); sb.Append(" onclick='mm(event)' onmousedown='DD(event);'>"); //sb.Append("<td><img src='../../../images/imgFN.gif'></td>"); //sb.Append("<td></td>"); sb.Append("<td><img src='../../../images/imgFN.gif'></td>"); sb.Append("<td align='center'>"); if (dr["t001_sexo"].ToString() == "V") { //if (dr["t001_tiporecurso"].ToString() == "I") // sb.Append("<img src='../../../images/imgUsuIV.gif'>"); //else // sb.Append("<img src='../../../images/imgUsuEV.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 { //if (dr["t001_tiporecurso"].ToString() == "I") // sb.Append("<img src='../../../images/imgUsuIM.gif'>"); //else // sb.Append("<img src='../../../images/imgUsuEM.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>"); //sb.Append("<td><nobr class='NBR W280' style='noWrap:true;' title=\"cssbody=[dvbdy] cssheader=[dvhdr] header=[<img src='../../../images/info.gif' style='vertical-align:middle' /> Información] body=[<label style='width:60px;'>Profesional:</label>" + dr["Profesional"].ToString().Replace((char)34, (char)39) + "<br><label style='width:60px;'>Usuario:</label>" + int.Parse(dr["t314_idusuario"].ToString()).ToString("#,###") + "<br><label style='width:60px;'>" + Estructura.getDefCorta(Estructura.sTipoElem.NODO) + ":</label>" + dr["t303_denominacion"].ToString().Replace((char)34, (char)39) + "<br><label style='width:60px;'>Empresa:</label>" + dr["empresa"].ToString().Replace((char)34, (char)39) + "] hideselects=[off]\">" + dr["Profesional"].ToString() + "</nobr></td>");// ondblclick='insertarFigura(this.parentNode.parentNode)' sb.Append("<td style='padding-left:3px;'><span class='NBR W280' style='noWrap:true;' title=\"cssbody=[dvbdy] cssheader=[dvhdr] header=[<img src='../../../images/info.gif' style='vertical-align:middle' /> Información] body=[<label style='width:60px;'>Profesional:</label>" + dr["Profesional"].ToString().Replace((char)34, (char)39) + "<br><label style='width:60px;'>Usuario:</label>" + int.Parse(dr["t314_idusuario"].ToString()).ToString("#,###") + "<br><label style='width:60px;'>" + Estructura.getDefCorta(Estructura.sTipoElem.NODO) + ":</label>" + dr["t303_denominacion"].ToString().Replace((char)34, (char)39) + "] hideselects=[off]\">" + dr["Profesional"].ToString() + "</span></td>");// ondblclick='insertarFigura(this.parentNode.parentNode)' //sb.Append("<td>" + dr["Profesional"].ToString() + "</td>"); //Figuras sb.Append("<td><div><ul id='boxv-" + dr["t314_idusuario"].ToString() + "'>"); switch (dr["figura"].ToString()) { case "D": sb.Append("<li id='DV' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgDelegado.gif' title='Delegado' /></li>"); break; case "C": sb.Append("<li id='CV' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgColaborador.gif' title='Colaborador' /></li>"); break; case "J": sb.Append("<li id='JV' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgJefeProyecto.gif' title='Jefe' /></li>"); break; case "M": sb.Append("<li id='MV' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgSubjefeProyecto.gif' title='Responsable técnico de proyecto económico' /></li>"); break; case "B": sb.Append("<li id='BV' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgBitacorico.gif' title='Bitacórico' /></li>"); break; case "S": sb.Append("<li id='SV' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgSecretaria.gif' title='Asistente' /></li>"); break; case "I": sb.Append("<li id='IV' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgInvitado.gif' title='Invitado' /></li>"); break; } nUsuario = (int)dr["t314_idusuario"]; } else { switch (dr["figura"].ToString()) { case "D": sb.Append("<li id='DV' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgDelegado.gif' title='Delegado' /></li>"); break; case "C": sb.Append("<li id='CV' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgColaborador.gif' title='Colaborador' /></li>"); break; case "J": sb.Append("<li id='JV' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgJefeProyecto.gif' title='Jefe' /></li>"); break; case "M": sb.Append("<li id='MV' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgSubjefeProyecto.gif' title='Responsable técnico de proyecto económico' /></li>"); break; case "B": sb.Append("<li id='BV' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgBitacorico.gif' title='Bitacórico' /></li>"); break; case "S": sb.Append("<li id='SV' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgSecretaria.gif' title='Secretaria' /></li>"); break; case "I": sb.Append("<li id='IV' value='" + dr["orden"].ToString() + "'><img src='../../../Images/imgInvitado.gif' title='Invitado' /></li>"); break; } } } dr.Close(); dr.Dispose(); if (bHayFilas) { sb.Append("</ul></div></td>"); sb.Append("</tr>"); } 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 virtuales.", ex)); } }