Example #1
0
 /// <summary>
 /// 使用session执行sql命令(update,insert)
 /// 返回0则成功,其他为错误代码
 /// </summary>
 /// <param name="sql"></param>
 /// <returns></returns>
 public static string exeSql(AppSvrHMI.L3Adapter adapter, string strSql)
 {
     try
     {
         if (adapter.Session == null || !adapter.Session.Opened)
         {
             //MessageBox.Show("adapter连接没有打开,请重新登陆");
             return(null);
         }
         AppSvrIF.Command cmd = null;
         //创建sql命令
         int result = adapter.Session.CreateCommand(14, strSql, "", ref cmd);
         if (result == 0)
         {
             //使用session执行sql命令
             return(adapter.Session.Execute(cmd).ToString());
         }
         else
         {
             return(result.ToString());
         }
     }
     catch (Exception ex)
     {
         return(ex.ToString());
     }
 }
Example #2
0
        public AppSvrHMI.L3DataSet ShowDialogExL(AppSvrHMI.L3Adapter adapter, int nPosition, string strSort, AppSvrHMI.L3DataSet dsData)
        {
            Adapter      = adapter;
            txtCopy.Text = "";
            dsReturn     = dsData;

            bsDesStdMainten.DataSource = null;
            bsDesStdMainten.DataSource = dsReturn;
            bsDesStdMainten.DataMember = dsReturn.Tables[0].TableName;

            ((System.Data.DataRowView)(bsDesStdMainten.Current)).DataView.Sort = strSort;
            bsDesStdMainten.Position = nPosition;
            strSteelGradeIndex       = dsData.Tables[0].Rows[nPosition]["SteelGradeIndex"].ToString();

            ShowDialog();

            return(dsReturn);
        }
Example #3
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]);
            }
        }
Example #4
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]);
            }
        }