Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            byte[] data = UTF8Encoding.UTF8.GetBytes(textBox6.Text);
            using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider())
            {
                byte[] keys = md5.ComputeHash(UTF8Encoding.UTF8.GetBytes(hash));
                using (TripleDESCryptoServiceProvider tps = new TripleDESCryptoServiceProvider()
                {
                    Key = keys, Mode = CipherMode.ECB, Padding = PaddingMode.PKCS7
                })
                {
                    ICryptoTransform trans  = tps.CreateEncryptor();
                    byte[]           result = trans.TransformFinalBlock(data, 0, data.Length);
                    pass = Convert.ToBase64String(result, 0, result.Length);
                }
            }
            if (isvalid())
            {
                con1.Open();
                SqlCommand com2 = new SqlCommand();
                com2.Connection  = con1;
                com2.CommandText = "SELECT * FROM Account WHERE ID='" + textBox2.Text.Trim() + "'";
                SqlDataReader dr = com2.ExecuteReader();
                if (dr.Read())
                {
                    MessageBox.Show("ID available", "Error");
                    textBox2.Focus();
                    con1.Close();
                }
                else
                {
                    SqlCommand com1 = new SqlCommand();


                    com1.CommandText = "Insert into Account values ('" + textBox1.Text.Trim() + "','" + textBox2.Text.Trim() + "','" + textBox3.Text.Trim() + "','" + textBox4.Text.Trim() + "','" + textBox5.Text.Trim() + "','" + pass.Trim() + "','" + "A" + "')";
                    SqlDataAdapter da = new SqlDataAdapter(com1.CommandText, con1.ConnectionString);
                    DataTable      dt = new DataTable();
                    da.Fill(dt);
                    MessageBox.Show("Successfully Saved");
                    con1.Close();
                    Create_Account cv = new Create_Account();
                    cv.Show();
                    this.Hide();
                }
            }
        }
Exemplo n.º 2
0
        private void button5_Click(object sender, EventArgs e)
        {
            byte[] data = UTF8Encoding.UTF8.GetBytes(textBox6.Text);
            using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider())
            {
                byte[] keys = md5.ComputeHash(UTF8Encoding.UTF8.GetBytes(hash));
                using (TripleDESCryptoServiceProvider tps = new TripleDESCryptoServiceProvider()
                {
                    Key = keys, Mode = CipherMode.ECB, Padding = PaddingMode.PKCS7
                })
                {
                    ICryptoTransform trans  = tps.CreateEncryptor();
                    byte[]           result = trans.TransformFinalBlock(data, 0, data.Length);
                    pass = Convert.ToBase64String(result, 0, result.Length);
                }
            }
            if (isvalid())
            {
                con1.Open();
                SqlCommand com2 = new SqlCommand();
                com2.Connection  = con1;
                com2.CommandText = "SELECT * FROM Account WHERE ID='" + textBox2.Text.Trim() + "'";
                SqlDataReader dr = com2.ExecuteReader();
                if (dr.Read())
                {
                    com2.CommandText = "UPDATE Account SET Name='" + textBox1.Text.Trim() + "',Mobile='" + textBox3.Text.Trim() + "',Post='" + textBox4.Text.Trim() + "',UserName='******',Password='******',Type='" + "A" + "' WHERE ID='" + textBox2.Text.Trim() + "' ";
                    dr.Close();
                    com2.ExecuteNonQuery();
                    MessageBox.Show("Updated");

                    this.Hide();
                    Create_Account cv = new Create_Account();
                    cv.Show();
                }
                else
                {
                    MessageBox.Show("Invaid ID", "Error");
                }
                con1.Close();
            }
        }
Exemplo n.º 3
0
        private void optionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Create_Account CA = new Create_Account();

            CA.Show();
        }
Exemplo n.º 4
0
        private void textBox2_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                con1.Open();
                SqlCommand com1 = new SqlCommand();
                com1.Connection = con1;
                if (textBox2.Text.Trim() != string.Empty)
                {
                    com1.CommandText = "Select * from Account where ID= '" + textBox2.Text.Trim() + "' ";

                    SqlDataReader dr = com1.ExecuteReader();
                    if (dr.Read())
                    {
                        textBox1.Text = dr.GetString(0).Trim();
                        string cons2 = dr.GetString(2).Trim();
                        string cons3 = dr.GetString(3).Trim();
                        string cons4 = dr.GetString(4).Trim();
                        string cons5 = dr.GetString(5).Trim();
                        string cons6 = dr.GetString(6).Trim();


                        textBox3.Text = cons2;
                        textBox4.Text = cons3;
                        textBox5.Text = cons4;
                        textBox6.Text = cons5;



                        dr.Close();
                    }
                    else
                    {
                        dr.Close();
                        MessageBox.Show("Invalid Data");
                        Create_Account ca = new Create_Account();
                        this.Hide();
                        ca.Show();


                        textBox1.Focus();
                    }
                }


                else
                {
                    MessageBox.Show("Invalid Data");
                    Create_Account ca = new Create_Account();
                    this.Hide();
                    ca.Show();


                    textBox1.Focus();
                }



                con1.Close();
            }
            textBox1.Focus();
        }