服务端[WebMethod] public dsid1 getid() { dsid1 dsid=new dsid1 (); idada.Fill (dsid); return dsid; } [WebMethod] public dsid1 updateid(dsid1 ch) { if (ch!=null) { idada.Update (ch); return ch; } else return null; } [WebMethod] public dsre1 getre() { dsre1 dsre=new dsre1 (); reada.Fill (dsre); return dsre; } [WebMethod] public dsre1 updatere(dsre1 c) { if (c!=null) { reada.Update (c); return c; } else return null; } [WebMethod] public dsbe1 getbe() { dsbe1 dsbe=new dsbe1 (); beada.Fill (dsbe); return dsbe; } [WebMethod] public dsbe1 updatebe(dsbe1 cha) { if (cha!=null) { beada.Fill (cha); return cha; } else return null; }
无法更新的段 this.oleDbUpdateCommand3.CommandText = "UPDATE be SET ID = ?,Action = ?, Class = ?, Labor = ? WHERE (ID = ?) AND (Action" + " = ? OR ? IS NULL AND Action IS NULL) AND (Class = ? OR ? IS NULL AND Class IS N" + "ULL) AND (Labor = ? OR ? IS NULL AND Labor IS NULL)"; this.oleDbUpdateCommand3.Connection = this.oleDbConnection1; this.oleDbUpdateCommand3.Parameters.Add(new System.Data.OleDb.OleDbParameter("ID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(10)), ((System.Byte)(0)), "ID", System.Data.DataRowVersion.Current, null)); this.oleDbUpdateCommand3.Parameters.Add(new System.Data.OleDb.OleDbParameter("Action", System.Data.OleDb.OleDbType.VarWChar, 50, "Action")); this.oleDbUpdateCommand3.Parameters.Add(new System.Data.OleDb.OleDbParameter("Class", System.Data.OleDb.OleDbType.VarWChar, 50, "Class"));
{
if (this.BindingContext [this.dsre11 ,"re"].Position ==this.BindingContext [this.dsre11 ,"re"].Count -1)
{
this.BindingContext [this.dsre11 ,"re"].Position =0;
this.lBox .SelectedIndex =this.BindingContext [this.dsre11 ,"re"].Position ;
}
else
{
this.BindingContext [this.dsre11 ,"re"].Position ++;
this.lBox.SelectedIndex =this.BindingContext [this.dsre11 ,"re"].Position;
this.BindingContext [this.dsbe11 ,"be"].Position ++;
this.BindingContext [this.dsid11 ,"id"].Position ++;
}
} private void btnBack_Click(object sender, System.EventArgs e)
{
if (this.BindingContext [this.dsre11 ,"re"].Position ==0)
{
this.BindingContext [this.dsre11 ,"re"].Position =this.BindingContext [this.dsre11 ,"re"].Count -1;
this.lBox .SelectedIndex =this.BindingContext [this.dsre11 ,"re"].Position ;
}
else
{
this.BindingContext [this.dsre11 ,"re"].Position --;
this.lBox.SelectedIndex =this.BindingContext [this.dsre11 ,"re"].Position;
this.BindingContext [this.dsbe11 ,"be"].Position --;
this.BindingContext [this.dsid11 ,"id"].Position --;
}
} private void Form1_Load(object sender, System.EventArgs e)
{
try
{
IAct_Teach.localhost5.Service1 ws = new IAct_Teach.localhost5.Service1 ();
ws.Credentials =System.Net.CredentialCache.DefaultCredentials ;
dsre11.Merge (ws.getre());
dsbe11.Merge (ws.getbe());
dsid11.Merge (ws.getid ());
}
catch(System.Exception soe)
{
MessageBox.Show (soe.ToString() ,"IAct",MessageBoxButtons.OK ,MessageBoxIcon.Error );
}
} private void btnUpdate_Click(object sender, System.EventArgs e)
{
try
{
if (dsre11.HasChanges())
{
IAct_Teach.localhost5.Service1 ws =new IAct_Teach.localhost5.Service1() ;
ws.Credentials = System.Net.CredentialCache.DefaultCredentials;
IAct_Teach.localhost5.dsre1 diff = new IAct_Teach.localhost5.dsre1();
diff.Merge(dsre11.GetChanges());
diff = ws.updatere (diff);
dsre11.Merge (ws.getre ());
}
if (dsbe11.HasChanges() )
{
IAct_Teach.localhost5.Service1 ps=new IAct_Teach.localhost5.Service1() ;
ps.Credentials =System.Net.CredentialCache.DefaultCredentials ;
IAct_Teach.localhost5.dsbe1 diff1=new IAct_Teach.localhost5.dsbe1 ();
diff1.Merge (dsbe11.GetChanges ());
diff1=ps.updatebe (diff1);
dsbe11.Merge (ps.getbe ()); }
} catch(System.Exception soe)
{
MessageBox.Show (soe.ToString (),"IAct",MessageBoxButtons.OK ,MessageBoxIcon.Error );
}
} private void lBox_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (lBox.SelectedIndex != -1)
{
this.BindingContext [this.dsre11 ,"re"].Position=lBox.SelectedIndex;
this.BindingContext [this.dsbe11 ,"be"].Position=lBox.SelectedIndex;
this.BindingContext [this.dsid11 ,"id"].Position=lBox.SelectedIndex;
}
}
public dsid1 getid()
{
dsid1 dsid=new dsid1 ();
idada.Fill (dsid);
return dsid;
}
[WebMethod]
public dsid1 updateid(dsid1 ch)
{
if (ch!=null)
{
idada.Update (ch);
return ch;
}
else
return null;
}
[WebMethod]
public dsre1 getre()
{
dsre1 dsre=new dsre1 ();
reada.Fill (dsre);
return dsre;
}
[WebMethod]
public dsre1 updatere(dsre1 c)
{
if (c!=null)
{
reada.Update (c);
return c;
}
else
return null;
}
[WebMethod]
public dsbe1 getbe()
{
dsbe1 dsbe=new dsbe1 ();
beada.Fill (dsbe);
return dsbe;
}
[WebMethod]
public dsbe1 updatebe(dsbe1 cha)
{
if (cha!=null)
{
beada.Fill (cha);
return cha;
}
else
return null;
}
this.oleDbUpdateCommand3.CommandText = "UPDATE be SET ID = ?,Action = ?, Class = ?, Labor = ? WHERE (ID = ?) AND (Action" +
" = ? OR ? IS NULL AND Action IS NULL) AND (Class = ? OR ? IS NULL AND Class IS N" +
"ULL) AND (Labor = ? OR ? IS NULL AND Labor IS NULL)";
this.oleDbUpdateCommand3.Connection = this.oleDbConnection1;
this.oleDbUpdateCommand3.Parameters.Add(new System.Data.OleDb.OleDbParameter("ID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(10)), ((System.Byte)(0)), "ID", System.Data.DataRowVersion.Current, null));
this.oleDbUpdateCommand3.Parameters.Add(new System.Data.OleDb.OleDbParameter("Action", System.Data.OleDb.OleDbType.VarWChar, 50, "Action"));
this.oleDbUpdateCommand3.Parameters.Add(new System.Data.OleDb.OleDbParameter("Class", System.Data.OleDb.OleDbType.VarWChar, 50, "Class"));
this.oleDbUpdateCommand3.Parameters.Add(new System.Data.OleDb.OleDbParameter("Labor", System.Data.OleDb.OleDbType.VarWChar, 50, "Labor"));
this.oleDbUpdateCommand3.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(10)), ((System.Byte)(0)), "ID", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand3.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Action", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Action", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand3.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Action1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Action", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand3.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Class", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Class", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand3.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Class1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Class", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand3.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Labor", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Labor", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand3.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Labor1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Labor", System.Data.DataRowVersion.Original, null));