private void btSave_Click(object sender, EventArgs e) { BUS.CommonControl ctr = new BUS.CommonControl(); DataTable dt = dgvList.DataSource as DataTable; if (dt != null) { ctr.executeNonQuery("Delete from LIST_EMAIL"); string query = ""; foreach (DataRow row in dt.Rows) { query += " insert into LIST_EMAIL(Mail, _Name,Lookup) values('" + row["Mail"].ToString() + "','" + row["_Name"].ToString() + "','" + row["Lookup"].ToString() + "')"; } ctr.executeNonQuery(query); } DialogResult = DialogResult.OK; Close(); }
private void btnOK_Click(object sender, EventArgs e) { DTO.License license = GetDataFromForm(); string param = license.CompanyName + license.SerialNumber + license.NumUsers.ToString() + license.Modules + license.ExpiryDate.ToString() + license.SerialCPU; string tmp = RC2.EncryptString(param, _key, _iv, _padMode, _opMode); string key = Convert.ToBase64String(new System.Security.Cryptography.SHA1CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(tmp))); if (key == license.Key) { String kq = license.CompanyName + ";" + license.ExpiryDate + ";" + license.Modules + ";" + license.NumUsers + ";" + license.SerialNumber + ";" + license.Key + ";" + license.SerialCPU; BUS.CommonControl ctr = new BUS.CommonControl(); string query = @"if EXISTS(SELECT INS_KEY FROM SSINSTAL WHERE INS_TB='LCS' and INS_KEY='QD') UPDATE SSINSTAL SET SUN_DATA = '{0}' WHERE INS_TB='LCS' and INS_KEY='QD' else INSERT INTO SSINSTAL(INS_TB ,INS_KEY ,SUN_DATA) VALUES ( 'LCS' ,'QD' ,'{0}')"; string result = RC2.EncryptString(kq, _key, _iv, _padMode, _opMode); query = string.Format(query, result); ctr.executeNonQuery(query); //StreamWriter writerStream = new StreamWriter(_pathLicense.Replace("file:\\", "")); //writerStream.WriteLine(result); //writerStream.Close(); Close(); DialogResult = DialogResult.OK; } else { lbErr.Text = "Registry fail"; } }