书格www.shuge.org

书格是一个自由开放的在线古籍图书馆。致力于开放式分享、介绍、推荐有价值的古籍善本,并鼓励将文化艺术作品数字化归档。分享内容限定为公共版权领域的书籍(参照标准
伯尔尼公约 
[2]);我们最大限度地还原书籍品貌、内容;借此计划让大家自由、免费地欣赏到那些难以现世的书籍。让大家能从中感受到人类文明进程。

书格发布的书籍主要以高清彩色影像版本 PDF 格式,大部分书籍书籍单页宽度在 1400 像素以上,跨页宽度在 2400 像素以上。书籍刊行年代有从宋元珍本,明清善本到近代刊本。

在可能的情况下,面对同一书籍,我们尽量遵循刊行质量和时间优先,挑选同类中最优资源分享介绍。部分书籍会同比列出不同版本的优秀资源。在内容方面,我们尽量挑选欣赏和在阅读价值较高的善本,所以我们更倾向于:艺术类、影像类、珍稀类以及部分刊印水平较高的书籍。

www.shuge.org

C# 自定义对话框_笔记

新建一个项目,添加Form2。

设置如下属性:


this.ControlBox = false;


this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;


this.MaximizeBox = false;


this.MinimizeBox = false;

添加如下两个按钮

将画面属性中两个属性做如下设置:

this.AcceptButton = this.button1;

this.CancelButton = this.button2;

 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

 

namespace WindowsFormsApplication23

{


public
partial
class
Form2 : Form

{


public
string s1 = null;


public Form2()

{

InitializeComponent();

}

 


private
void button1_Click(object sender, EventArgs e)

{


this.s1 = this.textBox1.Text;


this.DialogResult = DialogResult.OK;

}

 


private
void button2_Click(object sender, EventArgs e)

{


this.DialogResult = DialogResult.Cancel;

}

}

}

Form2做如下设置

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

 

namespace WindowsFormsApplication23

{


public
partial
class
Form1 : Form

{


public Form1()

{

InitializeComponent();

}

 


private
void button1_Click(object sender, EventArgs e)

{


Form2 f2 = new
Form2();


if(f2.ShowDialog()==DialogResult.OK)

{


this.Text = f2.s1;

}


else

{


this.Text = null;

}

f2.Dispose();

}

}

}

徐大军

iFIX 获取用户名和组名

获取用户名和组名的方法(调度的后台执行)

调度程序设置为后台执行,并且设定好刷新时间为1秒

Private Sub FixTimer3_OnTimeOut(ByVal lTimerId As Long)

 

On Error GoTo errdata

Dim sUserID As String

Dim sUserName As String

Dim sGroupName As String

System.FixGetUserInfo sUserID, sUserName, sGroupName

 

Dim WrkSpcApp As Object

Set WrkSpcApp = GetObject(“”, “Workspace.Application”)

 

‘ Get a pointer to the Variable object called Variable1 in the User globals

Dim TargetVar As Object

Set TargetVar = WrkSpcApp.Documents(“xudajun_username”).Page.FindObject(“TextBox1”)

TargetVar.Text = sUserName

Set TargetVar = WrkSpcApp.Documents(“xudajun_username”).Page.FindObject(“TextBox2”)

TargetVar.Text = sGroupName

errdata:

Exit Sub

 

End Sub

获取用户名和组名的方法(属性)

关于用户名和用户组以下两个属性

System.LoginUserFullName

用户的登陆全称

System. LoginGroup

用户所属的首个组名

徐大军

iFIX SQLServer数据库读写

‘数据库链接字符串

Const CONSTR = “Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ceshiku;Data Source=WIN-M2JO4N9DQ4O”

 

Dim Conn As ADODB.Connection

Dim Rs As ADODB.Recordset

Dim SQL As String

 

‘读取数据

Private Sub CommandButton1_Click()

Set Conn = New ADODB.Connection

Conn.ConnectionString = CONSTR

Conn.Open

SQL = “SELECT * FROM ceshibiao ORDER BY ID”

Set Rs = New ADODB.Recordset

Rs.Open SQL, Conn

Do While Not Rs.EOF

MsgBox Rs.Fields(“ID”) & Rs.Fields(“Value1”)

Rs.MoveNext

Loop

Rs.Close

Set Rs = Nothing

Conn.Close

Set Conn = Nothing

SQL = vbNullString

End Sub

‘添加数据

Private Sub CommandButton2_Click()

Set Conn = New ADODB.Connection

Conn.ConnectionString = CONSTR

Conn.Open

 

‘SQL = “INSERT INTO ceshibiao(ID,DataTime1,Value1,Value2) VALUES (,null,123.0,456.0)”

‘ID定义的是自增关键词,使用时应注意不予赋值,上句语法错误,DataTime1为DataTime类型,设置中允许null赋值

Dim t As String

t = Msecond()

SQL = “INSERT INTO ceshibiao VALUES (getdate(),123.0,456.0)”

 

Dim cmd As ADODB.Command

Set cmd = New ADODB.Command

cmd.ActiveConnection = Conn

cmd.CommandType = adCmdText

cmd.CommandText = SQL

cmd.Execute

 

Conn.Close

Set Conn = Nothing

 

End Sub

 

徐大军

iFIX时间获取,精确到毫秒

‘获取系统的精确时间,精确到毫秒

Private Function Msecond() As String

‘Get system time

Dim t As Double

Dim h, m, s As Integer

Dim ss As String

 

t = Timer

h = Int(t / 3600)

m = Int((t – 3600 * h) / 60)

s = Int(t – h * 3600 – m * 60)

 

If InStr(1, CStr(t), “.”) <> 0 Then

ss = Mid(CStr(t), InStr(1, CStr(t), “.”), 4)

Else

ss = “.”

End If

 

Select Case Len(ss)

Case 0, 1

ss = “.000”

Case 2

ss = ss & “00”

Case 3

ss = ss & “0”

End Select

 

Msecond = Format(Now, “yyyy/mm/dd hh:mm:ss”) & ss

End Function

徐大军

退出iFIX系统代码

Private Sub Btn_Exit_Click()

If MsgBox(“Want to exit the application? “, vbExclamation + vbYesNo, “Quit system”) = vbYes Then

Dim hw As Long, cnt As Long

hw = FindWindow(“iFix Startup”, vbNullString)

If hw = 0 Then

hw = FindWindow(“iFix Startup – DEMO MODE”, vbNullString)

End If

If hw <> 0 Then

‘Send close message to windows

cnt = SendMessage(hw, &H10, 0, 0&)

End If

End If

End Sub

徐大军

iFIX访问其它页面的控件?

示例在调度的脚本中访问画面上的对象的属性,访问时应保证被访问画面处于打开状态

Private Sub FixTimer3_OnTimeOut(ByVal lTimerId As Long)

Dim WrkSpcApp As Object

Set WrkSpcApp = GetObject(“”, “Workspace.Application”)

 

‘ Get a pointer to the Variable object called Variable1 in the User globals

Dim TargetVar As Object

Set TargetVar = WrkSpcApp.Documents(“PIC1”).Page.FindObject(“TEXT1”)

MsgBox TargetVar.Caption

End Sub

徐大军

使用Excel获取Historian中的数据

有时候我们想看一下Historian中的数据,可以用Excel直接查看

暂时使用英文版的Excel吧,电脑中没有中文版的,不过系统是多语言的,现在设置成中文了,过程中会出现中文画面。

首先打开Excel软件

DATA菜单àFrom Other SourcesàFrom Data Connection Wizard

选择如下图所示,然后Next

选择对用的驱动

点击测试连接,当然Historian安装的时候设置了用户名和密码的话需要填写,显示连接成功,错误不用管

我们选择图中所示的表格,如果会SQL语句的话,也可以使用语句

点击Finish后,出现下图画面

至此,数据被读取到了Excel中

徐大军