private void txtTundishNo_TextChanged(object sender, EventArgs e) { if (txtTundishNo.Text.Trim() != "") { AppSvrIF.Command cmdSQl = new AppSvrIF.Command(); string strSQL = string.Format("select TUNDISHID from XGMESLogic\\CCMMag\\CCCM_Tundish_Data where TUNDISHNO = '{0}'", txtTundishNo.Text); int iRet = Adapter.Session.CreateCommand((int)AppSvrIF.CommandType.QueryBySQL, strSQL, "", ref cmdSQl); if (iRet != 0) { MessageBox.Show(string.Format("查询中包号失败:{1:X}", iRet)); return; } iRet = Adapter.Session.Execute(cmdSQl); if (iRet != 0) { MessageBox.Show(string.Format("查询中包号失败:{1:X}", iRet)); return; } if (!(cmdSQl.Return is AppSvrIF.Recordset)) { return; } AppSvrIF.Recordset rs = cmdSQl.Return as AppSvrIF.Recordset; if (rs.Tables[0].Rows.Count < 1) { //MessageBox.Show(string.Format("查询出钢计划失败! 无法得到炉号{0}对应的工位!\n未找到炉号对应的计划!",HeatID)); return; } textBox1.Text = rs.Tables[0].Rows[0]["TUNDISHID"].ToString(); //DataRow row = rs.Tables[0].Rows[0]; } }
public DataTable GetData(AppSvrHMI.L3Adapter adapter, string strSql) { if (adapter.Session == null || !adapter.Session.Opened) { MessageBox.Show("adapter连接没有打开,请重新登陆"); return(null); } adapter.RefreshDataBindings(); AppSvrIF.Command cmdSQl = new AppSvrIF.Command(); int iRet = adapter.Session.CreateCommand((int)AppSvrIF.CommandType.QueryBySQL, strSql, "", ref cmdSQl); if (iRet != 0) { MessageBox.Show("创建查询命令失败,请重新登陆"); return(null); } iRet = adapter.Session.Execute(cmdSQl); if (iRet != 0) { MessageBox.Show("服务执行出现错误,请重新登陆"); return(null); } if (!(cmdSQl.Return is AppSvrIF.Recordset)) { MessageBox.Show("返回结果错误,请重新登陆"); return(null); } AppSvrIF.Recordset rs = cmdSQl.Return as AppSvrIF.Recordset; if (rs.Tables[0].Rows.Count < 1) { return(null); } else { return(rs.Tables[0]); } }
public static DataTable GetData(AppSvrHMI.L3Adapter adapter, string strSql) { if (adapter.Session == null || !adapter.Session.Opened) { MessageBox.Show("adapterÁ¬½ÓûÓдò¿ª£¬ÇëÖØеǽ"); return(null); } adapter.RefreshDataBindings(); AppSvrIF.Command cmdSQl = new AppSvrIF.Command(); int iRet = adapter.Session.CreateCommand((int)AppSvrIF.CommandType.QueryBySQL, strSql, "", ref cmdSQl); if (iRet != 0) { MessageBox.Show("´´½¨²éѯÃüÁîʧ°Ü£¬ÇëÖØеǽ"); return(null); } iRet = adapter.Session.Execute(cmdSQl); if (iRet != 0) { MessageBox.Show("·þÎñÖ´ÐгöÏÖ´íÎó£¬ÇëÖØеǽ"); return(null); } if (!(cmdSQl.Return is AppSvrIF.Recordset)) { MessageBox.Show("·µ»Ø½á¹û´íÎó£¬ÇëÖØеǽ"); return(null); } AppSvrIF.Recordset rs = cmdSQl.Return as AppSvrIF.Recordset; if (rs.Tables[0].Rows.Count < 1) { return(null); } else { return(rs.Tables[0]); } }