Imports iMESExceptionManager Public Class frmStudentDef Inherits COM_Kit.frmDefTemplat '//Public Variables Public EditDataRow As DataRow Public DefMode As Integer = 0 '0. ADD, 1.Edit, 2. Copy Public PrivFunNo As String = defString '//Web Service相關變數 ' 2016 YF, Dim wsENT As New wsENT.wsENT Dim InXml As String Dim OutXml As String Dim strIdentity As String Dim strParameter As String Dim intDataStamp As Integer '紀錄DataStamp #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents txtSCORE As System.Windows.Forms.RichTextBox Friend WithEvents lblScore As System.Windows.Forms.Label Friend WithEvents lblStudentNo As System.Windows.Forms.Label Friend WithEvents lblStudentName As System.Windows.Forms.Label Friend WithEvents gbxStudentData As System.Windows.Forms.GroupBox Friend WithEvents txtStudentNo As Infragistics.Win.UltraWinEditors.UltraTextEditor Friend WithEvents txtStudentName As Infragistics.Win.UltraWinEditors.UltraTextEditor Private Sub InitializeComponent() Dim Appearance1 As Infragistics.Win.Appearance = New Infragistics.Win.Appearance() Dim Appearance2 As Infragistics.Win.Appearance = New Infragistics.Win.Appearance() Me.gbxStudentData = New System.Windows.Forms.GroupBox() Me.txtSCORE = New System.Windows.Forms.RichTextBox() Me.lblScore = New System.Windows.Forms.Label() Me.lblStudentNo = New System.Windows.Forms.Label() Me.lblStudentName = New System.Windows.Forms.Label() Me.txtStudentNo = New Infragistics.Win.UltraWinEditors.UltraTextEditor() Me.txtStudentName = New Infragistics.Win.UltraWinEditors.UltraTextEditor() CType(Me.gbxBasisData, System.ComponentModel.ISupportInitialize).BeginInit() Me.gbxStudentData.SuspendLayout() CType(Me.txtStudentNo, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.txtStudentName, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'gbxBasisData ' Me.gbxBasisData.Location = New System.Drawing.Point(12, 185) Me.gbxBasisData.Size = New System.Drawing.Size(479, 70) ' 'btnApply ' Me.btnApply.Location = New System.Drawing.Point(403, 264) ' 'btnConfirm ' Me.btnConfirm.Location = New System.Drawing.Point(215, 264) ' 'btnClose ' Me.btnClose.Location = New System.Drawing.Point(309, 264) ' 'gbxStudentData ' Me.gbxStudentData.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ Or System.Windows.Forms.AnchorStyles.Left) _ Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.gbxStudentData.Controls.Add(Me.txtSCORE) Me.gbxStudentData.Controls.Add(Me.lblScore) Me.gbxStudentData.Controls.Add(Me.lblStudentNo) Me.gbxStudentData.Controls.Add(Me.lblStudentName) Me.gbxStudentData.Controls.Add(Me.txtStudentNo) Me.gbxStudentData.Controls.Add(Me.txtStudentName) Me.gbxStudentData.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.gbxStudentData.Location = New System.Drawing.Point(12, 8) Me.gbxStudentData.Name = "gbxStudentData" Me.gbxStudentData.Size = New System.Drawing.Size(479, 169) Me.gbxStudentData.TabIndex = 7 Me.gbxStudentData.TabStop = False Me.gbxStudentData.Text = "Student Data" ' 'txtSCORE ' Me.txtSCORE.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtSCORE.Location = New System.Drawing.Point(128, 86) Me.txtSCORE.Name = "txtSCORE" Me.txtSCORE.Size = New System.Drawing.Size(334, 67) Me.txtSCORE.TabIndex = 2 Me.txtSCORE.Text = "" ' 'lblScore ' Me.lblScore.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lblScore.Location = New System.Drawing.Point(56, 88) Me.lblScore.Name = "lblScore" Me.lblScore.Size = New System.Drawing.Size(64, 14) Me.lblScore.TabIndex = 13 Me.lblScore.Text = "SCORE" Me.lblScore.TextAlign = System.Drawing.ContentAlignment.TopRight ' 'lblStudentNo ' Me.lblStudentNo.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lblStudentNo.Location = New System.Drawing.Point(24, 24) Me.lblStudentNo.Name = "lblStudentNo" Me.lblStudentNo.Size = New System.Drawing.Size(96, 32) Me.lblStudentNo.TabIndex = 5 Me.lblStudentNo.Text = "Student No" Me.lblStudentNo.TextAlign = System.Drawing.ContentAlignment.TopRight ' 'lblStudentName ' Me.lblStudentName.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lblStudentName.Location = New System.Drawing.Point(8, 56) Me.lblStudentName.Name = "lblStudentName" Me.lblStudentName.Size = New System.Drawing.Size(112, 32) Me.lblStudentName.TabIndex = 9 Me.lblStudentName.Text = "Student Name" Me.lblStudentName.TextAlign = System.Drawing.ContentAlignment.TopRight ' 'txtStudentNo ' Appearance1.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer)) Me.txtStudentNo.Appearance = Appearance1 Me.txtStudentNo.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer)) Me.txtStudentNo.Location = New System.Drawing.Point(128, 24) Me.txtStudentNo.Name = "txtStudentNo" Me.txtStudentNo.Size = New System.Drawing.Size(152, 22) Me.txtStudentNo.TabIndex = 0 ' 'txtStudentName ' Appearance2.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer)) Me.txtStudentName.Appearance = Appearance2 Me.txtStudentName.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer)) Me.txtStudentName.Location = New System.Drawing.Point(128, 55) Me.txtStudentName.Name = "txtStudentName" Me.txtStudentName.Size = New System.Drawing.Size(334, 22) Me.txtStudentName.TabIndex = 1 ' 'frmStudentDef ' Me.ClientSize = New System.Drawing.Size(503, 309) Me.Controls.Add(Me.gbxStudentData) Me.Font = New System.Drawing.Font("Times New Roman", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Name = "frmStudentDef" Me.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "ENT Student" Me.Controls.SetChildIndex(Me.btnClose, 0) Me.Controls.SetChildIndex(Me.btnConfirm, 0) Me.Controls.SetChildIndex(Me.btnApply, 0) Me.Controls.SetChildIndex(Me.gbxBasisData, 0) Me.Controls.SetChildIndex(Me.gbxStudentData, 0) CType(Me.gbxBasisData, System.ComponentModel.ISupportInitialize).EndInit() Me.gbxStudentData.ResumeLayout(False) Me.gbxStudentData.PerformLayout() CType(Me.txtStudentNo, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.txtStudentName, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) End Sub #End Region Private Sub frmStudentDef_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Cursor.Current = Cursors.WaitCursor Select Case DefMode Case 0 Me.Text = Me.Text & "(ADD)" Case 1 Me.Text = Me.Text & "(EDIT)" Case 2 Me.Text = Me.Text & "(Copy)" Case Else Me.Text = Me.Text & "(Unknown)" End Select '做為MainForm判斷是否重新LoadData的依據 gReturnKeyValue = "" ' 2016 YF, wsENT.Url = LocalizeWebService(wsENT.Url.ToString) ' 2016 YF, wsENT.EnableDecompression = True If Not EditDataRow Is Nothing Then txtStudentNo.Text = EditDataRow.Item("StudentNo").ToString txtStudentName.Text = EditDataRow.Item("StudentName").ToString 'txtScore是RichTextBox Control,因為TextBox無法正常顯示多行換行的資料 txtSCORE.Text = EditDataRow.Item("Score").ToString End If If DefMode = 0 Or DefMode = 2 Then 'Add or Copy SetCreator(gUserNo) SetCreateDate(Now) ElseIf DefMode = 1 Then 'Edit txtStudentNo.ReadOnly = True SetCreator(EditDataRow.Item("Creator").ToString) SetCreateDate(Convert.ToDateTime(EditDataRow.Item("CreateDate"))) SetReviser(gUserNo) SetReviseDate(Now) intDataStamp = EditDataRow.Item("DataStamp") End If btnApplyEnabled = False '語系切換 Call ExeChangeResource(Me, gLanguageMode) ExeGroupControlPriv(Me, PrivFunNo) Cursor.Current = Cursors.Default End Sub Private Sub frmStudentDef_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated If DefMode = 0 Or DefMode = 2 Then txtStudentNo.Focus() Else txtStudentName.Focus() End If End Sub Protected Overrides Sub btnConfirm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Cursor.Current = Cursors.WaitCursor If funAddorEdit(sender) < 0 Then Exit Sub Me.Close() Cursor.Current = Cursors.Default End Sub Protected Overrides Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Me.Close() End Sub Protected Overrides Sub btnApply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Cursor.Current = Cursors.WaitCursor If funAddorEdit(sender) < 0 Then Exit Sub If DefMode = 0 Or DefMode = 2 Then txtStudentNo.Focus() Else txtStudentName.Focus() End If Cursor.Current = Cursors.Default btnApplyEnabled = False End Sub Private Sub frmStudentDef_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing ' 2016 YF, If Not wsENT Is Nothing Then wsENT.Dispose() End Sub #Region "Control KeyPress" Private Sub txtStudentNo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtStudentNo.Click txtStudentNo.SelectAll() End Sub Private Sub txtStudentNo_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtStudentNo.Enter txtStudentNo.SelectAll() End Sub Private Sub txtStudentNo_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtStudentNo.KeyPress If e.KeyChar = Convert.ToChar(13) Then SendKeys.Send("{TAB}") End If End Sub Private Sub txtStudentNo_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtStudentNo.Leave txtStudentNo.Text = UCase(txtStudentNo.Text) End Sub Private Sub txtStudentNo_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtStudentNo.TextChanged btnApplyEnabled = True End Sub Private Sub txtStudentName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtStudentName.Click txtStudentName.SelectAll() End Sub Private Sub txtStudentName_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtStudentName.Enter txtStudentName.SelectAll() End Sub Private Sub txtStudentName_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtStudentName.KeyPress If e.KeyChar = Convert.ToChar(13) Then SendKeys.Send("{TAB}") End If End Sub Private Sub txtStudentName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtStudentName.TextChanged btnApplyEnabled = True End Sub Private Sub txtScore_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtSCORE.Click txtSCORE.SelectAll() End Sub Private Sub txtScore_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtSCORE.Enter txtSCORE.SelectAll() End Sub Private Sub txtScore_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSCORE.TextChanged btnApplyEnabled = True End Sub #End Region #Region "Others" Private Function funAddorEdit(sender As Object) As Integer funAddorEdit = -1 '****************************************************************************** '1.基本檢查 '****************************************************************************** If txtStudentNo.Text = "" Then iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-200001", "[%StudentNo%]"), MsgBoxStyle.Exclamation, Me.Text) txtStudentNo.Focus() Exit Function End If If txtStudentName.Text = "" Then iMESExceptionManager.ExceptionManager.iMESMsgBoxShowDialog(ChgTranslateName_Msg("0000-200001", "[%StudentName%]"), MsgBoxStyle.Exclamation, Me.Text) txtStudentName.Focus() Exit Function End If '2. '****************************************************************************** '寫回資料庫 '****************************************************************************** Dim XmlDoc As New XmlDocument Try strIdentity = CombineXMLIdentity(gComputerName, gUserNo, GetNow()) strParameter = CombineXMLParameter("studentno", "studentNo", "string", CInput(txtStudentNo.Text), "") strParameter = strParameter & CombineXMLParameter("studentname", "studentname", "string", CInput(txtStudentName.Text), "") strParameter = strParameter & CombineXMLParameter("score", "score", "string", CInput(txtSCORE.Text), "") If DefMode = 0 Or DefMode = 2 Then 'Add or Copy strParameter = strParameter & CombineXMLParameter("creator", "creator", "string", gUserNo, "") strParameter = strParameter & CombineXMLParameter("createdate", "createDate", "datetime", Format(Now, "yyyy/MM/dd HH:mm:ss"), "") InXml = CombineXMLRequest(strIdentity, strParameter) ' 2016 YF, OutXml = wsENT.AddStudent(InXml) OutXml = InvokeSrv("SXS.wsENT_21684.AddStudent", InXml) Else '修改 strParameter = strParameter & CombineXMLParameter("issuestate", "IssueState", "String", EditDataRow.Item("IssueState").ToString, "") ' 增加Datastamp strParameter += CombineXMLParameter("datastamp", "Datastamp", "Integer", intDataStamp, "") InXml = CombineXMLRequest(strIdentity, strParameter) ' 2016 YF, OutXml = wsENT.EditStudent(InXml) OutXml = InvokeSrv("SXS.wsENT_21684.EditStudent", InXml) End If XmlDoc.LoadXml(OutXml) If ChkExecutionSuccess(XmlDoc) Then gReturnKeyValue = txtStudentNo.Text funAddorEdit = 0 If sender.Equals(btnApply) Then intDataStamp += 1 End If Else ExceptionManager.iMESShowDialog(GetExceptionCode(XmlDoc), GetExceptionSysMsg(XmlDoc), GetExceptionStack(XmlDoc)) End If Catch ex As Exception 'MsgBox("Unexpected Error. Add or Edit ENT Student Failed!," & e1.Message, MsgBoxStyle.Exclamation) ExceptionManager.iMESShowDialog(defWinErrCode, ex.Message, ex.StackTrace) End Try XmlDoc = Nothing End Function Private Sub lblScore_Click(sender As Object, e As EventArgs) Handles lblScore.Click End Sub Private Sub btnConfirm_Click_1(sender As Object, e As EventArgs) Handles btnConfirm.Click End Sub Private Sub btnClose_Click_1(sender As Object, e As EventArgs) Handles btnClose.Click End Sub #End Region End Class