// iPage 第N頁 // iSize 最大顯示數量 public DataTable fnSelects(ReturnM returnM, int iPage, int iSize) { int iStart = (iPage - 1) * iSize + 1; int iEnd = iPage * iSize; string sCondition = ""; sCondition += PublicApi.fnAddCondition("[order_id]", returnM.order_id); sCondition += PublicApi.fnAddCondition("[return_id]", returnM.return_id); sCondition += PublicApi.fnAddCondition("[id]", returnM.id); sCondition += PublicApi.fnAddCondition("CONVERT(varchar(10), [datetime], 126)", returnM.datetime); string sInquireSql = " SELECT [return_m].[NUM], " + " [return_m].[return_id], " + " [return_m].[order_id], " + " [return_m].[id], " + " [return_m].[complete], " + " CONVERT(CHAR, [return_m].[datetime], 111) [datetime] " + " FROM (SELECT Row_number() OVER(ORDER BY[" + returnM.order + "] ASC) NUM, " + " * " + " FROM [MNDTreturn_master] " + " WHERE 1 = 1 " + sCondition + ") AS [return_m] " + " WHERE NUM BETWEEN " + iStart.ToString() + " AND " + iEnd.ToString(); return(PublicApi.fnGetDt(sInquireSql, "MNDT")); }
public bool fnIsExist(ReturnM returnM) { string sSql = " SELECT COUNT([return_id]) " + " FROM [MNDTreturn_master] " + " WHERE [return_id] = '" + returnM.return_id + "' "; return(PublicApi.fnGetValue(sSql, "MNDT") == "1"); }
public string fnDelete(ReturnM returnM, string sIP) { string sSql = " UPDATE [MNDTreturn_master] " + " SET [status] = 'D' " + " WHERE [return_id] = '" + returnM.return_id + "' "; ReturnMTran returnMTran = new ReturnMTran(); returnMTran.ReturnId(returnM.return_id) .IP(sIP) .Status("D") .CreateId(returnM.create_id); sSql += fnInsertSql(returnMTran); return(PublicApi.fnExecuteSQL(sSql, "MNDT")); }
public DataTable fnSelect(ReturnM returnM) { string sSql = " SELECT TOP 1 [return_id] " + " ,[order_id] " + " ,[id] " + " ,CONVERT(varchar(10), [datetime], 126) [datetime] " + " ,[complete] " + " ,[status] " + " ,[description] " + " ,[create_id] " + " ,CONVERT(char, [create_datetime], 120) [create_datetime] " + " FROM [MNDTreturn_master] " + " WHERE [return_id] = '" + returnM.return_id + "' "; return(PublicApi.fnGetDt(sSql, "MNDT")); }
public string fnCount(ReturnM returnM) { string sCondition = ""; sCondition += PublicApi.fnAddCondition("[order_id]", returnM.order_id); sCondition += PublicApi.fnAddCondition("[return_id]", returnM.return_id); sCondition += PublicApi.fnAddCondition("[id]", returnM.id); sCondition += PublicApi.fnAddCondition("CONVERT(varchar(10), [datetime], 126)", returnM.datetime); string sCountSql = " SELECT COUNT([return_id]) " + " FROM [MNDTreturn_master] " + " WHERE 1 = 1 " + sCondition; string sPageSize = PublicApi.fnGetValue(sCountSql, "MNDT"); return(sPageSize); }
// sNum 排行 public string fnSelectReturnId(ReturnM returnM, string sNum) { string sCondition = ""; sCondition += PublicApi.fnAddCondition("[order_id]", returnM.order_id); sCondition += PublicApi.fnAddCondition("[return_id]", returnM.return_id); sCondition += PublicApi.fnAddCondition("[id]", returnM.id); sCondition += PublicApi.fnAddCondition("CONVERT(varchar(10), [datetime], 126)", returnM.datetime); string sSql = " SELECT [return_m].[return_id] " + " FROM (SELECT Row_number() OVER (ORDER BY [" + returnM.order + "] ASC) NUM, " + " * " + " FROM [MNDTreturn_master] " + " WHERE 1 = 1" + sCondition + ") AS [return_m] " + " WHERE [return_m].[NUM] = '" + sNum + "' "; return(PublicApi.fnGetValue(sSql, "MNDT")); }
public string fnUpdate(ReturnM returnM, string sIP) { string sSql = " UPDATE [dbo].[MNDTreturn_master] " + " SET [id] = '" + returnM.id + "' " + " ,[order_id] = '" + returnM.order_id + "' " + " ,[datetime] = '" + returnM.datetime + "' " + " ,[complete] = '" + returnM.complete + "' " + " ,[status] = '" + returnM.status + "' " + " ,[description] = '" + returnM.description + "' " + " WHERE [return_id] = '" + returnM.return_id + "' "; ReturnMTran returnMTran = new ReturnMTran(); returnMTran.ReturnId(returnM.return_id) .IP(sIP) .Status("M") .CreateId(returnM.create_id); sSql += fnInsertSql(returnMTran); return(PublicApi.fnExecuteSQL(sSql, "MNDT")); }
public string fnInsert(ReturnM returnM) { string sSql = " INSERT INTO [dbo].[MNDTreturn_master] " + " ([return_id] " + " ,[order_id] " + " ,[id] " + " ,[datetime] " + " ,[complete] " + " ,[description] " + " ,[create_id] " + " ,[create_datetime]) " + " VALUES " + " ('" + returnM.return_id + "' " + " ,'" + returnM.order_id + "' " + " ,'" + returnM.id + "' " + " ,'" + returnM.datetime + "' " + " ,'N' " + " ,'" + returnM.description + "' " + " ,'" + returnM.create_id + "' " + " ,GETDATE()) "; return(PublicApi.fnExecuteSQL(sSql, "MNDT")); }
public ValuesController(DatabaseContext context) { this._context = context; this.retornoVM = new ReturnM(); }