Exemplo n.º 1
0
        protected void UpdatePwd_Click(object sender, EventArgs e)
        {
            string sql = String.Empty;

            // --> 암호를 입력하세요.
            if (txtPWD.Text.Trim() == "")
            {
                lblmsg.Text = "암호를 입력하세요";
                txtPWD.Focus();
                return;
            }
            if (txtPWD2.Text.Trim() == "")
            {
                lblmsg.Text = "암호를 입력하세요";
                txtPWD2.Focus();
                return;
            }

            if (txtPWD.Text != txtPWD2.Text)
            {
                lblmsg.Text = "암호가 일치하지 않습니다.";
                return;
            }

            if (txtPWD.Text.Trim() != "" && txtPWD2.Text.Trim() != "")
            {
                sql = "update member set m_pwd=@m_pwd where m_id='" + txtID.Text + "'";
            }
            string       pwd  = MySite.MD5Hash(txtPWD.Text);
            DBConn       conn = new DBConn();
            OleDbCommand cmd  = new OleDbCommand(sql, conn.GetConn());

            cmd.Parameters.Add("@m_pwd", pwd);

            try
            {
                cmd.ExecuteNonQuery();
                Response.Write("<script>alert('재설정 완료.');</script>");
            }
            catch (Exception ee)//버튼 이벤트 변수가 e
            {
                Response.Write("<script>alert('재설정 실패.');</script>");
            }
            finally
            {
                conn.Close();
            }
        }
Exemplo n.º 2
0
        protected void btnSave_Click(object sender, ImageClickEventArgs e)
        {
            string sql = String.Empty;

            // --> 암호를 입력하세요.
            if (txtPWD.Text.Trim() == "")
            {
                msg.Text = "암호를 입력하세요";
                txtPWD.Focus();
                return;
            }
            if (txtPWD2.Text.Trim() == "")
            {
                msg.Text = "암호를 입력하세요";
                txtPWD2.Focus();
                return;
            }

            if (txtPWD.Text != txtPWD2.Text)
            {
                msg.Text = "암호가 서로 다릅니다";
                return;
            }
            // --> E-mail을  입력하세요.
            if (txtEmail.Text.Trim() == "")
            {
                msg.Text = "이메일을 입력하세요";
                txtEmail.Focus();
                return;
            }
            //이메일 형식
            if (txtEmail.Text != null)
            {
                Regex regex = new Regex("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*$");
                Match m     = regex.Match(txtEmail.Text);
                if (m.Success)
                {
                    msg.Text = "이메일 통과";
                }

                else
                {
                    msg.Text = "이메일 형식으로 입력하세요";
                    txtEmail.Focus();
                    return;
                }
            }


            if (txtPhone.Text.Trim() == "")
            {
                msg.Text = "전화번호를 입력하세요";
                txtPhone.Focus();
                return;
            }

            //전화번호 정규식

            if (txtPhone.Text.Trim() != null)
            {
                Regex regex = new Regex(@"01[016789]{1}-[0-9]{3,4}-[0-9]{4}");
                Match m     = regex.Match(txtPhone.Text);
                if (m.Success)
                {
                }

                else
                {
                    msg.Text = "전화번호 형식으로 입력하세요";
                    txtPhone.Focus();
                    return;
                }
            }


            if (txtPWD.Text.Trim() != "" && txtPWD2.Text.Trim() != "")
            {
                sql = "update member set m_pwd=@m_pwd, m_email = @m_email,m_phone = @m_phone where m_id='" + txtID.Text + "'";
            }
            string       pwd  = MySite.MD5Hash(txtPWD.Text);
            DBConn       conn = new DBConn();
            OleDbCommand cmd  = new OleDbCommand(sql, conn.GetConn());

            cmd.Parameters.Add("@m_pwd", pwd);
            cmd.Parameters.Add("@m_email", txtEmail.Text);
            cmd.Parameters.Add("@m_phone", txtPhone.Text);



            try
            {
                cmd.ExecuteNonQuery();
                Response.Write("<script>alert('정보 수정 완료.');</script>");
            }
            catch (Exception ee)//버튼 이벤트 변수가 e
            {
                Response.Write("<script>alert('정보 수정 실패.');</script>");
            }
            finally
            {
                conn.Close();
            }
        }
Exemplo n.º 3
0
        protected void btnSave_Click(object sender, ImageClickEventArgs e)
        {
            // 저장
            if (txtID.Text.Trim() == "")
            {
                msg.Text = "아이디를 입력하세요";
                txtID.Focus();
                return;
            }



            // --> 이름을 입력하세요.
            if (txtName.Text.Trim() == "")
            {
                msg.Text = "이름을 입력하세요";
                txtName.Focus();
                return;
            }
            // --> 암호를 입력하세요.
            if (txtPWD.Text.Trim() == "")
            {
                msg.Text = "암호를 입력하세요";
                txtPWD.Focus();
                return;
            }
            if (txtPWD2.Text.Trim() == "")
            {
                msg.Text = "암호를 입력하세요";
                txtPWD2.Focus();
                return;
            }

            if (txtPWD.Text != txtPWD2.Text)
            {
                msg.Text = "암호가 서로 다릅니다";
                return;
            }

            // --> E-mail을  입력하세요.
            if (txtEmail.Text.Trim() == "")
            {
                msg.Text = "이메일을 입력하세요";
                txtEmail.Focus();
                return;
            }
            //이메일 형식
            if (txtEmail.Text != null)
            {
                Regex regex = new Regex("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*$");
                Match m     = regex.Match(txtEmail.Text);
                if (m.Success)
                {
                    msg.Text = "이메일 통과";
                }

                else
                {
                    msg.Text = "이메일 형식으로 입력하세요";
                    txtEmail.Focus();
                    return;
                }
            }


            if (txtPhone.Text.Trim() == "")
            {
                msg.Text = "전화번호를 입력하세요";
                txtPhone.Focus();
                return;
            }

            //전화번호 정규식

            if (txtPhone.Text.Trim() != null)
            {
                Regex regex = new Regex(@"01[016789]{1}-[0-9]{3,4}-[0-9]{4}");
                Match m     = regex.Match(txtPhone.Text);
                if (m.Success)
                {
                }

                else
                {
                    msg.Text = "전화번호 형식으로 입력하세요";
                    txtPhone.Focus();
                    return;
                }
            }

            if (lbltitle.Text == "회원가입")
            {
                if (Button1.Enabled == true)
                {
                    msg.Text = "[아이디 중복]을 확인하세요";
                    txtID.Focus();
                    return;
                }
            }

            string sql = "";
            string pwd = MySite.MD5Hash(txtPWD.Text);

            if (Request["mode"] != null)
            {
                sql = "update member set m_pwd=@m_pwd, m_email = @m_email,m_phone = @m_phone where m_id='" + txtID.Text + "'";
                DBConn       conn = new DBConn();
                OleDbCommand cmd  = new OleDbCommand(sql, conn.GetConn());

                cmd.Parameters.Add("@m_pwd", pwd);
                cmd.Parameters.Add("@m_email", txtEmail.Text);
                cmd.Parameters.Add("@m_phone", txtPhone.Text);



                try
                {
                    cmd.ExecuteNonQuery();
                    Response.Write("<script>alert('정보 수정 완료.');</script>");
                }
                catch (Exception ee)//버튼 이벤트 변수가 e
                {
                    Response.Write("<script>alert('정보 수정 실패.');</script>");
                }
                finally
                {
                    conn.Close();
                }
            }
            else
            {
                sql = "insert into member(m_id,m_name,m_pwd,m_email,m_phone) values(@m_id,@m_name,@m_pwd,@m_email,@m_phone)";

                DBConn       conn = new DBConn();
                OleDbCommand cmd  = new OleDbCommand(sql, conn.GetConn());
                cmd.Parameters.AddWithValue("@m_id", txtID.Text);
                cmd.Parameters.AddWithValue("@m_name", txtName.Text);
                cmd.Parameters.AddWithValue("@m_pwd", pwd);
                cmd.Parameters.AddWithValue("@m_email", txtEmail.Text);
                cmd.Parameters.AddWithValue("@m_phone", txtPhone.Text);

                try
                {
                    cmd.ExecuteNonQuery();
                }



                catch (Exception ee)
                {
                    msg.Text = "오류가 있습니다."; // ee.Message;
                }
                finally
                {
                    conn.Close();
                }
            }

            Response.Redirect("~/Default.aspx");
        }