Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Numerics;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11.  
  12. namespace WindowsFormsApplication5
  13. {
  14. public partial class Form1 : Form
  15. {
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. }
  20.  
  21. private void button1_Click(object sender, EventArgs e)
  22. {
  23. String str = textBox1.Text.Replace(" ", "").Trim();
  24.  
  25. if (str.Length != 24) {
  26. textBox1.Text = "Podaj poprawny kod";
  27. return;
  28. }
  29.  
  30. str = str + "252100";
  31. int mod = 0;
  32. foreach(var num in str)
  33. mod = (10 * mod + int.Parse(num.ToString())) % 97;
  34. mod = 98 - mod;
  35.  
  36. textBox2.Text = "PL" + mod +" "+ textBox1.Text;
  37.  
  38. }
  39.  
  40. private void button2_Click(object sender, EventArgs e)
  41. {
  42. String str = textBox2.Text.Replace(" ", "").Trim();
  43.  
  44. if (str.Length != 28)
  45. {
  46. textBox2.Text = "Podaj poprawny kod";
  47. return;
  48. }
  49.  
  50. String code = str.Substring(0,4);
  51. code = code.Replace("PL","2521");
  52. str = str.Remove(0,4) + code;
  53.  
  54. int mod = 0;
  55. foreach (var num in str)
  56. mod = (10 * mod + int.Parse(num.ToString())) % 97;
  57.  
  58. if (mod == 1){
  59. label2.Text = "Poprawny";
  60. }
  61. else {
  62. label2.Text = "Niepoprawny";
  63. }
  64.  
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement