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); }
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); } }
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); } }