示例#1
0
        private bool CheckData()
        {
            for (int t = 0; t < DataGridView1.RowCount; t++)
            {
                if (DataGridView1.Rows[t].Cells["colenable"].Value.ToString() == bool.TrueString &&
                    DataGridView1.Rows[t].Cells[nameof(colSerial)].Value == null)
                {
                    MessageBox.Show(Properties.Resources.Msg_MissingSerialNumber, Properties.Resources.Msg_Attention,
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }

                var expiration  = DateTime.Today;
                var sType       = (SerialType)DataGridView1.Rows[t].Cells[nameof(colLicenseType)].Value;
                var application = (string)DataGridView1.Rows[t].Cells[nameof(colApplication)].Value;
                var module      = (string)DataGridView1.Rows[t].Cells[nameof(colModuleName)].Value;
                if (sType.HasFlag(SerialType.EXPIRATION_DATE))
                {
                    expiration = (DateTime)DateTime.Parse(DataGridView1.Rows[t].Cells[nameof(colExpiration)].Value.ToString());
                }

                var serial = (string)DataGridView1.Rows[t].Cells[nameof(colSerial)].Value;

                if (serial != SerialManager.CreateSerial(txtLicense.Text, txtMac.Text, application, module, sType, expiration, txtPenDrive.Text))
                {
                    var mess = string.Format(Properties.Resources.Msg_IncorrectSerialNumber, application, module);
                    MessageBox.Show(mess, Properties.Resources.Msg_Attention,
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
            }
            return(true);
        }
示例#2
0
 private void CreateSerial()
 {
     for (int t = 0; t < DataGridView1.Rows.Count; t++)
     {
         var expiration  = DateTime.Today;
         var sType       = (SerialType)DataGridView1.Rows[t].Cells[nameof(colLicenseType)].Value;
         var application = (string)DataGridView1.Rows[t].Cells[nameof(colApplication)].Value;
         var module      = (string)DataGridView1.Rows[t].Cells[nameof(colModuleName)].Value;
         if (sType.HasFlag(SerialType.EXPIRATION_DATE))
         {
             expiration = (DateTime)DateTime.Parse(DataGridView1.Rows[t].Cells[nameof(colExpiration)].Value.ToString());
         }
         DataGridView1.Rows[t].Cells[nameof(colSerial)].Value = SerialManager.CreateSerial(txtLicense.Text, txtMac.Text, application, module, sType, expiration, txtPenDrive.Text);
     }
 }
示例#3
0
 private void btnCreate_Click(object sender, EventArgs e)
 {
     for (int t = 0; t < DataGridView1.Rows.Count; t++)
     {
         DateTime   expiration  = DateTime.Today;
         SerialType sType       = (SerialType)DataGridView1.Rows[t].Cells["colLicenseType"].Value;
         string     application = (string)DataGridView1.Rows[t].Cells["colApplication"].Value;
         string     module      = (string)DataGridView1.Rows[t].Cells["colModuleName"].Value;
         if (sType.HasFlag(SerialType.EXPIRATION_DATE))
         {
             expiration = (DateTime)DateTime.Parse(DataGridView1.Rows[t].Cells["colExpiration"].Value.ToString());
         }
         DataGridView1.Rows[t].Cells["colSerial"].Value = SerialManager.CreateSerial(txtLicense.Text, txtMac.Text, application, module, sType, expiration, cbbPenDrive.Text);
     }
 }
示例#4
0
        private void tsmbinaryFile_Click(object sender, EventArgs e)
        {
            SerialManager.Load();
            DataGridView1.Rows.Clear();

            //foreach (SerialModule sd in SerialManager.SerialData.Modules)
            //{
            //    int row = DataGridView1.Rows.Add();
            //    DataGridView1.Rows[row].Cells["colenable"].Value = sd.Enable == bool.TrueString;
            //    SerialType sType = (SerialType)Enum.Parse(typeof(SerialType), sd.SerialType);
            //    DataGridView1.Rows[row].Cells["colLicenseType"].Value = sType;
            //    DataGridView1.Rows[row].Cells["colApplication"].Value = sd.Application;
            //    DataGridView1.Rows[row].Cells["colModuleName"].Value = sd.Module;
            //    DataGridView1.Rows[row].Cells["colSerial"].Value = sd.SerialNo;
            //    if (sType.HasFlag(SerialType.EXPIRATION_DATE))
            //        DataGridView1.Rows[row].Cells["colExpiration"].Value = sd.Expiration;

            //    txtLicense.Text = SerialManager.SerialData.License;
            //    cbbPenDrive.Text = SerialManager.SerialData.PenDrive;
            //}
        }
示例#5
0
        private void LoadDataFromBinary()
        {
            SerialManager.Load();
            DataGridView1.Rows.Clear();

            foreach (SerialModule sd in SerialManager.SerialData.Modules)
            {
                var row = DataGridView1.Rows.Add();
                DataGridView1.Rows[row].Cells["colenable"].Value            = sd.Enable == bool.TrueString;
                DataGridView1.Rows[row].Cells[nameof(colLicenseType)].Value = sd.SerialTypeString;
                DataGridView1.Rows[row].Cells[nameof(colApplication)].Value = sd.Application;
                DataGridView1.Rows[row].Cells[nameof(colModuleName)].Value  = sd.Module;
                DataGridView1.Rows[row].Cells[nameof(colSerial)].Value      = sd.SerialNo;
                if (sd.SerialType.HasFlag(SerialType.EXPIRATION_DATE))
                {
                    DataGridView1.Rows[row].Cells[nameof(colExpiration)].Value = sd.Expiration;
                }

                txtLicense.Text  = SerialManager.SerialData.License;
                txtPenDrive.Text = SerialManager.SerialData.PenDrive;
            }
        }
示例#6
0
        private void tsmActivationSave_Click(object sender, EventArgs e)
        {
            SerialManager.Clear();
            SerialManager.SerialData.License  = txtLicense.Text;
            SerialManager.SerialData.PenDrive = cbbPenDrive.Text;

            for (int t = 0; t < DataGridView1.Rows.Count; t++)
            {
                DateTime   expiration  = DateTime.Today;
                bool       enable      = (bool)DataGridView1.Rows[t].Cells["colEnable"].Value;
                SerialType sType       = (SerialType)DataGridView1.Rows[t].Cells["colLicenseType"].Value;
                string     application = (string)DataGridView1.Rows[t].Cells["colApplication"].Value;
                string     module      = (string)DataGridView1.Rows[t].Cells["colModuleName"].Value;
                if (sType.HasFlag(SerialType.EXPIRATION_DATE))
                {
                    expiration = DateTime.Parse(DataGridView1.Rows[t].Cells["colExpiration"].Value.ToString());
                }
                string serial = DataGridView1.Rows[t].Cells["colSerial"].Value.ToString();
                SerialManager.AddModule(application, enable, module, sType, expiration, serial);
            }
            SerialManager.Save();
        }
示例#7
0
 protected override void OnLoad(EventArgs e)
 {
     txtMac.Text = SerialManager.ReadMacAddress();
     base.OnLoad(e);
 }
示例#8
0
 private void btnMacAddress_Click(object sender, EventArgs e)
 {
     txtMac.Text = SerialManager.ReadMacAddress();
 }