public static string fnGetOrderNum(HttpContext context, string sType) { KindRepository kindRepository = new KindRepository(); KindD kindD = new KindD(); kindD.KindId("O01") .CodeId("DATE") .CreateId(context.Session["id"].ToString()); string sNowDate = DateTime.Now.ToString("yyyyMMdd"); string sCodeDate = kindRepository.fnSelect(kindD); if (sNowDate != sCodeDate) { fnSetZeroOrder(); } kindD.CodeId(sType); string sNowNum = kindRepository.fnSelect(kindD); string sSql = " UPDATE [MNDTkind_details] " + " SET [parameter] = '" + (int.Parse(sNowNum) + 1).ToString() + "' " + " WHERE [kind_id] = 'O01' " + " AND [code_id] = '" + sType + "' "; PublicApi.fnExecuteSQL(sSql, "MNDT"); return(sNowDate + fnFixOrder(sNowNum)); }
public bool fnIsExist(KindD kindD) { string sSql = " SELECT COUNT([code_id]) " + " FROM [MNDTkind_details] " + " WHERE [kind_id] = '" + kindD.kind_id + "' " + " AND [code_id] = '" + kindD.code_id + "' "; return(PublicApi.fnGetValue(sSql, "MNDT") == "1"); }
public DataTable fnSelectList(KindD kindD) { string sSql = " SELECT [kind_d].[code_id] [value], " + " [kind_d].[name], " + " [kind_d].[parameter] " + " FROM [MNDTkind_details] AS [kind_d] " + " WHERE [kind_id] = '" + kindD.kind_id + "' " + " AND [status] = 'N' "; return(PublicApi.fnGetDt(sSql, "MNDT")); }
public string fnCount(KindD kindD) { string sCondition = ""; sCondition += PublicApi.fnAddCondition("[kind_id]", kindD.kind_id); string sCountSql = " SELECT COUNT([kind_id]) " + " FROM [MNDTkind_details] " + " WHERE 1 = 1 " + sCondition; string sPageSize = PublicApi.fnGetValue(sCountSql, "MNDT"); return(sPageSize); }
public string fnSelect(KindD kindD) { string sCondition = ""; sCondition += PublicApi.fnAddCondition("[kind_id]", kindD.kind_id); sCondition += PublicApi.fnAddCondition("[code_id]", kindD.code_id); string sSql = " SELECT TOP 1 [kind_d].[parameter] " + " FROM [MNDTkind_details] AS [kind_d] " + " WHERE 1 = 1 " + sCondition; return(PublicApi.fnGetValue(sSql, "MNDT")); }
public string fnDelete(KindD kindD, string sIP, string sId) { string sSql = " UPDATE [MNDTkind_details] " + " SET [status] = 'D' " + " WHERE [kind_id] = '" + kindD.kind_id + "' " + " AND [code_id] = '" + kindD.code_id + "' "; KindDTran kindDTran = new KindDTran(); kindDTran.KindId(kindD.kind_id) .CodeId(kindD.code_id) .IP(sIP) .Status("D") .CreateId(sId); sSql += fnInsertSql(kindDTran); return(PublicApi.fnExecuteSQL(sSql, "MNDT")); }
public string fnInsert(KindD kindD) { string sSql = " INSERT INTO [MNDTkind_details] " + " ([kind_id] " + " ,[code_id] " + " ,[name] " + " ,[parameter] " + " ,[create_id] " + " ,[create_datetime]) " + " VALUES " + " ('" + kindD.kind_id + "' " + " ,'" + kindD.code_id + "' " + " ,'" + kindD.name + "' " + " ,'" + kindD.parameter + "' " + " ,'" + kindD.create_id + "' " + " ,GETDATE()) "; return(PublicApi.fnExecuteSQL(sSql, "MNDT")); }
// iPage 第N頁 // iSize 最大顯示數量 public DataTable fnSelects(KindD kindD, int iPage, int iSize) { int iStart = (iPage - 1) * iSize + 1; int iEnd = iPage * iSize; string sCondition = ""; sCondition += PublicApi.fnAddCondition("[kind_id]", kindD.kind_id); string sInquireSql = " SELECT [kind_d].[code_id], " + " [kind_d].[name], " + " [kind_d].[parameter], " + " [kind_d].[status] " + " FROM (SELECT Row_number() OVER (ORDER BY [code_id] ASC) NUM, " + " * " + " FROM [MNDTkind_details] " + " WHERE 1 = 1 " + sCondition + ") AS [kind_d] " + " WHERE NUM BETWEEN " + iStart.ToString() + " AND " + iEnd.ToString() + " "; return(PublicApi.fnGetDt(sInquireSql, "MNDT")); }