2024-01-15 14:20:27 +08:00
|
|
|
|
using iMESCore.Settings;
|
|
|
|
|
using Microsoft.VisualBasic;
|
|
|
|
|
using Microsoft.VisualBasic.CompilerServices;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using static iMESCore.Base.iMESComSubroutine;
|
|
|
|
|
using static iMESCore.Base.iMESComXML;
|
|
|
|
|
using static iMESCore.Base.iMESConst;
|
|
|
|
|
using static iMESCore.DataBase.iMESSql;
|
|
|
|
|
namespace MEStc_SXS
|
|
|
|
|
{
|
|
|
|
|
public class clsENT : IDisposable
|
|
|
|
|
{
|
|
|
|
|
/*不使用modXX,不再使用OleDb
|
|
|
|
|
* 資料庫相關(建立連線/讀取資料/異動資料),使用data_access_service.dll
|
|
|
|
|
* 設定檔相關,使用iMESAppSetting
|
|
|
|
|
* Xml相關,使用iMESComXML.dll
|
|
|
|
|
* 常數相關,使用iMESConst.dll
|
|
|
|
|
* 簡易副程式,使用iMESComSubroutine.dll
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private AppSettings objSetting = new AppSettings();
|
|
|
|
|
private string strConnectionString; // Connection string
|
|
|
|
|
private string strDataBaseType; // DataBase Type:oracle, mysql, access
|
|
|
|
|
private string strMQType; // MessageQueue Type:TIBCO, MQSeries, MSMQ
|
|
|
|
|
private bool disposed = false; // To detect redundant calls
|
|
|
|
|
private string strSQL = "";
|
|
|
|
|
private string strSQLAddField;
|
|
|
|
|
private string strSQLAddValue;
|
|
|
|
|
|
|
|
|
|
#region --- Initial Object ---
|
|
|
|
|
|
|
|
|
|
public clsENT()
|
2024-01-17 16:05:54 +08:00
|
|
|
|
{
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// Get database type
|
|
|
|
|
strDataBaseType = objSetting.GetDataBaseType();
|
|
|
|
|
// Get connection string
|
|
|
|
|
strConnectionString = objSetting.GetConnectionString(strDataBaseType);
|
|
|
|
|
// Get Message Queue Type
|
|
|
|
|
strMQType = objSetting.GetMQType();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region --- Property ---
|
|
|
|
|
|
|
|
|
|
// //Property--------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
public string ConnectionString
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return strConnectionString;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string DataBaseType
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return strDataBaseType;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string MQType
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return strMQType;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2003/03/22,sammi.
|
|
|
|
|
// 因TC可能呼叫KC,在整個Function中,必須要使用同一個Reverse物件,如此在產生AddReverseUpdateContent的資料時,ReverseOrder才不會重覆.
|
|
|
|
|
// 若KC再往下呼叫UD,則必須將Reverse物件傳遞予UD.
|
|
|
|
|
//public object ReverseObj
|
|
|
|
|
//{
|
|
|
|
|
// get
|
|
|
|
|
// {
|
|
|
|
|
// //return objReverse;
|
|
|
|
|
// // ReverseObj = objReverse
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region IDisposable Support
|
|
|
|
|
private bool disposedValue; // 偵測多餘的呼叫
|
|
|
|
|
|
|
|
|
|
// IDisposable
|
|
|
|
|
protected virtual void Dispose(bool disposing)
|
|
|
|
|
{
|
|
|
|
|
if (!disposedValue)
|
|
|
|
|
{
|
|
|
|
|
if (disposing)
|
|
|
|
|
{
|
|
|
|
|
// TODO: 處置 Managed 狀態 (Managed 物件)。
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: 釋放 Unmanaged 資源 (Unmanaged 物件) 並覆寫下面的 Finalize()。
|
|
|
|
|
// TODO: 將大型欄位設定為 null。
|
|
|
|
|
}
|
|
|
|
|
disposedValue = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: 只有當上面的 Dispose(ByVal disposing As Boolean) 有可釋放 Unmanaged 資源的程式碼時,才覆寫 Finalize()。
|
|
|
|
|
// Protected Overrides Sub Finalize()
|
|
|
|
|
// ' 請勿變更此程式碼。在上面的 Dispose(ByVal disposing As Boolean) 中輸入清除程式碼。
|
|
|
|
|
// Dispose(False)
|
|
|
|
|
// MyBase.Finalize()
|
|
|
|
|
// End Sub
|
|
|
|
|
|
|
|
|
|
// 由 Visual Basic 新增此程式碼以正確實作可處置的模式。
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
// 請勿變更此程式碼。在以上的 Dispose 置入清除程式碼 (ByVal 視為布林值處置)。
|
|
|
|
|
Dispose(true);
|
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
#region --- Student 外包商 ---
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
public string AddStudent(string StudentNo, string StudentName, string Score = defString, string Creator = defString, DateTime CreateDate = default(DateTime), string AdditionalXml = "")
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
string AddStudentRet = default(string);
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// 此 Function 將新增一筆資料
|
|
|
|
|
// 傳入值: 各欄位新增值
|
|
|
|
|
// 傳回值: success(成功), fail(失敗)
|
|
|
|
|
|
|
|
|
|
if (CreateDate == defDateTime)
|
|
|
|
|
CreateDate = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQLAddField = "Insert into tblENTChengJi (StudentNo, StudentName, IssueState";
|
|
|
|
|
strSQLAddValue = " Values ('" + StudentNo + "','" + StudentName + "', 0";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
if ((Score ?? "") != defString)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQLAddField += ",Score";
|
|
|
|
|
strSQLAddValue += ",'" + Score + "'";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
if ((Creator ?? "") != defString)
|
|
|
|
|
{
|
|
|
|
|
strSQLAddField += ",Creator";
|
|
|
|
|
strSQLAddValue += ",'" + Creator + "'";
|
|
|
|
|
}
|
|
|
|
|
if (CreateDate != defDateTime)
|
|
|
|
|
{
|
|
|
|
|
strSQLAddField += ",CreateDate";
|
|
|
|
|
strSQLAddValue += ", To_Date('" + Strings.Format(Conversions.ToDate(CreateDate), "yyyy/MM/dd H:mm:ss") + "','YYYY/MM/DD HH24:MI:SS')";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(AdditionalXml))
|
|
|
|
|
{
|
|
|
|
|
// 當沒有額外的欄位時,直接給定strSQL
|
|
|
|
|
strSQL = strSQLAddField + ")" + strSQLAddValue + ")";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// 加上additional的field & value 後傳回
|
|
|
|
|
strSQL = SeparateAddXML_Add(ref strSQLAddField, ref strSQLAddValue, AdditionalXml);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// //執行SQL指令
|
|
|
|
|
ExecuteSQLNoneQuery(Conversions.ToString(DataBaseType), strConnectionString, ref strSQL);
|
|
|
|
|
|
|
|
|
|
// //Return success
|
2024-01-17 16:05:54 +08:00
|
|
|
|
AddStudentRet = "success";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception e1)
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
AddStudentRet = "fail";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// 發生錯誤時丟回本身的Function Name及系統錯誤訊息
|
|
|
|
|
throw;
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
} // New Exception("kcENT.AddStudent: " & e1.Message)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
return AddStudentRet;
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
public string EditStudent(string StudentNo, string StudentName = defString, string Score = defString, string AdditionalXml = "", int DataStamp = defInteger, string Reviser = defString, DateTime ReviseDate = default(DateTime))
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
string EditStudentRet = default(string);
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// 此 Function 將修改一筆資料
|
|
|
|
|
// 傳入值: 各欄位修改值
|
|
|
|
|
// 傳回值: success(成功), fail(失敗)
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// 先給定strSQL一定有的欄位
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL = "Update tblENTChengJi Set ";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
if ((StudentName ?? "") != defString)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL += "StudentName = '" + StudentName + "',";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
2024-01-17 16:05:54 +08:00
|
|
|
|
if ((Score ?? "") != defString)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL += "Score = '" + Score + "',";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Reviser != defString)
|
|
|
|
|
strSQL = strSQL + "Reviser = '" + Reviser + "',";
|
|
|
|
|
|
|
|
|
|
if (ReviseDate != defDateTime)
|
|
|
|
|
strSQL = strSQL + "ReviseDate = To_Date('" + Strings.Format(ReviseDate, "yyyy/MM/dd H:mm:ss") + "','YYYY/MM/DD HH24:MI:SS'),";
|
|
|
|
|
|
|
|
|
|
if (DataStamp != defInteger)
|
|
|
|
|
strSQL = strSQL + "DataStamp = DataStamp + 1 ,";
|
|
|
|
|
|
|
|
|
|
// 有額外的欄位時再Append進原來的strSQL中
|
|
|
|
|
if (!string.IsNullOrEmpty(AdditionalXml))
|
|
|
|
|
{
|
|
|
|
|
// 加上additional的field & value
|
|
|
|
|
strSQL += SeparateAddXML_Edit(AdditionalXml);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 去除strSQL中最後一個 ","
|
|
|
|
|
if (Strings.InStr(1, strSQL, ",") != 0) // 表示有要修改的欄位
|
|
|
|
|
{
|
|
|
|
|
if (Strings.Right(strSQL, 1) == ",")
|
|
|
|
|
{
|
|
|
|
|
strSQL = Strings.Mid(strSQL, 1, Strings.Len(strSQL) - 1);
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL += " Where StudentNo ='" + StudentNo + "'";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
strSQL = strSQL + " And DataStamp = '" + DataStamp + "'";
|
|
|
|
|
|
|
|
|
|
// 有額外的條件式時再Append進原來的strSQL中
|
|
|
|
|
if (!string.IsNullOrEmpty(AdditionalXml))
|
|
|
|
|
{
|
|
|
|
|
// 加上additional的condition
|
|
|
|
|
strSQL += SeparateAddXML_Condition(AdditionalXml);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 呼叫執行SQL指令
|
|
|
|
|
ExecuteSQLNoneQuery(Conversions.ToString(DataBaseType), strConnectionString, ref strSQL, 1, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// //Return success
|
2024-01-17 16:05:54 +08:00
|
|
|
|
EditStudentRet = "success";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception e1)
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
EditStudentRet = "fail";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// 發生錯誤時丟回本身的Function Name及系統錯誤訊息
|
|
|
|
|
throw;
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
} // New Exception("kcENT.EditStudent: " & e1.Message)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
return EditStudentRet;
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
}
|
2024-01-17 16:05:54 +08:00
|
|
|
|
public string DelStudent(string StudentNo, string AdditionalXml = "")
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
string DelStudentRet = default(string);
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// 此 Function 將刪除資料
|
|
|
|
|
// 傳入值: 刪除的索引值
|
|
|
|
|
// 傳回值: success(成功), fail(失敗)
|
|
|
|
|
var CollectionSQL = new Collection();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
// 1. 刪除Parent
|
|
|
|
|
strSQL = "Delete From tblENTChengJiCont " + "Where StudentNo='" + StudentNo + "'";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
CollectionSQL.Add(strSQL);
|
|
|
|
|
|
|
|
|
|
// 2. 刪除主檔
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL = "Delete From tblENTChengJi " + " Where StudentNo ='" + StudentNo + "'";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(AdditionalXml))
|
|
|
|
|
{
|
|
|
|
|
// 加上additional的condition
|
|
|
|
|
strSQL += SeparateAddXML_Condition(AdditionalXml);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CollectionSQL.Add(strSQL);
|
|
|
|
|
|
|
|
|
|
// 呼叫執行SQL指令
|
|
|
|
|
ExecuteSQLNoneQuery_UPD(Conversions.ToString(DataBaseType), strConnectionString, CollectionSQL);
|
|
|
|
|
|
|
|
|
|
// //Return success
|
2024-01-17 16:05:54 +08:00
|
|
|
|
DelStudentRet = "success";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception e1)
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
DelStudentRet = "fail";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// 發生錯誤時丟回本身的Function Name及系統錯誤訊息
|
|
|
|
|
throw;
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
} // New Exception("kcENT.DelStudent: " & e1.Message)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
return DelStudentRet;
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
public string LoadStudent(string StudentNo = defString, int IssueState = defInteger, string AdditionalXml = "")
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
string LoadStudentRet = default(string);
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// 此 Function 將資料以XML方式取出
|
|
|
|
|
// 傳入值: 索引值
|
|
|
|
|
// 傳回值: XML(成功), fail(失敗)
|
|
|
|
|
|
|
|
|
|
var dsENT = default(DataSet);
|
|
|
|
|
IDbConnection cnnTemp = null;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// //Create connection
|
|
|
|
|
cnnTemp = CreateConnection(strConnectionString);
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL = "Select * From tblENTChengJi Where StudentNo Is Not Null";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
if ((StudentNo ?? "") != defString)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL += " And StudentNo = '" + StudentNo + "'";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
if (IssueState != defInteger)
|
|
|
|
|
{
|
|
|
|
|
strSQL += " And IssueState = " + IssueState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(AdditionalXml))
|
|
|
|
|
{
|
|
|
|
|
// 加上additional的condition
|
|
|
|
|
strSQL += SeparateAddXML_Condition(AdditionalXml);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// //Select data
|
|
|
|
|
dsENT = new DataSet();
|
2024-01-17 16:05:54 +08:00
|
|
|
|
ExecuteSQLQuery_Adapter(strSQL, dsENT, "tblENTChengJi", cnnTemp);
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
// //Combine return value
|
2024-01-17 16:05:54 +08:00
|
|
|
|
LoadStudentRet = CombineXMLReturnValue("loadStudent", "tblENTChengJi", "DataSet", FormatXMLSchema(dsENT.GetXmlSchema()), dsENT.GetXml(), "");
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception e1)
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
LoadStudentRet = "fail";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
throw;
|
2024-01-17 16:05:54 +08:00
|
|
|
|
} // New Exception("kcENT.LoadStudent: " & e1.Message)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
CloseConnection(cnnTemp);
|
|
|
|
|
if (dsENT != null)
|
|
|
|
|
{
|
|
|
|
|
dsENT.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
return LoadStudentRet;
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
public DataSet ShowStudent(string StudentNo = defString, int IssueState = defInteger, string AdditionalXml = "")
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
DataSet ShowStudentRet = default(DataSet);
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// 此 Function 將資料以 Dataset 方式取出
|
|
|
|
|
// 傳入值: 索引值
|
|
|
|
|
// 傳回值: Dataset(成功), Nothing(失敗)
|
|
|
|
|
|
|
|
|
|
var dsENT = default(DataSet);
|
|
|
|
|
IDbConnection cnnTemp = null;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// //Create connection
|
|
|
|
|
cnnTemp = CreateConnection(strConnectionString);
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL = "Select * From tblENTChengJi Where StudentNo Is Not Null";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
if ((StudentNo ?? "") != defString)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL += " And StudentNo = '" + StudentNo + "'";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
if (IssueState != defInteger)
|
|
|
|
|
{
|
|
|
|
|
strSQL += " And IssueState = " + IssueState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(AdditionalXml))
|
|
|
|
|
{
|
|
|
|
|
// 加上additional的condition
|
|
|
|
|
strSQL += SeparateAddXML_Condition(AdditionalXml);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// //Select data
|
|
|
|
|
dsENT = new DataSet();
|
2024-01-17 16:05:54 +08:00
|
|
|
|
ExecuteSQLQuery_Adapter(strSQL, dsENT, "tblENTChengJi", cnnTemp);
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
// //Return data
|
2024-01-17 16:05:54 +08:00
|
|
|
|
ShowStudentRet = dsENT;
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception e1)
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
ShowStudentRet = null;
|
2024-01-15 14:20:27 +08:00
|
|
|
|
throw;
|
2024-01-17 16:05:54 +08:00
|
|
|
|
} // New Exception("kcENT.ShowStudent: " & e1.Message)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
CloseConnection(cnnTemp);
|
|
|
|
|
if (dsENT != null)
|
|
|
|
|
{
|
|
|
|
|
dsENT.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
return ShowStudentRet;
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
public DataRow GetStudent(string StudentNo = defString, int IssueState = defInteger, string AdditionalXml = "")
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
DataRow GetStudentRet = default(DataRow);
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// 此 Function 將資料以 DataRow 方式取出
|
|
|
|
|
// 傳入值: 索引值
|
|
|
|
|
// 傳回值: DataRow(成功), Nothing(失敗)
|
|
|
|
|
|
|
|
|
|
var dsENT = default(DataSet);
|
|
|
|
|
IDbConnection cnnTemp = null;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// //Create connection
|
|
|
|
|
cnnTemp = CreateConnection(strConnectionString);
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL = "Select * From tblENTChengJi Where StudentNo Is Not Null";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
if ((StudentNo ?? "") != defString)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL += " And StudentNo = '" + StudentNo + "'";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
if (IssueState != defInteger)
|
|
|
|
|
{
|
|
|
|
|
strSQL += " And IssueState = " + IssueState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(AdditionalXml))
|
|
|
|
|
{
|
|
|
|
|
// 加上additional的condition
|
|
|
|
|
strSQL += SeparateAddXML_Condition(AdditionalXml);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// //Select data
|
|
|
|
|
dsENT = new DataSet();
|
2024-01-17 16:05:54 +08:00
|
|
|
|
ExecuteSQLQuery_Adapter(strSQL, dsENT, "tblENTChengJi", cnnTemp);
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
// //Return data
|
|
|
|
|
if (dsENT.Tables[0].Rows.Count > 0)
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
GetStudentRet = dsENT.Tables[0].Rows[0];
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
GetStudentRet = dsENT.Tables[0].NewRow();
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e1)
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
GetStudentRet = null;
|
2024-01-15 14:20:27 +08:00
|
|
|
|
throw;
|
2024-01-17 16:05:54 +08:00
|
|
|
|
} // New Exception("kcENT.GetStudent: " & e1.Message)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
CloseConnection(cnnTemp);
|
|
|
|
|
if (dsENT != null)
|
|
|
|
|
{
|
|
|
|
|
dsENT.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
return GetStudentRet;
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
}
|
2024-01-17 16:05:54 +08:00
|
|
|
|
public string SetStudentIssueState(string StudentNo, int IssueState, int DataStamp = defInteger, string Reviser = defString, DateTime ReviseDate = default(DateTime))
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
string SetStudentIssueStateRet = default(string);
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// 此 Function 將修改IssueState欄位的值
|
|
|
|
|
// 傳入值: IssueState修改後的值及VendorNo
|
|
|
|
|
// 傳回值: success(成功), fail(失敗)
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// 先給定strSQL一定有的欄位
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL = "Update tblENTChengJi Set IssueState = " + IssueState + ",";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
if (Reviser != defString)
|
|
|
|
|
strSQL = strSQL + "Reviser = '" + Reviser + "',";
|
|
|
|
|
|
|
|
|
|
if (ReviseDate != defDateTime)
|
|
|
|
|
strSQL = strSQL + "ReviseDate = To_Date('" + Strings.Format(ReviseDate, "yyyy/MM/dd H:mm:ss") + "','YYYY/MM/DD HH24:MI:SS'),";
|
|
|
|
|
|
|
|
|
|
if (DataStamp != defInteger)
|
|
|
|
|
strSQL = strSQL + "DataStamp = DataStamp + 1 ,";
|
|
|
|
|
|
|
|
|
|
if (Strings.InStr(1, strSQL, ",") != 0) // 表示有要修改的欄位
|
|
|
|
|
{
|
|
|
|
|
if (Strings.Right(strSQL, 1) == ",")
|
|
|
|
|
{
|
|
|
|
|
strSQL = Strings.Mid(strSQL, 1, Strings.Len(strSQL) - 1);
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL = strSQL + " Where StudentNo ='" + StudentNo + "'";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
strSQL = strSQL + " And DataStamp = '" + DataStamp + "'";
|
|
|
|
|
|
|
|
|
|
// 呼叫執行SQL指令
|
|
|
|
|
ExecuteSQLNoneQuery(Conversions.ToString(DataBaseType), strConnectionString, ref strSQL, 1, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// //Return success
|
2024-01-17 16:05:54 +08:00
|
|
|
|
SetStudentIssueStateRet = "success";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception e1)
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
SetStudentIssueStateRet = "fail";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// 發生錯誤時丟回本身的Function Name及系統錯誤訊息
|
|
|
|
|
throw;
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
} // New Exception("kcENT.SetStudentIssueState: " & e1.Message)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
return SetStudentIssueStateRet;
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
public string AddStudentCont(string StudentNo, string ParentName, string TelNo = defString, string FaxNo = defString, string Title = defString, string Address = defString, string EMail = defString, string Score = defString, string AdditionalXml = "", string Creator = defString, DateTime CreateDate = default(DateTime))
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
string AddStudentContRet = default(string);
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// 此 Function 將新增一筆資料
|
|
|
|
|
// 傳入值: 各欄位新增值
|
|
|
|
|
// 傳回值: success(成功), fail(失敗)
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQLAddField = "Insert into tblENTChengJiCont (StudentNo, ParentName";
|
|
|
|
|
strSQLAddValue = " Values ('" + StudentNo + "','" + ParentName + "'";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
if ((TelNo ?? "") != defString)
|
|
|
|
|
{
|
|
|
|
|
strSQLAddField += ",TelNo";
|
|
|
|
|
strSQLAddValue += ",'" + TelNo + "'";
|
|
|
|
|
}
|
|
|
|
|
if ((FaxNo ?? "") != defString)
|
|
|
|
|
{
|
|
|
|
|
strSQLAddField += ",FaxNo";
|
|
|
|
|
strSQLAddValue += ",'" + FaxNo + "'";
|
|
|
|
|
}
|
|
|
|
|
if ((Title ?? "") != defString)
|
|
|
|
|
{
|
|
|
|
|
strSQLAddField += ",Title";
|
|
|
|
|
strSQLAddValue += ",'" + Title + "'";
|
|
|
|
|
}
|
|
|
|
|
if ((Address ?? "") != defString)
|
|
|
|
|
{
|
|
|
|
|
strSQLAddField += ",Address";
|
|
|
|
|
strSQLAddValue += ",'" + Address + "'";
|
|
|
|
|
}
|
|
|
|
|
if ((EMail ?? "") != defString)
|
|
|
|
|
{
|
|
|
|
|
strSQLAddField += ",EMail";
|
|
|
|
|
strSQLAddValue += ",'" + EMail + "'";
|
|
|
|
|
}
|
|
|
|
|
if (Creator != defString)
|
|
|
|
|
{
|
|
|
|
|
strSQLAddField = strSQLAddField + ",Creator";
|
|
|
|
|
strSQLAddValue = strSQLAddValue + ",'" + Creator + "'";
|
|
|
|
|
}
|
|
|
|
|
if (CreateDate != defDateTime)
|
|
|
|
|
{
|
|
|
|
|
strSQLAddField = strSQLAddField + ",CreateDate";
|
|
|
|
|
strSQLAddValue = strSQLAddValue + ", To_Date('" + Strings.Format(CreateDate, "yyyy/MM/dd HH:mm:ss") + "','YYYY/MM/DD HH24:MI:SS')";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(AdditionalXml))
|
|
|
|
|
{
|
|
|
|
|
// 當沒有額外的欄位時,直接給定strSQL
|
|
|
|
|
strSQL = strSQLAddField + ")" + strSQLAddValue + ")";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// 加上additional的field & value 後傳回
|
|
|
|
|
strSQL = SeparateAddXML_Add(ref strSQLAddField, ref strSQLAddValue, AdditionalXml);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// //執行SQL指令
|
|
|
|
|
ExecuteSQLNoneQuery(Conversions.ToString(DataBaseType), strConnectionString, ref strSQL);
|
|
|
|
|
|
|
|
|
|
// //Return success
|
2024-01-17 16:05:54 +08:00
|
|
|
|
AddStudentContRet = "success";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception e1)
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
AddStudentContRet = "fail";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// 發生錯誤時丟回本身的Function Name及系統錯誤訊息
|
|
|
|
|
throw;
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
} // New Exception("kcENT.AddStudentCont: " & e1.Message)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
return AddStudentContRet;
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
public string EditStudentCont(string StudentNo, string ParentName, string TelNo = defString, string FaxNo = defString, string Title = defString, string Address = defString, string EMail = defString, string Score = defString, string AdditionalXml = "", int DataStamp = defInteger, string Reviser = defString, DateTime ReviseDate = default(DateTime))
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
string EditStudentContRet = default(string);
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
// 此 Function 將修改一筆資料
|
|
|
|
|
// 傳入值: 各欄位修改值
|
|
|
|
|
// 傳回值: success(成功), fail(失敗)
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// 先給定strSQL一定有的欄位
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL = "Update tblENTChengJiCont Set ";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
if ((TelNo ?? "") != defString)
|
|
|
|
|
{
|
|
|
|
|
strSQL += "TelNo = '" + TelNo + "',";
|
|
|
|
|
}
|
|
|
|
|
if ((FaxNo ?? "") != defString)
|
|
|
|
|
{
|
|
|
|
|
strSQL += "FaxNo = '" + FaxNo + "',";
|
|
|
|
|
}
|
|
|
|
|
if ((Title ?? "") != defString)
|
|
|
|
|
{
|
|
|
|
|
strSQL += "Title = '" + Title + "',";
|
|
|
|
|
}
|
|
|
|
|
if ((Address ?? "") != defString)
|
|
|
|
|
{
|
|
|
|
|
strSQL += "Address = '" + Address + "',";
|
|
|
|
|
}
|
|
|
|
|
if ((EMail ?? "") != defString)
|
|
|
|
|
{
|
|
|
|
|
strSQL += "EMail = '" + EMail + "',";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Reviser != defString)
|
|
|
|
|
strSQL = strSQL + "Reviser = '" + Reviser + "',";
|
|
|
|
|
|
|
|
|
|
if (ReviseDate != defDateTime)
|
|
|
|
|
strSQL = strSQL + "ReviseDate = To_Date('" + Strings.Format(ReviseDate, "yyyy/MM/dd H:mm:ss") + "','YYYY/MM/DD HH24:MI:SS'),";
|
|
|
|
|
|
|
|
|
|
if (DataStamp != defInteger)
|
|
|
|
|
strSQL = strSQL + "DataStamp = DataStamp + 1 ,";
|
|
|
|
|
|
|
|
|
|
// 有額外的欄位時再Append進原來的strSQL中
|
|
|
|
|
if (!string.IsNullOrEmpty(AdditionalXml))
|
|
|
|
|
{
|
|
|
|
|
// 加上additional的field & value
|
|
|
|
|
strSQL += SeparateAddXML_Edit(AdditionalXml);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 去除strSQL中最後一個 ","
|
|
|
|
|
if (Strings.InStr(1, strSQL, ",") != 0) // 表示有要修改的欄位
|
|
|
|
|
{
|
|
|
|
|
if (Strings.Right(strSQL, 1) == ",")
|
|
|
|
|
{
|
|
|
|
|
strSQL = Strings.Mid(strSQL, 1, Strings.Len(strSQL) - 1);
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL += " Where StudentNo = '" + StudentNo + "'" + " And ParentName ='" + ParentName + "'";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
strSQL = strSQL + " And DataStamp = '" + DataStamp + "'";
|
|
|
|
|
|
|
|
|
|
// 有額外的條件式時再Append進原來的strSQL中
|
|
|
|
|
if (!string.IsNullOrEmpty(AdditionalXml))
|
|
|
|
|
{
|
|
|
|
|
// 加上additional的condition
|
|
|
|
|
strSQL += SeparateAddXML_Condition(AdditionalXml);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 呼叫執行SQL指令
|
|
|
|
|
ExecuteSQLNoneQuery(Conversions.ToString(DataBaseType), strConnectionString, ref strSQL, 1, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// //Return success
|
2024-01-17 16:05:54 +08:00
|
|
|
|
EditStudentContRet = "success";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception e1)
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
EditStudentContRet = "fail";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// 發生錯誤時丟回本身的Function Name及系統錯誤訊息
|
|
|
|
|
throw;
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
} // New Exception("kcENT.EditStudentCont: " & e1.Message)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
return EditStudentContRet;
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
public string DelStudentCont(string StudentNo, string ParentName = defString, string AdditionalXml = "")
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
string DelStudentContRet = default(string);
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// 此 Function 將刪除資料
|
|
|
|
|
// 傳入值: 刪除的索引值
|
|
|
|
|
// 傳回值: success(成功), fail(失敗)
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL = "Delete From tblENTChengJiCont " + " Where StudentNo='" + StudentNo + "'";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
if ((ParentName ?? "") != defString)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL += " And ParentName = '" + ParentName + "'";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(AdditionalXml))
|
|
|
|
|
{
|
|
|
|
|
// 加上additional的condition
|
|
|
|
|
strSQL += SeparateAddXML_Condition(AdditionalXml);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 呼叫執行SQL指令
|
|
|
|
|
ExecuteSQLNoneQuery(Conversions.ToString(DataBaseType), strConnectionString, ref strSQL);
|
|
|
|
|
|
|
|
|
|
// //Return success
|
2024-01-17 16:05:54 +08:00
|
|
|
|
DelStudentContRet = "success";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception e1)
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
DelStudentContRet = "fail";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// 發生錯誤時丟回本身的Function Name及系統錯誤訊息
|
|
|
|
|
throw;
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
} // New Exception("kcENT.DelStudentCont: " & e1.Message)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
return DelStudentContRet;
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
public string LoadStudentCont(string StudentNo = defString, string ParentName = defString, string AdditionalXml = "")
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
string LoadStudentContRet = default(string);
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// 此 Function 將資料以XML方式取出
|
|
|
|
|
// 傳入值: 索引值
|
|
|
|
|
// 傳回值: XML(成功), fail(失敗)
|
|
|
|
|
|
|
|
|
|
var dsENT = default(DataSet);
|
|
|
|
|
IDbConnection cnnTemp = null;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// //Create connection
|
|
|
|
|
cnnTemp = CreateConnection(strConnectionString);
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL = "Select * From tblENTChengJiCont Where StudentNo Is Not Null";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
// 有傳入StudentNo表示只取該StudentNo之資料
|
|
|
|
|
if ((StudentNo ?? "") != defString)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL += " And StudentNo = '" + StudentNo + "'";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
2024-01-17 16:05:54 +08:00
|
|
|
|
if ((ParentName ?? "") != defString)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL += " And ParentName = '" + ParentName + "'";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(AdditionalXml))
|
|
|
|
|
{
|
|
|
|
|
// 加上additional的condition
|
|
|
|
|
strSQL += SeparateAddXML_Condition(AdditionalXml);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// //Select data
|
|
|
|
|
dsENT = new DataSet();
|
2024-01-17 16:05:54 +08:00
|
|
|
|
ExecuteSQLQuery_Adapter(strSQL, dsENT, "tblENTChengJiCont", cnnTemp);
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
// //Combine return value
|
2024-01-17 16:05:54 +08:00
|
|
|
|
LoadStudentContRet = CombineXMLReturnValue("loadStudentcont", "tblENTChengJiCont", "DataSet", FormatXMLSchema(dsENT.GetXmlSchema()), dsENT.GetXml(), "");
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception e1)
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
LoadStudentContRet = "fail";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
throw;
|
2024-01-17 16:05:54 +08:00
|
|
|
|
} // New Exception("kcENT.LoadStudentCont: " & e1.Message)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
CloseConnection(cnnTemp);
|
|
|
|
|
if (dsENT != null)
|
|
|
|
|
{
|
|
|
|
|
dsENT.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
return LoadStudentContRet;
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
public DataSet ShowStudentCont(string StudentNo = defString, string ParentName = defString, string AdditionalXml = "")
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
DataSet ShowStudentContRet = default(DataSet);
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// 此 Function 將資料以 Dataset 方式取出
|
|
|
|
|
// 傳入值: 索引值
|
|
|
|
|
// 傳回值: Dataset(成功), Nothing(失敗)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dsENT = default(DataSet);
|
|
|
|
|
IDbConnection cnnTemp = null;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// //Create connection
|
|
|
|
|
cnnTemp = CreateConnection(strConnectionString);
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL = "Select * From tblENTChengJiCont Where StudentNo Is Not Null";
|
|
|
|
|
if ((StudentNo ?? "") != defString)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL += " And StudentNo = '" + StudentNo + "'";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
2024-01-17 16:05:54 +08:00
|
|
|
|
if ((ParentName ?? "") != defString)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL += " And ParentName = '" + ParentName + "'";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(AdditionalXml))
|
|
|
|
|
{
|
|
|
|
|
// 加上additional的condition
|
|
|
|
|
strSQL += SeparateAddXML_Condition(AdditionalXml);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// //Select data
|
|
|
|
|
dsENT = new DataSet();
|
2024-01-17 16:05:54 +08:00
|
|
|
|
ExecuteSQLQuery_Adapter(strSQL, dsENT, "tblENTChengJiCont", cnnTemp);
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
// //Return data
|
2024-01-17 16:05:54 +08:00
|
|
|
|
ShowStudentContRet = dsENT;
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception e1)
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
ShowStudentContRet = null;
|
2024-01-15 14:20:27 +08:00
|
|
|
|
throw;
|
2024-01-17 16:05:54 +08:00
|
|
|
|
} // New Exception("kcENT.ShowStudentCont: " & e1.Message)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
CloseConnection(cnnTemp);
|
|
|
|
|
if (dsENT != null)
|
|
|
|
|
{
|
|
|
|
|
dsENT.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
return ShowStudentContRet;
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
public DataRow GetStudentCont(string StudentNo = defString, string ParentName = defString, string AdditionalXml = "")
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
DataRow GetStudentContRet = default(DataRow);
|
2024-01-15 14:20:27 +08:00
|
|
|
|
// 此 Function 將資料以 DataRow 方式取出
|
|
|
|
|
// 傳入值: 索引值
|
|
|
|
|
// 傳回值: DataRow(成功), Nothing(失敗)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dsENT = default(DataSet);
|
|
|
|
|
IDbConnection cnnTemp = null;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// //Create connection
|
|
|
|
|
cnnTemp = CreateConnection(strConnectionString);
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL = "Select * From tblENTChengJiCont Where StudentNo Is Not Null";
|
|
|
|
|
if ((StudentNo ?? "") != defString)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL += " And StudentNo = '" + StudentNo + "'";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
2024-01-17 16:05:54 +08:00
|
|
|
|
if ((ParentName ?? "") != defString)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
strSQL += " And ParentName = '" + ParentName + "'";
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(AdditionalXml))
|
|
|
|
|
{
|
|
|
|
|
// 加上additional的condition
|
|
|
|
|
strSQL += SeparateAddXML_Condition(AdditionalXml);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// //Select data
|
|
|
|
|
dsENT = new DataSet();
|
2024-01-17 16:05:54 +08:00
|
|
|
|
ExecuteSQLQuery_Adapter(strSQL, dsENT, "tblENTChengJiCont", cnnTemp);
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
// //Return data
|
|
|
|
|
if (dsENT.Tables[0].Rows.Count > 0)
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
GetStudentContRet = dsENT.Tables[0].Rows[0];
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
GetStudentContRet = dsENT.Tables[0].NewRow();
|
2024-01-15 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e1)
|
|
|
|
|
{
|
2024-01-17 16:05:54 +08:00
|
|
|
|
GetStudentContRet = null;
|
2024-01-15 14:20:27 +08:00
|
|
|
|
throw;
|
2024-01-17 16:05:54 +08:00
|
|
|
|
} // New Exception("kcENT.GetStudentCont: " & e1.Message)
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
CloseConnection(cnnTemp);
|
|
|
|
|
if (dsENT != null)
|
|
|
|
|
{
|
|
|
|
|
dsENT.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-17 16:05:54 +08:00
|
|
|
|
return GetStudentContRet;
|
2024-01-15 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|