Ejemplo n.º 1
0
        private void btn_obtenir_codi_Click(object sender, EventArgs e)
        {
            //String NomTaula = "Orders";
            //String CampTaula = "idOrder";


            //DataTable infotaula = dts.Tables[0];

            //string query = "select idPlanet from DeliveryData where idSpaceShip = (select idSpaceShip from SpaceShips where idSpaceShip = '" + dts.Tables[0] + "';";


            string query = "select idPlanet from DeliveryData where idSpaceShip = (select idSpaceShip from SpaceShips where CodeSpaceShip = (select CodeSpaceShipCategory from SpaceShipCategories where DescSpaceShipCategory = '" + cmb_Nau.SelectedItem + "'))";

            DataSet dts = bbdd.PortarPerConsulta(query);
        }
Ejemplo n.º 2
0
        private void btn_codi_Click(object sender, EventArgs e)
        {
            byte[] data = new byte[4 * diccionari.Length];
            using (RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider())
            {
                crypto.GetBytes(data);
            }
            StringBuilder result = new StringBuilder(diccionari.Length);

            for (int i = 0; i < 12; i++)
            {
                var random = BitConverter.ToUInt32(data, i * 4);
                var numero = random % diccionari.Length;

                result.Append(diccionari[numero]);
            }

            code = result.ToString();

            string idPlanet = Portar_idPlanet();

            DataSet dtsEncryption   = bbdd.PortarTaula("InnerEncryption");
            string  queryEncryption = "select * from InnerEncryption where idPlanet = '" + idPlanet + "'";

            DataSet dtsidEncryption = bbdd.PortarPerConsulta(queryEncryption);

            if (dtsidEncryption.Tables[0].Rows.Count > 0)
            {
                DataRow drEncryption = dtsidEncryption.Tables[0].Rows[0];
                drEncryption["ValidationCode"] = code;

                bbdd.Actualitzar(dtsidEncryption, queryEncryption);
            }
            else
            {
                DataRow drEncryption = dtsEncryption.Tables[0].NewRow();
                drEncryption["idPlanet"]       = idPlanet;
                drEncryption["ValidationCode"] = code;

                dtsEncryption.Tables[0].Rows.Add(drEncryption);
                string query = "select * from InnerEncryption";
                bbdd.Actualitzar(dtsEncryption, query);
            }
        }