| using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; //Espacio de nombres necesarios using System.Data; namespace URL_Syntax { public partial class Form1 : Form { public const string SEARCH_URL="http://litwaredemo:12000/sites/Intranet/_layouts/OSSSearchResults.aspx"; public const string QUESTION_MARK_SYMBOL = "?"; public const string EQUAL_SYMBOL = "="; public const string AMPERSAND_SYMBOL = "&"; public const string K_PARAMETER = "k"; public const string S_PARAMETER = "s"; public const string V_PARAMETER = "v"; public const string START_PARAMETER = "start"; public const string ID_TIPO_VISTA = "ID_Vista"; public const string TIPO_VISTA = "Vista"; public const string ID_TIPO_VISTA_0 = "D"; public const string ID_TIPO_VISTA_1 = "R"; public const string ID_TIPO_VISTA_TEXT_0 = "date"; public const string ID_TIPO_VISTA_TEXT_1 = "relevance"; public Form1() { InitializeComponent(); //Filling the combo DataTable dtlTipoVista = new DataTable(); dtlTipoVista.Columns.Add(ID_TIPO_VISTA); dtlTipoVista.Columns.Add(TIPO_VISTA); DataRow dtrFila; //Por fecha dtrFila = dtlTipoVista.NewRow(); dtrFila[ID_TIPO_VISTA] = ID_TIPO_VISTA_0; dtrFila[TIPO_VISTA] = ID_TIPO_VISTA_TEXT_0; dtlTipoVista.Rows.Add(dtrFila); //Por relevancia dtrFila = dtlTipoVista.NewRow(); dtrFila[ID_TIPO_VISTA] = ID_TIPO_VISTA_1; dtrFila[TIPO_VISTA] = ID_TIPO_VISTA_TEXT_1; dtlTipoVista.Rows.Add(dtrFila); this.comboBox1.ValueMember = ID_TIPO_VISTA; this.comboBox1.DisplayMember = TIPO_VISTA; this.comboBox1.DataSource = dtlTipoVista; } private void button1_Click(object sender, EventArgs e) { try { string sKParameter = this.textBox1.Text; string sSParameter = this.textBox3.Text; string sVParameter = ""; if (this.comboBox1.SelectedValue.ToString() == ID_TIPO_VISTA_0) { sVParameter = ID_TIPO_VISTA_TEXT_0; } else { sVParameter = ID_TIPO_VISTA_TEXT_1; } string sSTARTParameter = this.textBox4.Text; string sUrl = SEARCH_URL + QUESTION_MARK_SYMBOL + K_PARAMETER + EQUAL_SYMBOL + sKParameter + AMPERSAND_SYMBOL + S_PARAMETER + EQUAL_SYMBOL + sSParameter + AMPERSAND_SYMBOL + V_PARAMETER + EQUAL_SYMBOL + sVParameter; Uri uURL; if (this.textBox4.Text != "") { sUrl += AMPERSAND_SYMBOL + START_PARAMETER + EQUAL_SYMBOL + sSTARTParameter; uURL = new Uri(sUrl); } else { uURL = new Uri(sUrl); } this.webBrowser1.Url = uURL; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } } } |