Esempio n. 1
0
    protected void btnGui_Click(object sender, EventArgs e)
    {
        try
        {
            NguoiDung nguoidung = new NguoiDung();
            DataSet ds = nguoidung.SelectByField("email", txtEmail.Text.Trim(), "nvarchar");
            if (ds.Tables[0].Rows.Count > 0)
            {
                string emailto = txtEmail.Text;
                string emailfrom = ConfigurationManager.AppSettings["EmailFrom"];
                string emailsubject = "Quên mật khẩu "; // +Session["UserFullName"].ToString();
                string emailbody = "Mật khẩu được gửi theo yêu cầu của bạn: ";
                emailbody += " Tên truy cập: " + ds.Tables[0].Rows[0]["TaiKhoan"];
                emailbody += " Mật khẩu: " + ds.Tables[0].Rows[0]["MatKhau"];
                string smtpserver = ConfigurationManager.AppSettings["smtpserver"];
                string emailcc = "";
                string emailbcc = "";

                Common.SendMail(emailto, emailfrom, emailsubject, emailbody, smtpserver, emailcc, emailbcc);
            }
            string strScript = "<script language='JavaScript'>" + "this.close();</script>";
            ClientScript.RegisterStartupScript(Type.GetType("System.String"), "Refresh", strScript);
        }
        catch (Exception ex)
        {
            Response.Redirect("message.aspx?msg=" + ex.ToString().Replace("\r\n", ""));
        }
    }
Esempio n. 2
0
    protected void btnSend_Click(object sender, EventArgs e)
    {
        try
        {
            NguoiDung nd = new NguoiDung();
            DataSet ds = nd.SelectByField("email", txtEmail.Text.Trim(), "nvarchar");

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (bool.Parse(ds.Tables[0].Rows[0]["KichHoat"].ToString()) == false)
                {
                    string emailto = txtEmail.Text;
                    string emailfrom = ConfigurationManager.AppSettings["EmailFrom"];
                    string emailsubject = "Kích hoạt tài khoản từ CHONET.VN";
                    string emailbody =
                        Common.GetEmailHTMLTemplate(Server.MapPath(".") +
                                                    ConfigurationManager.AppSettings["TemplateKichHoat"]);
                    string smtpserver = ConfigurationManager.AppSettings["smtpserver"];
                    string emailcc = "";
                    string emailbcc = "";
                    string name = ds.Tables[0].Rows[0]["HoVaTen"].ToString();
                    string ndid = ds.Tables[0].Rows[0]["NguoiDungID"].ToString();
                    string activatecode = ds.Tables[0].Rows[0]["MaSoKichHoat"].ToString();
                    string taikhoan = ds.Tables[0].Rows[0]["TaiKhoan"].ToString();
                    string matkhau = ds.Tables[0].Rows[0]["MatKhau"].ToString();

                    //emailbody = emailbody.Replace("[[name]]", ds.Tables[0].Rows[0]["HoVaTen"].ToString());
                    //emailbody = emailbody.Replace("[[linkkichhoat]]", "http://chonet.vn/ActivateAccount.aspx?ndid=" + ds.Tables[0].Rows[0]["NguoiDungID"].ToString()
                    //    + "&activate=" + ds.Tables[0].Rows[0]["MaSoKichHoat"].ToString());
                    //emailbody = emailbody.Replace("[[taikhoan]]",ds.Tables[0].Rows[0]["TaiKhoan"].ToString());
                    //emailbody = emailbody.Replace("[[password]]", ds.Tables[0].Rows[0]["MatKhau"].ToString());
                    //emailbody = emailbody.Replace("[[email]]", txtEmail.Text);

                    //Common.SendMail(emailto, emailfrom, emailsubject, emailbody, smtpserver, emailcc, emailbcc);
                    Common.SendActiveMail(txtEmail.Text, emailsubject, emailbody, name, ndid, activatecode, taikhoan,
                                          matkhau, emailto);

                    Response.Redirect(
                        "Inform.aspx?msg=Hệ thống đã gửi thư kích hoạt đến hộp thư của bạn. Hãy kiểm tra và làm theo hướng dẫn!",
                        false);
                    return;
                }
                else
                {
                    Response.Redirect("Inform.aspx?msg=Tài khoản của bạn đã được kích hoạt!", false);
                    return;
                }
            }
        }
        catch (Exception ex)
        {
            Response.Redirect("message.aspx?msg=" + ex.ToString().Replace("\r\n", ""));
        }
    }
Esempio n. 3
0
    protected void btnDangNhap_Click(object sender, EventArgs e)
    {
        try
        {
            NguoiDung nguoidung = new NguoiDung();
            DataSet ds = nguoidung.SelectByField("taikhoan", txtTaiKhoan.Text.Trim(), "nvarchar");

            if (ds.Tables[0].Rows.Count > 0)
            {
                if ((ds.Tables[0].Rows[0]["matkhau"].ToString() == txtMatKhau.Text) &&
                    bool.Parse(ds.Tables[0].Rows[0]["KichHoat"].ToString()))
                {
                    Session.Clear();
                    Session.Add("LoaiNguoiDungID", ds.Tables[0].Rows[0]["LoaiNguoiDungID"]);
                    Session.Add("NguoiDungID", ds.Tables[0].Rows[0]["NguoiDungID"]);
                    Session.Add("UserFullName", ds.Tables[0].Rows[0]["HoVaTen"]);
                    Session.Add("NguoiDungEmail", ds.Tables[0].Rows[0]["Email"]);

                    FormsAuthentication.Authenticate(txtTaiKhoan.Text.Trim(), txtMatKhau.Text);
                    tblchaomung.Visible = true;
                    tbldangnhap.Visible = false;
                }
                else
                {
                    lblErr.Visible = true;
                    lblErr.Text = "Đăng nhập lỗi";
                }
            }
            else
            {
                lblErr.Visible = true;
                lblErr.Text = "Đăng nhập lỗi";
            }
        }
        catch (Exception ex)
        {
            Response.Redirect("Message.aspx?msg=" + ex.Message);
            return;
        }
    }
Esempio n. 4
0
 private bool CheckEmail()
 {
     NguoiDung nd = new NguoiDung();
     DataSet ds = nd.SelectByField("email", txtEmail.Text.Trim(), "nvarchar");
     if (ds.Tables[0].Rows.Count > 0)
     {
         return false;
     }
     else
     {
         return true;
     }
 }