isotonicq

Untitled

Apr 27th, 2021
671
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public override void Action()
  2. {
  3.      string result = string.Empty;
  4.    
  5.      using (var connection = Session.Login.Database.OpenConnection(DatabaseType.Operational))
  6.      {
  7.             string tableQuery = "SELECT Kod FROM Towary ORDER BY CONVERT(SUBSTRING_INDEX(SUBSTR(Kod, 2),'-',-1),UNSIGNED INTEGER) DESC LIMIT 1";
  8.  
  9.           Devart.Data.MySql.MySqlDataReader tableResult = ( Devart.Data.MySql.MySqlDataReader)connection.ExecuteCommand(ExecuteMode.Reader, tableQuery);
  10.            
  11.             while (tableResult.Read())
  12.             {
  13.                  result = tableResult.GetString(0);
  14.                  break;
  15.             }
  16.            
  17.             tableResult.Close();
  18.      }
  19.    
  20.      if(!string.IsNullOrEmpty(result))
  21.      {
  22.           result = (Convert.ToInt32(string.Join(string.Empty, result.Where(char.IsDigit))) + 1).ToString();
  23.           Row.Kod = "M" + result;  
  24.      }
  25.    
  26.     Task.Delete();
  27. }
RAW Paste Data