//GET //Retrieves existing customer from the database Author Stephen Sander public ActionResult GetCustomer(string username) { username = (string)Session["Username"]; UpdateCustomer oldCust = CustomersDB.GetCustomer(username); return(View(oldCust)); }
public ActionResult GetCustomer(UpdateCustomer newCust) { string username = (string)Session["Username"]; try { UpdateCustomer oldCust = CustomersDB.GetCustomer(username); //Thread.Sleep(10000) int count = CustomersDB.UpdateCustomer(oldCust, newCust); if (count == 0)// no update due to concurrency issue { TempData["errorMessage"] = "Update aborted. " + "Another user changed or deleted this row"; } else { TempData["errorMessage"] = ""; } return(RedirectToAction("Index", "Home")); } catch { return(View()); } }
private void FillOrderDetails(int OrderID) { //create an instance of the CustomersDB class CustomersDB customer = new CustomersDB(); DataSet datasetOrders = customer.GetOrderDetails(OrderID); //bind the data set to the datagrid. dgOrderDetails.SetDataBinding(datasetOrders, datasetOrders.Tables[0].TableName); }
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 = "로그인에 실패했습니다. 다시 로그인하세요."; } }
private void btnGetCust_Click(object sender, System.EventArgs e) { //get the customer id string customerID = this.cboCustomers.SelectedValue.ToString(); //create an instance of the CustomersDB class. CustomersDB customerData = new CustomersDB(); //get the orders for the selected customer. DataSet datasetOrders = customerData.GetOrders(customerID); //bind the dataset to the datagrid. dgOrders.SetDataBinding(datasetOrders, datasetOrders.Tables[0].TableName); }
protected override void SetUp() { mProps = new CustomersProps(); mOldProps = new CustomersProps(); if (this.mConnectionString == "") { mdbReadable = new CustomersDB(); mdbWriteable = new CustomersDB(); } else { mdbReadable = new CustomersDB(this.mConnectionString); mdbWriteable = new CustomersDB(this.mConnectionString); } }
private void CustomerOrders_Load(object sender, System.EventArgs e) { //loads the form with the customer information. //create instance of CustomersDB class CustomersDB customerData = new CustomersDB(); //retrieve the Customers. DataSet datasetOrders = customerData.GetCustomers(); //create the dataview object. DataView dataviewOrders = new DataView(datasetOrders.Tables[0]); cboCustomers.DataSource = dataviewOrders; //set the display properties of the Customers combo box. cboCustomers.DisplayMember = dataviewOrders.Table.Columns["CompanyName"].ColumnName; cboCustomers.ValueMember = dataviewOrders.Table.Columns["CustomerID"].ColumnName; }
public ActionResult Register(Customers customer) { if (ModelState.IsValid) { int existingUsername = CustomersDB.GetUserDetails(customer.UserName); int existingEmail = CustomersDB.GetEmailDetails(customer.CustEmail); if (existingUsername == 0 && existingEmail == 0) { CustomersDB.RegisterCustomers(customer); Session["Username"] = customer.UserName; Session["CustFirstName"] = customer.CustFirstName; Session["CustLastName"] = customer.CustLastName; ViewBag.firstName = Session["CustFirstName"]; ViewBag.lastName = Session["CustLastName"]; ViewBag.Message = "Valid User"; return(RedirectToAction("Index", "Home")); } else if (existingUsername > 0 || existingEmail > 0) { if (existingUsername > 0) { ViewBag.UsernameMessage = "This username is already taken"; } if (existingEmail > 0) { ViewBag.EmailMessage = "This email is already taken"; } } } return(View()); }
protected void cmdCheckOut_Click(object sender, System.EventArgs e) { // 쇼핑카트 클래스 인스턴스 생성 ShoppingCartDB cart = new ShoppingCartDB(); // 쇼핑카트 아아디 가져오기 : 회원 string cartId = cart.GetShoppingCartId(); // 주문번호 : 회원이든 비회원이든 주문번호는 생성(비회원이면, 주문정보 확인시 사용) int orderId = 0; // 회원/비회원에 따른 폼 모양 정의 if (Page.User.Identity.IsAuthenticated) { // 고객코드 가져오기 string customerId = Page.User.Identity.Name; // 주문 정보 클래스 사용 OrderDetails orderDetails = new OrderDetails(); orderDetails.CustomerID = customerId; // 배송비 포함 여부 : 3만원 이상 orderDetails.TotalPrice = (cart.GetTotal(cartId) >= 30000) ? cart.GetTotal(cartId) : cart.GetTotal(cartId) + 2500; orderDetails.OrderStatus = "신규주문"; orderDetails.Payment = this.lstPayment.SelectedValue; // 배송비 포함 여부 : 3만원 이상 orderDetails.PaymentPrice = (cart.GetTotal(cartId) >= 30000) ? cart.GetTotal(cartId) : cart.GetTotal(cartId) + 2500; orderDetails.PaymentInfo = "미입금"; orderDetails.DeliveryInfo = 1;//일단 회원... orderDetails.DeliveryStatus = "미배송"; orderDetails.OrderIP = Request.UserHostAddress; orderDetails.Password = ""; orderDetails.CartID = cartId; orderDetails.Message = this.txtMessage.Text; // orderDetails.CustomerName = this.txtCustomerName.Text; orderDetails.TelePhone = String.Format("{0}-{1}-{2}" , this.txtDeliveryTelePhone1.Text , this.txtDeliveryTelePhone2.Text , this.txtDeliveryTelePhone3.Text); orderDetails.MobilePhone = String.Format("{0}-{1}-{2}" , this.txtDeliveryMobilePhone1.Text , this.txtDeliveryMobilePhone2.Text , this.txtDeliveryMobilePhone3.Text); orderDetails.ZipCode = this.txtDeliveryZipCode.Text; orderDetails.Address = this.txtDeliveryAddress.Text; orderDetails.AddressDetail = this.txtDeliveryAddressDetail.Text; // 고객이면서 장바구니에 구매 상품이 담겨져 있다면, if ((cartId != null) && (customerId != null)) { // 주문 클래스 인스턴스 생성 OrdersDB ordersDatabase = new OrdersDB(); // 주문 실행 orderId = ordersDatabase.PlaceOrder(orderDetails); // 주문 완료 표시 lblMessage.Text = "당신이 주문하신 주문번호는 : " + orderId + "입니다."; cmdCheckOut.Visible = false;// 구매 버튼 숨기기 } } else // 비회원 주문 처리 { // 고객 클래스 인스턴스 생성 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.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.EmailAddress = this.txtEmailAddress.Text; customerDetails.MemberDivision = 0;//비회원 // 고객 정보 저장 및 고객 코드 반환 string customerId = accountSystem.AddNonCustomer(customerDetails); // 주문 정보 클래스 사용 OrderDetails orderDetails = new OrderDetails(); orderDetails.CustomerID = customerId; orderDetails.TotalPrice = (cart.GetTotal(cartId) >= 30000) ? cart.GetTotal(cartId) : (cart.GetTotal(cartId) + 2500); orderDetails.OrderStatus = "신규주문"; orderDetails.Payment = this.lstPayment.SelectedValue; orderDetails.PaymentPrice = (cart.GetTotal(cartId) >= 30000) ? cart.GetTotal(cartId) : (cart.GetTotal(cartId) + 2500); orderDetails.PaymentInfo = "미입금"; orderDetails.DeliveryInfo = 0;// 비회원... orderDetails.DeliveryStatus = "미배송"; orderDetails.OrderIP = Request.UserHostAddress; orderDetails.Password = this.txtOrdersPassword.Text; orderDetails.CartID = cartId; orderDetails.Message = this.txtMessage.Text; // orderDetails.CustomerName = this.txtCustomerName.Text; orderDetails.TelePhone = String.Format("{0}-{1}-{2}" , this.txtDeliveryTelePhone1.Text , this.txtDeliveryTelePhone2.Text , this.txtDeliveryTelePhone3.Text); orderDetails.MobilePhone = String.Format("{0}-{1}-{2}" , this.txtDeliveryMobilePhone1.Text , this.txtDeliveryMobilePhone2.Text , this.txtDeliveryMobilePhone3.Text); orderDetails.ZipCode = this.txtDeliveryZipCode.Text; orderDetails.Address = this.txtDeliveryAddress.Text; orderDetails.AddressDetail = this.txtDeliveryAddressDetail.Text; // 비회원이면서 장바구니에 구매 상품이 담겨져 있다면, if ((cartId != null) && (customerId != null)) { // 주문 클래스 인스턴스 생성 OrdersDB ordersDatabase = new OrdersDB(); // 주문 실행 orderId = ordersDatabase.PlaceOrder(orderDetails); // 주문 완료 표시 lblMessage.Text = "<hr />당신이 주문하신 주문번호는 : " + orderId + "입니다.<br />"; lblMessage.Text += "<a href='Default.aspx'>홈으로 가기</a><hr />"; cmdCheckOut.Visible = false;// 구매 버튼 숨기기 } } // 메일전송 : 주문 내역을 메일 또는 SMS로 보내주는 코드는 이 부분에 위치 // System.Web.Mail.SmtpMail.Send("*****@*****.**", this.txtEmailAddress.Text, "주문이 완료되었습니다.", "주문번호 : " + orderId + ", 주문비밀번호 : " + this.txtOrdersPassword.Text); }
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; } }
protected void btnCustRegister_Click(object sender, EventArgs e) { bool UserNameChecked = false; bool insert = false; List <string> userNames = CustomersDB.GetUserNames(); // replace with user name list foreach (string username in userNames) { if (txtCustUserName.Text == username) { Response.Write("User name is already taken. Please choose another user name"); UserNameChecked = false; break; } else { UserNameChecked = true; } } if (Page.IsValid && UserNameChecked) { string cryptPassword = EncryptDB.Encrypt(txtCustPassword.Text); Customer cust = new Customer(txtCustFirstName.Text, txtCustLastName.Text, txtCustAddress.Text, txtCustCity.Text, ddlCustProv.SelectedValue.ToString(), txtCustPostal.Text, ddlCustCountry.SelectedValue.ToString(), txtCustHomePhone.Text, txtCustBusPhone.Text, txtCustEmail.Text, txtCustUserName.Text, cryptPassword.ToString().Trim()); SqlConnection conn = TravelExperts1DB.GetConnection(); try { conn.Open(); insert = CustomersDB.CreateCustomer(cust); if (insert) { Response.Redirect("http://localhost:61652/Login.aspx"); //Response.Write("Registration successful"); } //else // Response.Write("Registration unsuccessful"); } catch (Exception) { //Response.Write("User name is already taken. Please choose another user name"); //throw ex; Response.Write("Registration unsuccessful"); } finally { conn.Close(); } } //else //{ // Response.Write("Registration unsuccessful"); //} }
// 회원 가입 버튼 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: 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"); }
public Customers() { customersDB = new CustomersDB(); serviceClient = new MyServiceClient(); }
public CustomersManager(IConfiguration configuration) { CustomerDB = new CustomersDB(configuration); }