Exemplo n.º 1
0
        protected void btnLogin_Click(object sender, System.EventArgs e)
        {
            // 오래된 쇼핑카트 아이디 저장
            ShoppingCartDB shoppingCart = new ShoppingCartDB();
            string         tempCartID   = shoppingCart.GetShoppingCartId();

            // 로그인 정보가 맞는지 확인
            CustomersDB accountSystem = new CustomersDB();
            // 로그인이 정상적으로 진행되면 고객번호 : 1번 고객, 2번 고객
            string customerId = accountSystem.Login(txtUserID.Text, Security.Encrypt(txtPassword.Text));

            if (customerId != null)
            {
                // 현재 쇼핑카트 정보를 고객 정보로 마이그레이트
                shoppingCart.MigrateCart(tempCartID, customerId);

                // 고객의 모든 정보 값 반환
                CustomerDetails customerDetails = accountSystem.GetCustomerDetails(customerId);

                // 고객의 이름을 쿠키에 저장
                // Response.Cookies["Shopping_CustomerName"].Value = customerDetails.CustomerName;
                HttpCookie customerName = new HttpCookie("Shopping_CustomerName", Server.UrlEncode(customerDetails.CustomerName));
                customerName.HttpOnly = true;
                Response.Cookies.Add(customerName);

                // 고객의 이이디를 쿠키에 저장
                Response.Cookies["Shopping_UserID"].Value = customerDetails.UserID;

                // 고객 이름 저장 체크박스 확인
                if (chkRememberLogin.Checked == true)
                {
                    // 앞으로 한달간 저장
                    Response.Cookies["Shopping_CustomerName"].Expires = DateTime.Now.AddMonths(1);
                }

                // 원래 요청했었던 페이지로 이동
                if (Request.ServerVariables["SCRIPT_NAME"].ToLower().EndsWith("checklogin.aspx"))
                {
                    System.Web.Security.FormsAuthentication.SetAuthCookie(customerId, chkRememberLogin.Checked); // 인증값 부여
                    Response.Redirect("CheckOut.aspx");                                                          // 현재 페이지가 로그인 체크 페이지면 주문서 페이지로 이동
                }
                else
                {
                    // 따로 지정하지 않았으면 기본값으로 ~/Default.aspx로 이동
                    System.Web.Security.FormsAuthentication.RedirectFromLoginPage(customerId, chkRememberLogin.Checked);
                }
            }
            else
            {
                lblError.Text = "로그인에 실패했습니다. 다시 로그인하세요.";
            }
        }
Exemplo n.º 2
0
        // 회원 가입 버튼
        protected void btnRegister_Click(object sender, System.EventArgs e)
        {
            // 쇼핑 카드 업데이트
            ShoppingCartDB shoppingCart = new ShoppingCartDB();
            String         tempCartId   = shoppingCart.GetShoppingCartId();

            // 고객 클래스 인스턴스 생성
            CustomersDB     accountSystem   = new CustomersDB();
            CustomerDetails customerDetails = new CustomerDetails();

            customerDetails.CustomerName   = this.txtCustomerName.Text;
            customerDetails.Phone1         = this.txtPhone1.Text;
            customerDetails.Phone2         = this.txtPhone2.Text;
            customerDetails.Phone3         = this.txtPhone2.Text;
            customerDetails.Mobile1        = this.txtMobile1.Text;
            customerDetails.Mobile2        = this.txtMobile2.Text;
            customerDetails.Mobile3        = this.txtMobile3.Text;
            customerDetails.EmailAddress   = this.txtEmailAddress.Text;
            customerDetails.MemberDivision = 1;
            //
            customerDetails.UserID        = this.txtUserID.Text;
            customerDetails.Password      = Security.Encrypt(txtPassword.Text);
            customerDetails.Zip           = this.txtZip.Text;
            customerDetails.Address       = this.txtAddress.Text;
            customerDetails.AddressDetail = this.txtAddressDetail.Text;
            customerDetails.Ssn1          = this.txtSsn1.Text;
            customerDetails.Ssn2          = this.txtSsn2.Text;
            customerDetails.BirthYear     = this.txtBirthYear.Text;
            customerDetails.BirthMonth    = this.txtBirthMonth.Text;
            customerDetails.BirthDay      = this.txtBirthDay.Text;
            customerDetails.BirthStatus   = this.lstBirthStatus.SelectedValue;
            customerDetails.Gender        = Convert.ToInt32(this.lstGender.SelectedValue);
            customerDetails.Job           = this.lstJob.SelectedValue;
            customerDetails.Wedding       = Convert.ToInt32(this.lstWedding.SelectedValue);
            customerDetails.Hobby         = this.txtHobby.Text;
            customerDetails.Homepage      = this.txtHomepage.Text;
            customerDetails.Intro         = this.txtIntro.Text;
            customerDetails.Mailing       = (this.chkMailing.Checked) ? 1 : 0;
            customerDetails.Mileage       = 0;

            // 고객 정보 입력
            string customerId = accountSystem.AddCustomer(customerDetails);

            if (customerId != "")
            {
                // 회원가입 후 바로 로그인 처리 : 1, 2, 3
                System.Web.Security.FormsAuthentication.SetAuthCookie(customerId, false);

                shoppingCart.MigrateCart(tempCartId, customerId);
                // 현재 접속자의 이름은 따로 쿠키에 저장
                //Response.Cookies["Shopping_CustomerName"].Value = Server.HtmlEncode(this.txtCustomerName.Text); // 홍길동
                HttpCookie customerName = new HttpCookie("Shopping_CustomerName", Server.UrlEncode(txtCustomerName.Text));
                customerName.HttpOnly = true;
                Response.Cookies.Add(customerName);
            }
            else
            {
                lblDisplay.Text = "Registration failed:&nbsp; That email address is already registered.<br /><img align=left height=1 width=92 src=images/1x1.gif>";
            }

            string strJs = @"
			<script language='javascript'>
			window.alert('회원가입을 축하드립니다.');
			location.href='Default.aspx';
			</script>
		"        ;

            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "js", strJs);

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