Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Numerics;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApplication5
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- String str = textBox1.Text.Replace(" ", "").Trim();
- if (str.Length != 24) {
- textBox1.Text = "Podaj poprawny kod";
- return;
- }
- str = str + "252100";
- int mod = 0;
- foreach(var num in str)
- mod = (10 * mod + int.Parse(num.ToString())) % 97;
- mod = 98 - mod;
- textBox2.Text = "PL" + mod +" "+ textBox1.Text;
- }
- private void button2_Click(object sender, EventArgs e)
- {
- String str = textBox2.Text.Replace(" ", "").Trim();
- if (str.Length != 28)
- {
- textBox2.Text = "Podaj poprawny kod";
- return;
- }
- String code = str.Substring(0,4);
- code = code.Replace("PL","2521");
- str = str.Remove(0,4) + code;
- int mod = 0;
- foreach (var num in str)
- mod = (10 * mod + int.Parse(num.ToString())) % 97;
- if (mod == 1){
- label2.Text = "Poprawny";
- }
- else {
- label2.Text = "Niepoprawny";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement