WinCE在调用WebService时候不定时出现无法连接服务器 代码如下:求大神解决 int num = -1;
if (txt_Vin.Text != "" && txt_location.Text != "")
{
string vin = this.txt_Vin.Text.Trim();
string AL = this.txt_location.Text.Trim();
string Area_Code = AL.Split('-')[0].ToString();
string Location_No = AL.Split('-')[1].ToString();
try
{
num = Fu.Login.In_Car(vin, W_ID, Area_Code, Location_No); }
catch(Exception ex)
{
LogerHelper.WriteLog(ex.Message + " print into car error.");
MessageBox.Show("print into car error!");
}
//In_Car.Dispose();
if (num == 1)
{
MessageBox.Show("入库成功!");
//重新绑定列表数据
ViewBind();
txt_Vin.Text = "";
txt_location.Text = "";
txt_Vin.Focus();
}
else if (num == 0)
{
MessageBox.Show("入库失败!");
txt_Vin.Text = "";
txt_location.Text = "";
txt_Vin.Focus();
}
else if (num == 2)
{
MessageBox.Show("此车辆不为待入库车辆!");
txt_Vin.Text = "";
txt_location.Text = "";
txt_Vin.Focus();
}
}
else
{
MessageBox.Show("Vin码或库位都不能为空!");
txt_location.Text = "";
txt_Vin.Text = "";
txt_Vin.Focus();
}
WebService代码如下:
public int In_Car(string Vin,string W_ID,string Area_Code,string Location_No)
{
int result = 0;
string sql = "select VIN_Number,Brand_Code,Inventory_ID from TBL_Inventory_records_Detail where VIN_Number='" + Vin + "' and InventoryStauts=0 and Warehouse_ID='" + W_ID + "' and Area_Code='" + Area_Code + "' and Location_No='" + Location_No + "'";
DataTable orname = SQLHelper.ExecuteDataTable(CommandType.Text, sql);
if (orname.Rows.Count != 0)
{
string ID = orname.Rows[0]["Inventory_ID"].ToString();
string Update = "update TBL_Inventory_records_Detail set InventoryStauts=1 where Inventory_ID='" + ID + "'";
int couO = SQLHelper.ExecuteNonQuery(CommandType.Text, Update);
if (couO > 0)
{
result = 1;//入库成功!
}
else
{
result = 0;//入库失败!
}
}
else
{
result = 2;//此车辆信息不为待入库车辆
}
return result;
}