|
From: <sv...@de...> - 2005-06-10 20:18:10
|
Author: marcelo
Date: 2005-06-10 16:18:09 -0400 (Fri, 10 Jun 2005)
New Revision: 1283
Added:
humano2/trunk/web/builder/site/viewpertinencelist.aspx
humano2/trunk/web/builder/site/viewpertinencelist.aspx.cs
Log:
* Forgot to include 2 files for the pertinance bug fix
Added: humano2/trunk/web/builder/site/viewpertinencelist.aspx
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/web/builder/site/viewpertinencelist.aspx 2005-06-10 20:=
11:45 UTC (rev 1282)
+++ humano2/trunk/web/builder/site/viewpertinencelist.aspx 2005-06-10 20:=
18:09 UTC (rev 1283)
@@ -0,0 +1,42 @@
+<%@ Page language=3D"c#" Codebehind=3D"viewpertinencelist.aspx.cs" AutoE=
ventWireup=3D"false" Inherits=3D"Portal.site.ViewPertinenceList" %>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
+<HTML>
+ <HEAD>
+ <title>ViewPertinenceList</title>
+ <script language=3D"javascript">
+ function sendData()
+ {
+ objeto =3D document.getElementById("ListBox1");
+ if(objeto.selectedIndex < 0)
+ {
+ return;
+ }
+ =20
+ txtSelected =3D objeto.options[objeto.selectedIndex].text;
+ idSelected =3D objeto.options[objeto.selectedIndex].value;
+ elem2 =3D "txt_"+sysAttName;
+
+// alert("sysAttName: "+ sysAttName );
+ =09
+// alert("elem2: "+ elem2 );
+// alert(window.parent);
+ myframe =3D window.parent;
+
+ obj1 =3D myframe.document.getElementsByName(sysAttName)[0]; =09
+ obj2 =3D myframe.document.getElementsByName(elem2)[0];
+
+ obj1.value =3D idSelected;
+ obj2.value =3D txtSelected;
+ obj2.focus();
+
+ return true;
+ }
+
+ </script>
+ </HEAD>
+ <body leftMargin=3D"0" topMargin=3D"0" marginheight=3D"0" marginwidth=3D=
"0">
+ <form id=3D"Form1" method=3D"post" runat=3D"server">
+ <asp:listbox id=3D"ListBox1" runat=3D"server" Width=3D"192px" Height=3D=
"168px"></asp:listbox>
+ </form>
+ </body>
+</HTML>
\ No newline at end of file
Added: humano2/trunk/web/builder/site/viewpertinencelist.aspx.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/web/builder/site/viewpertinencelist.aspx.cs 2005-06-10 =
20:11:45 UTC (rev 1282)
+++ humano2/trunk/web/builder/site/viewpertinencelist.aspx.cs 2005-06-10 =
20:18:09 UTC (rev 1283)
@@ -0,0 +1,205 @@
+//
+// The Humano2 Business solution.
+// Copyright (C) 2004,5 Humano2 Chile S.A. (http://www.humano2.com)
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version. =20
+//
+// $Id: viewpertinencelist.aspx.cs 1165 2005-05-27 16:23:01Z marijn $
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Web;
+using System.Web.SessionState;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Web.UI.HtmlControls;
+
+using Humano2.Components.WebTools;
+using Humano2.Core;
+using Humano2.Core.Db;
+
+
+namespace Portal.site
+{
+ /// <summary>
+ /// Summary description for ViewPertinenceList.
+ /// </summary>
+ public class ViewPertinenceList : basePage
+ { //FIXME: This needs to be refactored. This can be much less fragile.
+ protected System.Web.UI.WebControls.ListBox ListBox1;
+ protected System.Web.UI.WebControls.TextBox idSel;
+ protected System.Web.UI.WebControls.TextBox txtSel;
+ protected System.Web.UI.WebControls.TextBox theIdEntity;
+ DataTable dt1;
+ int idEntity;
+
+ private void Page_Load(object sender, System.EventArgs e)
+ {
+ //Logger.Log("ViewPertinenceList: Called", LogLevel.Trace) ;
+ // Put user code to initialize the page here
+ adapter dbAdapter =3D userCred.CoreAdapter;
+ int idClass;
+ //int idView;
+ int columnPrimary;
+ string sysAttName;
+
+ this.ListBox1.AutoPostBack =3D false;
+ this.ListBox1.Attributes.Add("onClick","javascript:sendData()");
+ idClass =3D Convert.ToInt32(Request.QueryString["idClass"]);
+ //idView =3D Convert.ToInt32(Request.QueryString["idView"]);
+ idEntity =3D Convert.ToInt32(Request.QueryString["idEntity"]);
+ sysAttName =3D Request.QueryString["sysAttName"];
+ =09
+ string filterVariableName =3D "";
+ string filterValue =3D "";=20
+ =09
+ //Logger.Log("ViewPertinenceList: idEntity =3D " + idEntity, LogLevel=
.Trace) ;
+ =09
+ int filterView =3D dbAdapter.PertinenceFilterView(idEntity); // Get t=
he Id of the asociated view.
+ //int filterView =3D getvista
+ Logger.Log("ViewPertinenceList: FilterView =3D " + filterView, LogLev=
el.Trace) ;
+ =09
+ int viewClass =3D0;
+ string viewFilter =3D"";
+ string viewWhereComplete =3D "";
+ string displayColumn =3D "";
+ if(filterView !=3D 0)=20
+ {
+ filterVariableName =3D dbAdapter.GetPertinenceFilterValues(filterVie=
w, out viewClass, out viewFilter, out displayColumn);
+ Logger.Log("ViewPertinenceList: filterVariableName =3D " + filterVar=
iableName, LogLevel.Trace);
+ Logger.Log("ViewPertinenceList: viewClass =3D " + viewClass, LogLeve=
l.Trace);
+ Logger.Log("ViewPertinenceList: viewFilter =3D " + viewFilter, LogLe=
vel.Trace);
+ Logger.Log("ViewPertinenceList: viewWhere =3D " + viewWhereComplete,=
LogLevel.Trace);
+ filterValue =3D Request.QueryString[filterVariableName];
+ viewFilter =3D viewFilter.Replace("[" + filterVariableName + "]", fi=
lterValue );
+ Logger.Log("ViewPertinenceList: filterValue =3D " + filterValue, Log=
Level.Trace);
+ }
+
+ //this.theIdEntity.Text =3D idEntity.ToString();
+ Response.Write("<script language=3D'Javascript'>var idEntity=3D"+idEn=
tity+";</script>\n");
+ Response.Write("<script language=3D'Javascript'>var sysAttName=3D'"+s=
ysAttName+"';</script>\n");
+
+ if(!Page.IsPostBack)
+ {
+ if (displayColumn =3D=3D "")
+ {
+ columnPrimary =3D this.GetAttributePrimary(idClass);
+ if(columnPrimary!=3D-1)
+ displayColumn =3D "0,"+columnPrimary;
+ }
+
+ DataTable dtParam =3D this.makeDataTableInViewTools();
+ DataRow dr =3D dtParam.NewRow();
+ =09
+ //dr["columna"] =3D "0,"+columnPrimary;
+ dr["columna"] =3D displayColumn;
+ =09
+ if(filterView !=3D 0)=20
+ {
+// dr["filtros"] =3D viewColumn+"|4|'"+filterValue+"'|0|0";
+ dr["filtros"] =3D viewFilter;
+ }
+ =09
+ dtParam.Rows.Add(dr); =09
+ =09
+ dt1 =3D dbAdapter.GetDataTableView(dtParam, idClass);
+ this.ListBox1.DataValueField =3D "id_entity";
+ this.ListBox1.DataTextField =3D dt1.Columns[1].ColumnName;//"col"+c=
olumnPrimary;
+ this.ListBox1.DataSource =3D dt1;
+ this.ListBox1.DataBind();
+ }
+ }
+
+
+ #region Web Form Designer generated code
+ override protected void OnInit(EventArgs e)
+ {
+ //
+ // CODEGEN: This call is required by the ASP.NET Web Form Designer.
+ //
+ InitializeComponent();
+ base.OnInit(e);
+ }
+ =09
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ //this.ListBox1.SelectedIndexChanged +=3D new System.EventHandler(thi=
s.ListBox1_SelectedIndexChanged);
+ this.Load +=3D new System.EventHandler(this.Page_Load);
+
+ }
+ #endregion
+
+ #region Metodos utilizados
+
+ /// <summary>
+ /// Funcion que trae cual es el atribuo primary de una clase en partic=
ular
+ /// Consulta en la clase attribute
+ /// </summary>
+ /// <returns></returns>
+ public int GetAttributePrimary(int idClass)
+ {
+ int iniClass;
+ adapter dbAdapter =3D userCred.CoreAdapter;
+
+ DataTable dtParam =3D this.makeDataTableInViewTools();
+ DataRow dr =3D dtParam.NewRow();
+
+ //clase de los atributos.
+ iniClass =3D (int) MetaModelConsts.EntitiesAttribute;
+
+ dr["columna"] =3D "0";
+
+ //Explicacion de los filtros...
+ //atributo 67|4|'true' =3D> isPrimary=3D'true'
+ //atributo 40|4|idClass =3D> classId=3DidClass
+ dr["filtros"] =3D "67|4|'1'|1|0;40|4|'"+idClass+"'|0|0";
+ =09
+ dtParam.Rows.Add(dr);
+
+ dt1 =3D dbAdapter.GetDataTableView(dtParam, iniClass);
+ if(dt1.Rows.Count=3D=3D1)
+ {
+ return Convert.ToInt32(dt1.Rows[0][0].ToString());
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ #endregion
+ /// <summary>
+ /// Funcion que genera un datatable con la forma en que ViewTools lo r=
ecibe...
+ /// </summary>
+ /// <returns></returns>
+ private DataTable makeDataTableInViewTools()
+ {
+ DataTable dt1 =3D new DataTable();
+ DataColumn dc1;
+ dc1 =3D new DataColumn("columna",typeof(string));
+ dt1.Columns.Add(dc1);
+ dc1 =3D new DataColumn("filtros",typeof(string));
+ dt1.Columns.Add(dc1);
+ dc1 =3D new DataColumn("group",typeof(string));
+ dt1.Columns.Add(dc1);
+ dc1 =3D new DataColumn("having",typeof(string));
+ dt1.Columns.Add(dc1);
+ dc1 =3D new DataColumn("order",typeof(string));
+ dt1.Columns.Add(dc1);
+ dc1 =3D new DataColumn("claves",typeof(string));
+ dt1.Columns.Add(dc1);
+ return dt1;
+ }
+ }
+
+}
|