private void buttonAssignSerialMAC_Click(object sender, EventArgs e) { string sMAC = sqldata_.FindMAC(comboBoxType.Text, textBoxAssignMAC.Text); if ((sMAC != string.Empty) && (textBoxAssignMAC.Text != string.Empty)) { sqldata_.UpdateMACWithSerial(comboBoxType.Text, sMAC, textBoxAssignSerial.Text); } else { Trace.WriteLine(string.Format("Assign Serial={0} to MAC={1} failed!", textBoxAssignSerial.Text, sMAC), "ERROR"); } }
public Int32 FetchLicense() { Int32 result = -1; string db_MAC0 = string.Empty; try { if (NeedsNewLicense == true) { db_MAC0 = sqldata_.FindUnusedMAC(ColType); } else { db_MAC0 = sqldata_.FindMAC(ColType, MAC0.ToUpper()); } if (string.IsNullOrEmpty(db_MAC0)) { Trace.WriteLine("ERROR: Can't find requested MAC0 in database."); return(result); } if (sqldata_.UpdateMACWithSerial(ColType, db_MAC0.ToUpper(), Serial) == true) { result = StoreLicenseFile(ColType, db_MAC0); } else { if (sqldata_.FindMACBySerial(ColType, Serial) == MAC0.ToUpper()) { Trace.WriteLine(string.Format("{0} is already assinged to {1}", Serial, MAC0)); result = StoreLicenseFile(ColType, db_MAC0); } else { Trace.WriteLine(string.Format("ERROR: Did not fetch license file from db. Serialnumber already assigned to another MAC")); } } } catch (Exception ex) { Trace.WriteLine(string.Format("ERROR: Exception thrown - {0}", ex.Message)); } return(result); }