private void btnAuthen_Click(object sender, EventArgs e) { lic.ProductCd = ProductCd; lic.ProductKey = ProductKey; DbConnect dbConn = new DbConnect(); try { dbConn.Open(); dbConn.BeginTran(); var bSuccess = ser.RegisterLicense(dbConn, lic, ser.GetDriveSerialNumber()); if (bSuccess) { dbConn.Commit(); MessageBox.Show("Active success"); } else { dbConn.Rollback(); MessageBox.Show("Active fail"); } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); MessageBox.Show("Error"); } finally { dbConn.DisposeTran(); dbConn.Close(); } }
private void button1_Click(object sender, EventArgs e) { if (cboProduct.SelectedValue.ToString().Length == 0) { MessageBox.Show("Please choose a product."); cboProduct.Focus(); return; } if (txtProductKey.Text.Length == 0) { MessageBox.Show("Please get a product key."); btnCreateProductKey.Focus(); return; } SerialnumberHDD ser = new SerialnumberHDD(); string outKey = ""; DbConnect dbConn = new DbConnect(); try { dbConn.Open(); dbConn.BeginTran(); bool bSuccess = ser.CreateKey(dbConn, cboProduct.SelectedValue.ToString(), txtProductKey.Text, ser.GetDriveSerialNumber(), out outKey); if (bSuccess) { dbConn.Commit(); MessageBox.Show("Success"); } else { MessageBox.Show("Fail"); dbConn.Rollback(); } } catch (Exception ex) { dbConn.Rollback(); Debug.WriteLine(ex.ToString()); MessageBox.Show("Error"); } finally { dbConn.DisposeTran(); dbConn.Close(); } }