示例#1
0
    public MemberFruit CheckLogin(string _email, string _password)
    {
        MemberFruit memer = null;
        try
        {
            Conn = db.openConn();

            sb = new StringBuilder();

            sb.Remove(0, sb.Length);
            sb.Append(" SELECT ID,FullName,EmailFruit,PasswordFruit FROM tbMemberFruit ");
            sb.Append(" WHERE (EmailFruit='" + _email + "')");
            sb.Append(" AND (PasswordFruit='" + _password + "')");

            string sql;
            sql = sb.ToString();

            com = new OleDbCommand();
            com.CommandText = sql;
            com.CommandType = CommandType.Text;
            com.Connection = Conn;
            dr = com.ExecuteReader();
            if (dr.HasRows)
            {

                DataTable dt = new DataTable();
                dt.Load(dr);
                foreach (DataRow drw in dt.Rows)
                {
                    memer = new MemberFruit();
                    memer.ID = Convert.ToInt32(drw["ID"].ToString());
                    memer.FullName = Convert.ToString(drw["FullName"].ToString());
                    memer.Password = Convert.ToString(drw["PasswordFruit"].ToString());
                    memer.Email = Convert.ToString(drw["EmailFruit"].ToString());

                }
            }

            dr.Close();

        }
        catch (Exception ex)
        {

            Conn.Close();
            return null;
            throw ex;
        }
        finally
        {
            Conn.Close();
        }

        return memer;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        _userlogin = (MemberFruit)Session[SessionKey.USERLOGIN];

        if (!Page.IsPostBack)
        {
            Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());
            if (_userlogin != null)
            {
                txtUser.Text = _userlogin.FullName;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
         _userlogin = (MemberFruit )Session[SessionKey.USERLOGIN];

         if (_userlogin != null)
         {
             bmember.Style["display"] = "none";
             member.Style["display"] = "block";
             LinkButton4.Style["display"] = "inline";

             lblmemberlogin.Text = "ยินดีต้อนรับคุณ :" + _userlogin.FullName ;

         }
         else
         {
             bmember.Style["display"] = "block";
             member.Style["display"] = "none";
             LinkButton4.Style["display"] = "none";
         }
    }
示例#4
0
    protected void btnlogin_Click(object sender, EventArgs e)
    {
        if (txtUserName.Text.Trim() == "")
        {
            Alert.Show("กรุณากรอกชื่อผู้เข้าใช้ด้วย ");
            txtUserName.Focus();
            return;
        }
        if (txtpassword.Text.Trim() == "")
        {
            Alert.Show("กรุณากรอกรหัสผู้เข้าใช้ด้วย ");
            txtpassword.Focus();
            return;
        }

        if (txtconfirmpass.Text.Trim() == "")
        {
            Alert.Show("กรุณายืนยันรหัสผู้เข้าใช้ด้วย ");
            txtconfirmpass.Focus();
            return;
        }
        if (!txtpassword.Text.Trim().Equals(txtconfirmpass.Text.Trim()))
        {
            Alert.Show("รหัสผ่านไม่ตรงกัน ");
            txtpassword.Focus();
            return;
        }
        if (txtEmail.Text.Trim() == "")
        {
            Alert.Show("กรุณากรอก Email ด้วย ");
            txtEmail.Focus();
            return;
        }
        if (this.isEmail(txtEmail.Text.Trim()) == false)
        {
            Alert.Show("รูปแบบ Email ไม่ถูกต้อง ");
            txtEmail.Focus();
            return;
        }

        if (Session["update"].ToString() == ViewState["update"].ToString())
        {
            try
            {
                FruitService service = new FruitService();

                MemberFruit mb = new MemberFruit();
                mb.FullName = txtUserName.Text.Trim();
                mb.Password = txtpassword.Text.Trim();
                mb.Email = txtEmail.Text.Trim();

                if (service.CreateMember(mb))
                {
                    Clear();
                    Alert.Show("บันทึกเรียบร้อยแล้ว");

                }
                Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());

                Response.Redirect("login.aspx");
            }
            catch (Exception ex)
            {
                Alert.Show("ไม่สามารถบันทึกได้ เนื่องจาก " + ex.Message);
            }

        }
    }
示例#5
0
    public bool CreateMember(MemberFruit  _member)
    {
        bool result = false;
        try
        {
            Conn = db.openConn();
            tr = Conn.BeginTransaction();

            sb = new StringBuilder();

            sb.Remove(0, sb.Length);
            sb.Append(" INSERT INTO tbMemberFruit(FullName,EmailFruit,PasswordFruit)");
            sb.Append(" VALUES (");
            sb.Append(" '" + _member.FullName  + "',");
            sb.Append(" '" + _member.Email  + "',");
            sb.Append(" '" + _member.Password  + "')");

            string sqlSave;
            sqlSave = sb.ToString();

            com = new OleDbCommand();
            com.Connection = Conn;
            com.CommandText = sqlSave;
            com.Transaction = tr;
            com.Parameters.Clear();

            com.ExecuteNonQuery();
            tr.Commit();

            result = true;

        }
        catch (Exception ex)
        {
            tr.Rollback();
            Conn.Close();
            return result;
            throw ex;
        }
        finally
        {
            Conn.Close();
        }

        return result;
    }