Пример #1
0
        /// <summary>
        /// Executes the gives SQL query
        /// </summary>
        /// <param name="query">The SQL query to be executed</param>
        /// <param name="Parameters">Query parameters and their values</param>
        /// <returns>Number of rows affected</returns>
        public int ExecuteNonQuery(string query, Dictionary <string, object> Parameters = null)
        {
            int x = ExecuteCommand(connString, providerName, query, Parameters);

            if (x <= 0)
            {
                MethodesClass.ErrorLogAsync(query + MethodesClass.GetMethodName());
            }
            return(x);
        }
Пример #2
0
        //#region Validation IsDate

        ////(yyyy/MM/dd)
        //private static readonly string isDate_PATTERN = @"((19|20|30|40|50)\d\d)\/(0[1-9]|1[0-9])\/((0|1)[0-9]|2[0-9]|3[0-1])$";

        ////private static readonly string isDate_PATTERN = @"^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))|^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d+$";

        //public static bool IsValidDate(string date)
        //{
        //  //try
        //  //{
        //  //  if (IsValidEmpty(date) == false)
        //  //  {
        //  //    Convert.ToDateTime(date);
        //  //    return true;
        //  //  }
        //  //}
        //  //catch
        //  //{
        //  //  //MethodesClass.ErrorLogAsync("date is " + date + MethodesClass.GetMethodName());
        //  //  return false;
        //  //}
        //  if (date != null && date != string.Empty)
        //    return Regex.IsMatch(date, isDate_PATTERN) & date.Trim().Length > 0;
        //  else
        //  {
        //    return false;
        //  }
        //}

        //#endregion Validation IsDate

        #region Validation DateTime

        public static bool IsValiDateTime(string date, string dateFormat)
        {
            try
            {
                DateTime dt = default;
                //bool isValid = DateTime.TryParseExact(date, dateFormat, null, 0, out dt);
                bool isValid = DateTime.TryParseExact(date, dateFormat, null, 0, out dt);
                if (!isValid)
                {
                    return(false);
                }
                DateTime min = new DateTime(1967, 1, 1);
                DateTime max = new DateTime(3000, 1, 1);
                if (dt < min || dt > max)
                {
                    return(false);
                }
                return(true);
            }
            catch (Exception e1)
            {
                MethodesClass.ErrorLogAsync("date is " + date + "\n" + " Exception Is " + e1.Message + MethodesClass.GetMethodName());
                return(false);
            }
        }