} //klucz przekazywany do pliku public string GenerateKey(string companyNIP, CustomerModules customerModules) { MagicWord = ""; foreach (var list in customerModules.ProductList) { MagicWord = list.Key.Name.Trim() + ";"; foreach (var modules in list.Value) { MagicWord += modules.Name.Trim() + ";"; } } MagicWord += companyNIP.Trim(); //Debug.WriteLine(MagicWord); return(MagicWord); }
private void button1_Click(object sender, System.EventArgs e) //generuj klucz { keyGenereator = new KeyGenerator(); Company companyKey = new Company(); companyKey.companyNIP = dataGridView1.CurrentRow.Cells[2].Value.ToString(); CustomerModules CustomerModulesKey = new CustomerModules(); CustomerModulesKey.ProductList = new Dictionary <IProduct, List <IModules> >(); foreach (DataGridViewRow datarow in dataGridView2.Rows) { datarow.Selected = true; if (Convert.ToBoolean(datarow.Cells[Zaznacz.Name].Value)) { var product = new Product { Name = datarow.Cells[2].Value.ToString() }; var moduleList = new List <IModules>(); foreach (DataGridViewRow dt in dataGridView3.Rows) { if (Convert.ToBoolean(dt.Cells[ZaznaczModul.Name].Value)) { moduleList.Add(new Modules { Name = dt.Cells[1].Value.ToString() }); } } CustomerModulesKey.ProductList.Add(product, moduleList); } datarow.Selected = false; } var MagicKey = keyGenereator.GenerateKey(companyKey.companyNIP, CustomerModulesKey); //przekazany customermoduleskey wraz ze wszystkimi polami (listami) }