コード例 #1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            BE.Id       = Convert.ToInt32(txtUserName.Text);
            BE.Password = txtPassword.Text.Trim();
            InterfaceLayer IL        = BL;
            DataSet        dsDecrypt = IL.DecryptPassWord();

            if (dsDecrypt.Tables[0].Rows.Count > 0)
            {
                lblMsg.Text      = CryptUtil1.Decrypt(Convert.ToString(txtPassword.Text.Trim()));
                lblMsg.Visible   = true;
                lblMsg.ForeColor = Color.Green;
            }
            else
            {
                lblMsg.Text      = "Your Details Not Correctly...!";
                lblMsg.Visible   = true;
                lblMsg.ForeColor = Color.Red;
            }
        }
        catch (Exception ex)
        {
            lblMsg.Visible   = true;
            lblMsg.Text      = ex.Message.ToString();
            lblMsg.ForeColor = Color.Red;
        }
    }
コード例 #2
0
    //private void sendemail(string to, string subject, string body)
    //{
    //    string sender = ConfigurationManager.AppSettings["EmailFromAddress"];
    //    try
    //    {
    //        var MailHelper = new MailHelper
    //        {
    //            Sender = sender,
    //            Recipient = to,
    //            RecipientCC = null,
    //            Subject = subject,
    //            Body = body,
    //        };
    //        MailHelper.Send();
    //    }
    //    catch (Exception)
    //    {

    //        throw;
    //    }
    //}
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            string   strPassWord  = string.Empty;
            string[] GenerateList = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
            Random   r            = new Random();
            for (int i = 0; i < 6; i++)
            {
                int j;
                j            = r.Next(GenerateList.Length);
                strPassWord += GenerateList[j];
            }
            BE.Id       = Convert.ToInt32(txtUserName.Text);
            BE.Password = CryptUtil1.Encrypt(Convert.ToString(strPassWord.Trim()));
            InterfaceLayer IL     = BL;
            int            Result = IL.GetPassWord();

            if (Result == 1)
            {
                //SendMails();
                BE.Email = IL.GetMailId();
                //em.SendEmail(BE.Email, BE.Password.ToString());
                //sendemail(BE.Email, "Password", "Your Password Info is: " + BE.Password.ToString() + "");
                //sendemail(Properties.EmailId, "Password", "Your Password Info is: " + password.ToString() + "");


                Result1 = "Your Password is" + BE.Password.ToString();
                //Result1 = "Your Password Info is " + CryptUtil1.Encrypt(Convert.ToString(strPassWord.Trim())).ToString();
                Page.RegisterClientScriptBlock("balu", "<script>alert('" + Result1 + "')</script>");
                txtUserName.Text = string.Empty;
                lblMsg.Text      = string.Empty;
            }
            else
            {
                Result1 = "Already your password has been displayed";
                Page.RegisterClientScriptBlock("Balu", "<script>alert('" + Result1 + "')</script>");
                txtUserName.Text = string.Empty;
                lblMsg.Text      = string.Empty;
            }
        }
        catch (Exception ex)
        {
            lblMsg.Visible   = true;
            lblMsg.Text      = ex.Message.ToString();
            lblMsg.ForeColor = Color.Red;
        }
    }