Advertisement
hskartono

Untitled

Nov 30th, 2021
747
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 KB | None | 0 0
  1. public String GetDelayReceivingMsp(string day = "")
  2.         {
  3.             try
  4.             {
  5.                 string sqlday = " and  1=1";
  6.                 if (!string.IsNullOrEmpty(sqlday))
  7.                 {
  8.                     if (day == "one")
  9.                     {
  10.                         sqlday = "and DATEDIFF(DAY, eta, convert(date,getdate())) = 3";
  11.                     }
  12.                     else if (day == "mid")
  13.                     {
  14.                         sqlday = "and DATEDIFF(DAY, eta, convert(date,getdate())) BETWEEN 4 AND 5";
  15.                     }
  16.                     else if (day == "more")
  17.                     {
  18.                         sqlday = "and DATEDIFF(DAY, eta, convert(date,getdate())) > 6";
  19.                     }
  20.                 }
  21.                 string sql = @"
  22.                SELECT count(*) AS delay_receiving_msp FROM (
  23.                SELECT container_no FROM SsDelayReceiving WITH (NOLOCK)
  24.                WHERE source like 'MSP%' " + sqlday +
  25.                 " GROUP BY container_no) AS tbl";
  26.  
  27.                 DataTable result = mSharedHelper.SqlToDataTable(sql);
  28.  
  29.                 return result != null ? result.Rows[0]["delay_receiving_msp"].ToString() : "0";
  30.             }
  31.             catch (Exception ex)
  32.             {
  33.                 throw new AMNDaoException(base.ErrorMethodInfo(System.Reflection.MethodBase.GetCurrentMethod()) + " " + ex.Message, ex);
  34.             }
  35.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement