/// <summary>
        /// 쇼핑카트 리스트
        /// 현재 접속자에 대한 장바구니 리스트를 출력
        /// </summary>
        private void PopulateShoppingCartList()
        {
            // 쇼핑카트 인스턴스 생성
            ShoppingCartDB cart = new ShoppingCartDB();
            // 고유 키 값 생성
            string cartId = cart.GetShoppingCartId();

            // 현재 사용자에 해당하는 상품이 없다면... 아이템 카운트가 0이라면..
            if (cart.GetItemCount(cartId) == 0)
            {
                this.MultiView1.ActiveViewIndex = 1;
                lblErrorMessage.Text            = "장바구니가 비어있습니다.";
            }
            else
            {
                this.MultiView1.ActiveViewIndex = 0;
                // 바인딩
                ctlShoppingCartList.DataSource = cart.GetItems(cartId);
                ctlShoppingCartList.DataBind();

                // 총합 : 정수 3자리마다 콤마 찍기 : String.Format("{0:###,###}", 정수형데이터);
                lblTotal.Text = String.Format("{0:###,###}", cart.GetTotal(cartId));
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // 체크박스 컨트롤에 자바스크립트 이벤트 적용
            this.chkDelivery.Attributes["onclick"] = "return CopyForm();";

            // 현재 사용자의 쇼핑카트 아이디 가져오기 : 회원 또는 비회원
            ShoppingCartDB cart   = new ShoppingCartDB();
            String         cartId = cart.GetShoppingCartId();

            // 현재 접속자의 장바구니 내용 읽어오기 : ASP.NET1.X 버전과 호환 테스트 위해 데이터그리드 사용하였음
            ctlCheckOutList.DataSource = cart.GetItems(cartId);
            ctlCheckOutList.DataBind();

            // 총합 출력하기 : 만약에 3만원 이상 구매시 배송료(2500원) 미포함
            //lblTotal.Text =
            //  String.Format("{0:###,###}", cart.GetTotal(cartId));
            int intTotal = cart.GetTotal(cartId);

            if (intTotal >= 30000)
            {
                lblTotal.Text = String.Format("{0:###,###}", intTotal);
            }
            else
            {
                this.lblDelivery.Visible = true;
                lblTotal.Text            = String.Format("{0:###,###}", intTotal + 2500);
            }

            // 회원/비회원에 따른 폼 모양 정의
            if (Page.User.Identity.IsAuthenticated)
            {
                // 고객 정보 읽어오기
                string          customerId      = Page.User.Identity.Name.ToString();
                CustomersDB     customerDB      = new CustomersDB();
                CustomerDetails customerDetails = customerDB.GetCustomerDetails(customerId);

                // 고객 정보 바인딩
                // 주문자 정보 입력
                this.txtCustomerName.Text        = customerDetails.CustomerName;
                this.txtPhone1.Text              = customerDetails.Phone1;
                this.txtPhone2.Text              = customerDetails.Phone2;
                this.txtPhone3.Text              = customerDetails.Phone3;
                this.txtMobile1.Text             = customerDetails.Mobile1;
                this.txtMobile2.Text             = customerDetails.Mobile2;
                this.txtMobile3.Text             = customerDetails.Mobile3;
                this.txtZip.Text                 = customerDetails.Zip;
                this.txtAddress.Text             = customerDetails.Address;
                this.txtAddressDetail.Text       = customerDetails.AddressDetail;
                this.txtSsn1.Text                = customerDetails.Ssn1;
                this.txtSsn2.Text                = customerDetails.Ssn2;
                this.txtEmailAddress.Text        = customerDetails.EmailAddress;
                this.MemberDivisionPanel.Visible = false;
                // 배송지 정보 입력
                this.txtDeliveryCustomerName.Text  = customerDetails.CustomerName;
                this.txtDeliveryTelePhone1.Text    = customerDetails.Phone1;
                this.txtDeliveryTelePhone2.Text    = customerDetails.Phone2;
                this.txtDeliveryTelePhone3.Text    = customerDetails.Phone3;
                this.txtDeliveryMobilePhone1.Text  = customerDetails.Mobile1;
                this.txtDeliveryMobilePhone2.Text  = customerDetails.Mobile2;
                this.txtDeliveryMobilePhone3.Text  = customerDetails.Mobile3;
                this.txtDeliveryZipCode.Text       = customerDetails.Zip;
                this.txtDeliveryAddress.Text       = customerDetails.Address;
                this.txtDeliveryAddressDetail.Text = customerDetails.AddressDetail;
            }
            else
            {
                this.MemberDivisionPanel.Visible = true;
            }
        }