using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GeneratedSerial
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private string GenerateSerial(string hardwareCode)
        {
            string code = hardwareCode.Substring(1, 10);
            string serial = string.Empty;
            for (int i = 0; i < code.Length; i++)
            {
                char ch = char.Parse(code.Substring(i, 1));
                serial += ((int)ch).ToString() + hardwareCode.Substring(i, 1);
            }

            serial = serial.Substring(1, 10);

            string serial2 = string.Empty;
            for (int i = 0; i < serial.Length; i++)
            {
                char ch = char.Parse(serial.Substring(i, 1));
                serial2 += ((int)ch).ToString() + serial.Substring(i, 1);
            }

            return "SNIR" + serial2;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int type = 0;
            if (comboBox1.SelectedIndex == 0)
                type = 1;
            else if (comboBox1.SelectedIndex == 1)
                type = 2;
            else if (comboBox1.SelectedIndex == 2)
                type = 3;
            else
            {
                MessageBox.Show("نوع لایسنس را انتخاب کنید");
                return;
            }

            txtSerial.Text = GenerateSerial(txtSystemId.Text) + type;
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}
