Erreur programme C#

ibtissame_87 Messages postés 102 Date d'inscription   Statut Membre Dernière intervention   -  
Taxiarque Messages postés 63 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,
SVP quand je compile ce programme il me dit qu'il ya une accolade qui manque j'ai beau verifier j'ai pa su ou ca bloque,

Ca va me rendre dingue SVP aidez moi:



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WordAddIn1
{
public partial class VersionControl : UserControl
{
const string XmlNs = "";
const string ListName = "Clients";

public VersionControl()
{
InitializeComponent();
}

private XmlNode GetListItems(string SpQuery)
{
SPListService.Lists SPService = new SPListService.Lists();
SPService.Url = SiteUrl.Text + "_vti_bin/lists.asmx";
SPService.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

XmlNode Lists = SPService.GetListCollection();
XPathNavigator Navigator = Lists.CreateNavigator();
XPathNavigator ClientAdresse =
Navigator.SelectSingleNode(string.Format("//*[@Title='{0}']", ListName));

if (ClientAdresse != null)
{
XmlDocument Doc = new XmlDocument();
XmlNode NoeudViewFields =
Doc.CreateNode(XmlNodeType.Element, "ViewFields", "");
XmlNode QueryOptionsNode =
Doc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
QueryOptionsNode.InnerXml = "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>";

XmlNode SearchQuery = Doc.CreateNode(
XmlNodeType.Element, "Query", "");
NoeudViewFields.InnerXml = "<FieldRef Name='ID'/><FieldRef Name='Nom'/><FieldRef Name='Pr_x00e9_nom'/>";
SearchQuery.InnerXml = SpQuery;
XmlNode Items = SPService.GetListItems(ListName, null, SearchQuery, NoeudViewFields, null, QueryOptionsNode, null);
return Items;
}
else
{
MessageBox.Show("La liste d'adresse n'a pu être trouvée");
}
return null;
}

private void ok_Click(object sender, EventArgs e)
{
DataTable TableClients = new DataTable();
TableClients.Columns.Add("ID");
TableClients.Columns.Add("Nom Complet");
TableClients.Rows.Add("", "");
try
{
XmlNode Items = GetListItems(
string.Format("<Where><Or><Contains><FieldRef Name=\"Nom\"/><Value Type=\"Text\">{0}</Value></Contains><Contains><FieldRef Name=\"Pr_x00e9_nom\" /><Value Type=\"Text\">{1}</Value></Contains></Or></Where>",Nom.Text, Prenom.Text));

XmlNodeList Clients = Items.SelectNodes(
string.Format("{0}{1}",
"//*[local-name() = 'data' and namespace-uri() = 'urn:schemas-microsoft-com:rowset']",
"/*[local-name() = 'row' and namespace-uri() = '#RowsetSchema']"));
NbClients.Text = string.Format("Nombre de clients : {0}", Clients.Count);
if (Clients.Count > 0)
{
for (int i = 0; i < Clients.Count; i++)
{
TableClients.Rows.Add(
Clients[i].Attributes["ows_ID"].Value,
string.Format("{0} {1}",
Clients[i].Attributes["ows_Nom"].Value,
Clients[i].Attributes["ows_Pr_x00e9_nom"].Value
));

}
TableClients.AcceptChanges();
}
}
catch (SoapException WebSrvEx)
{
MessageBox.Show(
string.Format(
"Problème de communication avec le service lists.asmx : {0}",
WebSrvEx.Message));
}
ComboClients.DisplayMember = "Nom Complet";
ComboClients.ValueMember = "ID";
ComboClients.DataSource = TableClients;
}

private void ComboClients_SelectedIndexChanged(object sender, EventArgs e)
{
StringBuilder FicheClient=null;
if (!String.IsNullOrEmpty(ComboClients.SelectedValue.ToString()))
{
FicheClient = new StringBuilder();
try
{
XmlNode Items =
GetListItems(
string.Format(
"<Where><Eq><FieldRef Name=\"ID\" /><Value Type=\"Counter\">{0}</Value></Eq></Where>",
ComboClients.SelectedValue.ToString()));

XmlNodeList Clients = Items.SelectNodes(
string.Format("{0}{1}",
"//*[local-name() = 'data' and namespace-uri() = 'urn:schemas-microsoft-com:rowset']",
"/*[local-name() = 'row' and namespace-uri() = '#RowsetSchema']"));

if (Clients != null && Clients.Count == 1)
{
FicheClient.AppendFormat("Nom : {0}\r\n", Clients[0].Attributes["ows_Nom"].Value);
FicheClient.AppendFormat("Prénom : {0}\r\n", Clients[0].Attributes["ows_Pr_x00e9_nom"].Value);
FicheClient.AppendFormat("Adresse : {0}\r\n", Clients[0].Attributes["ows_Adresse"].Value);
Word.Range currentRange = Globals.ThisAddIn.Application.Selection.Range;
currentRange.Text = FicheClient.ToString();
}
else
{
MessageBox.Show("Problème lors de la réception de la fiche client");
}
}
catch (SoapException WebSrvEx)
{
MessageBox.Show(
string.Format(
"Problème de communication avec le service lists.asmx : {0}",
WebSrvEx.Message));
}
}
}

private void ComboClients_SelectedIndexChanged_1(object sender, EventArgs e)
{
StringBuilder FicheClient=null;
if (!String.IsNullOrEmpty(ComboClients.SelectedValue.ToString()))
{
FicheClient = new StringBuilder();
try
{
XmlNode Items =
GetListItems(
string.Format(
"<Where><Eq><FieldRef Name=\"ID\" /><Value Type=\"Counter\">{0}</Value></Eq></Where>",
ComboClients.SelectedValue.ToString()));

XmlNodeList Clients = Items.SelectNodes(
string.Format("{0}{1}",
"//*[local-name() = 'data' and namespace-uri() = 'urn:schemas-microsoft-com:rowset']",
"/*[local-name() = 'row' and namespace-uri() = '#RowsetSchema']"));

if (Clients != null && Clients.Count == 1)
{
FicheClient.AppendFormat("Nom : {0}\r\n", Clients[0].Attributes["ows_Nom"].Value);
FicheClient.AppendFormat("Prénom : {0}\r\n", Clients[0].Attributes["ows_Pr_x00e9_nom"].Value);
FicheClient.AppendFormat("Adresse : {0}\r\n", Clients[0].Attributes["ows_Adresse"].Value);
Word.Range currentRange = Globals.ThisAddIn.Application.Selection.Range;
currentRange.Text = FicheClient.ToString();
}
else
{
MessageBox.Show("Problème lors de la réception de la fiche client");
}
}
catch (SoapException WebSrvEx)
{
MessageBox.Show(
string.Format(
"Problème de communication avec le service lists.asmx : {0}",
WebSrvEx.Message));
}
}
}

private void OkBtn_Click(object sender, EventArgs e)
{
private XmlNode GetListItems(string SpQuery)
{
SPListService.Lists SPService = new SPListService.Lists();
SPService.Url = SiteUrl.Text + "_vti_bin/lists.asmx";
SPService.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

XmlNode Lists = SPService.GetListCollection();
XPathNavigator Navigator = Lists.CreateNavigator();
XPathNavigator ClientAdresse =
Navigator.SelectSingleNode(string.Format("//*[@Title='{0}']", ListName));

if (ClientAdresse != null)
{
XmlDocument Doc = new XmlDocument();
XmlNode NoeudViewFields =
Doc.CreateNode(XmlNodeType.Element, "ViewFields", "");
XmlNode QueryOptionsNode =
Doc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
QueryOptionsNode.InnerXml = "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>";

XmlNode SearchQuery = Doc.CreateNode(
XmlNodeType.Element, "Query", "");
NoeudViewFields.InnerXml = "<FieldRef Name='ID'/><FieldRef Name='Nom'/><FieldRef Name='Pr_x00e9_nom'/>";
SearchQuery.InnerXml = SpQuery;
XmlNode Items = SPService.GetListItems(ListName, null, SearchQuery, NoeudViewFields, null, QueryOptionsNode, null);
return Items;
}
else
{
MessageBox.Show("La liste d'adresse n'a pu être trouvée");
}
return null;
}
}
}

1 réponse

Taxiarque Messages postés 63 Date d'inscription   Statut Membre Dernière intervention   10
 
Coucou,

tu as oublié ton accolade ici :

private void OkBtn_Click(object sender, EventArgs e)
{

}

Bonne soirée
0