Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
3.8 KiB

  1. using System;
  2. using System.Web.UI.WebControls;
  3. using UDDI.API;
  4. using UDDI.API.Business;
  5. namespace UDDI.Web
  6. {
  7. public class AddressControl : UddiControl
  8. {
  9. protected AddressCollection addresses;
  10. protected BusinessEntity business;
  11. protected UddiLabel count;
  12. protected DataGrid grid;
  13. public void Initialize( AddressCollection addresses )
  14. {
  15. this.addresses = addresses;
  16. grid.Columns[ 1 ].Visible = false;
  17. }
  18. public void Initialize( AddressCollection addresses, BusinessEntity business )
  19. {
  20. this.addresses = addresses;
  21. this.business = business;
  22. grid.Columns[ 1 ].Visible = true;
  23. }
  24. protected void Page_Load( object sender, EventArgs e )
  25. {
  26. if( !Page.IsPostBack )
  27. PopulateDataGrid();
  28. if( grid.EditItemIndex >= 0 )
  29. SetEditMode();
  30. }
  31. void PopulateDataGrid()
  32. {
  33. grid.DataSource = addresses;
  34. grid.DataBind();
  35. }
  36. protected void DataGrid_Edit( object sender, DataGridCommandEventArgs e )
  37. {
  38. int index = e.Item.ItemIndex;
  39. grid.EditItemIndex = index;
  40. SetEditMode();
  41. PopulateDataGrid();
  42. }
  43. protected void OnEnterKeyPressed( object sender, EventArgs e )
  44. {
  45. DataGrid_Update( sender, null );
  46. }
  47. protected void DataGrid_Update( object sender, DataGridCommandEventArgs e )
  48. {
  49. int index = grid.EditItemIndex;
  50. if( index >= addresses.Count )
  51. addresses.Add( "", "" );
  52. Address address = addresses[ index ];
  53. address.AddressLines.Clear();
  54. DataGridItem item = grid.Items[ index ];
  55. string[] addressLine = new string[ 5 ]
  56. {
  57. ((TextBox)item.FindControl( "address0" )).Text,
  58. ((TextBox)item.FindControl( "address1" )).Text,
  59. ((TextBox)item.FindControl( "address2" )).Text,
  60. ((TextBox)item.FindControl( "address3" )).Text,
  61. ((TextBox)item.FindControl( "address4" )).Text
  62. };
  63. for( int i = 0; i < 5; i ++ )
  64. {
  65. if( !Utility.StringEmpty( addressLine[ i ] ) )
  66. address.AddressLines.Add( addressLine[ i ] );
  67. }
  68. address.UseType = ((TextBox)item.FindControl( "useType" )).Text;
  69. business.Save();
  70. grid.EditItemIndex = -1;
  71. CancelEditMode();
  72. PopulateDataGrid();
  73. }
  74. protected void DataGrid_Cancel( object sender, DataGridCommandEventArgs e )
  75. {
  76. grid.EditItemIndex = -1;
  77. CancelEditMode();
  78. PopulateDataGrid();
  79. }
  80. protected void DataGrid_Delete( object sender, DataGridCommandEventArgs e )
  81. {
  82. int index = e.Item.ItemIndex;
  83. addresses.RemoveAt( index );
  84. business.Save();
  85. PopulateDataGrid();
  86. }
  87. protected void DataGrid_Add( object sender, EventArgs e )
  88. {
  89. grid.EditItemIndex = addresses.Count;
  90. SetEditMode();
  91. addresses.Add( "", "" );
  92. PopulateDataGrid();
  93. }
  94. protected void Selector_OnSelect( object sender, string key, string name )
  95. {
  96. /*
  97. UddiLabel otherBusiness = (UddiLabel)GetControl( "otherBusiness", 6 );
  98. UddiLabel otherBusinessKey = (UddiLabel)GetControl( "otherBusinessKey", 6 );
  99. UddiLabel leftOtherBusiness = (UddiLabel)GetControl( "leftOtherBusiness", 6 );
  100. UddiLabel rightOtherBusiness = (UddiLabel)GetControl( "rightOtherBusiness", 6 );
  101. otherBusinessKey.Text = key;
  102. otherBusiness.Text = name;
  103. leftOtherBusiness.Text = name;
  104. rightOtherBusiness.Text = name;
  105. Panel selectPanel = (Panel)GetControl( "selectPanel", 6 );
  106. Panel directionPanel = (Panel)GetControl( "directionPanel", 6 );
  107. UddiButton add = (UddiButton)GetControl( "add", 7 );
  108. add.Enabled = true;
  109. selectPanel.Visible = false;
  110. directionPanel.Visible = true; */
  111. }
  112. }
  113. }