WINCE访问webservice
wince 访问webservice 总是出现这个问题 ,只有偶尔才可以连接正确。基础已经关闭:接收时发生错误把你C#写的程序代码列出来啊, fxyc87 发表于 2018-7-4 14:08
把你C#写的程序代码列出来啊,
后台代码:
/// <summary>
/// 查询,返回datatable
/// </summary>
/// <param name="param">参数</param>
/// <param name="sql">sql语句</param>
/// <param name="info">数据库信息</param>
/// <returns>datatable</returns>
public static DataTable SelectDataTable(DataTable param, string sql, string info)
{
DataTable dt = new DataTable("result");
SqlConnection conn = OpenCloseDB.OpenDatabase(info);
try
{
SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
adapter.SelectCommand.Parameters.Clear();
if (param != null)
{
foreach (DataRow dic in param.Rows)
{
adapter.SelectCommand.Parameters.AddWithValue(Dtv(dic, "name", string.Empty), Dtv(dic, "value", string.Empty));
}
}
adapter.Fill(dt);
adapter = null;
}
catch (Exception ex)
{
Common.WriteLog(ex, "查询返回表格", "");
return dt;
}
finally
{
OpenCloseDB.CloseDatabase(conn);
}
return dt;
}
前台代码: private void Query()
{
string billno = this.txt_Billno.Text.Trim();
string sql = "select ic.FNumber , CEILING(ie.FAuxQtyMust) as FAuxQtyMust , CEILING(ie.FAuxQty) asFAuxQty , case ie.FAuxQtyMust when 0 then 0 else (ie.FQtyMust/ie.FAuxQtyMust) end as fsecqty, ic.FModel , tp.FNameas stockplace "
+ " ,ib.FStatus, ie.fentryid, ib.finteridfrom ICStockBill ib inner join ICStockBillEntry ie on ib.FInterID = ie.FInterID "
+ "inner join t_ICItem ic on ie.FItemID = ic.FItemID "
+ " inner join t_StockPlace tp on ie.FDCSPID = tp.FSPID "
+ " where ib.FBillNo like '%" + billno + "%' and ib.fbillno like 'SOUT%' ";
try
{
DataTable t = WebRef.obj.SelectDataTable(null, sql, login.conn);
detail.Clear();
if (t != null && t.Rows.Count > 0)
{
if (t.Rows["FStatus"].ToString() == "1")
{
MessageBox.Show("单据已审核");
this.txt_Billno.Text = "";
return;
}
foreach (DataRow dd in t.Rows)
{
DataRow dr = this.detail.NewRow();
dr["fentryid"] = dd["fentryid"];
dr["FQty"] = dd["FAuxQty"];
dr["FAuxQty"] =0;
dr["FSecQty"] = dd["fsecqty"];
dr["FModel"] = dd["FModel"].ToString();
dr["stockplace"] = dd["stockplace"].ToString();
dr["FNumber"] = dd["FNumber"].ToString();
dr["finterid"] = dd["finterid"];
this.detail.Rows.Add(dr);
this.detail.AcceptChanges();
}
sql = "select yz.fmodel, count(1) as num from yzbarcode_tmp yt inner join yz_icitem yz on yt.bptype = yz.bptype where chukubillno = '" + billno + "' and isvalid = 1 group by yz.fmodel ";
DataTable bindingDT = WebRef.obj.SelectDataTable(null, sql, login.conn);
if (bindingDT != null || bindingDT.Rows.Count > 0)
{
foreach(DataRow r in bindingDT.Rows)
{
int num = (int)r["num"];
DataRow[] drs = detail.Select("FModel = '" + r["fmodel"].ToString() + "'");
if (drs != null && drs.Length > 0)
{
foreach (DataRow rr in drs)
{
if (num > 0)
{
int qty = (int)rr["FQty"];
if (num > qty)
{
rr["FAuxQty"] = qty;
num -= qty;
}
else
{
rr["FAuxQty"] = num;
num = 0;
}
}
}
}
}
this.detail.AcceptChanges();
}
}
scBillno = billno;
}
catch (Exception ex)
{
MessageBox.Show("异常:" + ex.ToString());
return;
}
}
页:
[1]