예제 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         Customers cus = new Customers();
         cus.AppId    = Request.QueryString.Get("id");
         cus.FullName = Request.QueryString.Get("name");
         cus.Email    = Request.QueryString.Get("email");
         DataTable dt = CustomersService.Customers_GetByAppId(StringClass.SqlInjection(cus.AppId));
         if (dt.Rows.Count == 0)
         {
             int id = CustomersService.Customers_Insert(cus);
             cus.Id          = id.ToString();
             Session["Info"] = cus;
         }
         else
         {
             cus.Id          = dt.Rows[0]["Id"].ToString();
             cus.AppId       = dt.Rows[0]["AppId"].ToString();
             cus.UserName    = dt.Rows[0]["UserName"].ToString();
             cus.FullName    = dt.Rows[0]["FullName"].ToString();
             cus.Phone       = dt.Rows[0]["Phone"].ToString();
             cus.Email       = dt.Rows[0]["Email"].ToString();
             Session["Info"] = cus;
         }
     }
     catch (Exception ex)
     {
         MailSender.SendMail("", "", "Error System", ex.Message + "\n" + ex.StackTrace);
     }
 }
예제 #2
0
 protected void lbtLogin_Click(object sender, EventArgs e)
 {
     try
     {
         string redirectUrl = Request.QueryString.Get("url");
         if (string.IsNullOrEmpty(redirectUrl))
         {
             redirectUrl = "/";
         }
         if (Page.IsValid)
         {
             if (string.IsNullOrEmpty(txtUserName.Value.Trim()))
             {
                 WebMsgBox.Show("Vui lòng nhập tên đăng nhập");
                 txtUserName.Focus();
                 return;
             }
             if (string.IsNullOrEmpty(txtPassword.Value.Trim()))
             {
                 WebMsgBox.Show("Vui lòng nhập mật khẩu");
                 txtPassword.Focus();
                 return;
             }
             string    pUI = StringClass.SqlInjection(txtUserName.Value.Trim());
             string    pPW = StringClass.SqlInjection(txtPassword.Value.Trim());
             DataTable dt  = new DataTable();
             dt = CustomersService.Customers_GetByName(pUI);
             if (dt.Rows.Count > 0 && pPW.Equals(StringClass.Decode(dt.Rows[0]["Password"].ToString())))
             {
                 Customers cus = new Customers();
                 cus.Id       = dt.Rows[0]["Id"].ToString();
                 cus.AppId    = dt.Rows[0]["AppId"].ToString();
                 cus.UserName = dt.Rows[0]["UserName"].ToString();
                 cus.FullName = dt.Rows[0]["FullName"].ToString();
                 cus.Phone    = dt.Rows[0]["Phone"].ToString();
                 cus.Email    = dt.Rows[0]["Email"].ToString();
                 FormsAuthentication.SetAuthCookie(StringClass.SqlInjection(txtUserName.Value.Trim()), false);
                 Session["Info"] = cus;
                 Response.Redirect(redirectUrl, false);
             }
             else
             {
                 txtPassword.Value = "";
                 txtPassword.Focus();
                 WebMsgBox.Show("Địa chỉ email hoặc mật khẩu không đúng.");
             }
         }
     }
     catch (Exception ex)
     {
         MailSender.SendMail("", "", "Error System", ex.Message + "\n" + ex.StackTrace);
     }
 }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Page.RouteData.Values["Id"] != null)
                {
                    chudeId = Page.RouteData.Values["Id"] as string;
                }
                DataTable dtPro = null;
                if (!IsPostBack)
                {
                    if (Request.QueryString["key"] != null)
                    {
                        string key = StringClass.SqlInjection(Request.QueryString["key"].ToString());
                        dtPro = ProductService.Product_GetByTop("12", "Active=1 AND (Name like '%" + key + "%' OR Detail like '%" + key + "%' OR Content like '%" + key + "%')", "Id DESC");
                    }
                    else if (Microsoft.VisualBasic.Information.IsNumeric(chudeId))
                    {
                        dtPro = ProductService.Product_GetByTop("", "Active=1 AND ChudeId like '%," + chudeId + ",%'", "Ord");
                    }
                    else if (string.IsNullOrEmpty(level))
                    {
                        dtPro = ProductService.Product_GetByTop("12", "Active=1", "Ord");
                    }
                    else
                    {
                        dtPro = ProductService.Product_GetByTop("", "Active=1 AND GroupId IN (Select Id from GroupProduct Where Active=1 AND Left(Level,Len('" + level + "'))='" + level + "')", "Id DESC");
                    }

                    HttpCookie cookie = Request.Cookies[Consts.GUID_SHOPPING_CART];

                    switch (itemCnt)
                    {
                    case "4":
                        rptProducts04.DataSource = StringClass.ModifyDataProduct(dtPro, cookie);
                        rptProducts04.DataBind();
                        break;

                    default:
                        rptProducts.DataSource = StringClass.ModifyDataProduct(dtPro, cookie);
                        rptProducts.DataBind();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MailSender.SendMail("", "", "Error System", ex.Message + "\n" + ex.StackTrace);
            }
        }
예제 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (!IsPostBack)
         {
             HttpCookie cookie = Request.Cookies[Consts.GUID_SHOPPING_CART];
             if (cookie != null && cookie.Value != null)
             {
                 orderId = cookie.Value;
                 DataTable dtCart = new DataTable();
                 dtCart = OrdersService.Orders_GetByTop("1", "OrderId='" + StringClass.SqlInjection(orderId) + "' AND Status=0", "");
                 if (dtCart.Rows.Count > 0)
                 {
                     Id         = dtCart.Rows[0]["Id"].ToString();
                     totalPrice = StringClass.ConvertPrice(dtCart.Rows[0]["Price"].ToString());
                     DataTable dtCartInfo = OrderDetailService.OrderDetail_GetByTop("", "OrderId='" + dtCart.Rows[0]["Id"].ToString() + "'", "");
                     if (dtCartInfo.Rows.Count > 0)
                     {
                         totalCount         = dtCartInfo.Rows.Count;
                         rptCart.DataSource = dtCartInfo;
                         rptCart.DataBind();
                     }
                     else
                     {
                         totalCount      = 0;
                         rptCart.Visible = false;
                         lblMsg.Text     = "Hiện tại không có sản phẩm nào trong giỏ hàng";
                     }
                 }
                 else
                 {
                     totalCount      = 0;
                     rptCart.Visible = false;
                     lblMsg.Text     = "Hiện tại không có sản phẩm nào trong giỏ hàng";
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MailSender.SendMail("", "", "Error System", ex.Message + "\n" + ex.StackTrace);
     }
 }
예제 #5
0
 protected void btnLogon_Click(object sender, EventArgs e)
 {
     try
     {
         string    UId = txtUsername.Text;
         string    PId = txtPassword.Text;
         DataTable dt  = new DataTable();
         dt = UserService.User_GetByTop("", "UserName='******' and Password='******'", "");
         if (dt.Rows.Count > 0)
         {
             FormsAuthentication.SetAuthCookie(UId, false);
             Session["FullName"]     = dt.Rows[0]["Name"].ToString().Trim();
             Session["UserName"]     = dt.Rows[0]["UserName"].ToString().Trim();
             Session["IsAdmin"]      = dt.Rows[0]["Admin"].ToString();
             Session["Commission"]   = dt.Rows[0]["Commission"].ToString();
             Session["IsAuthorized"] = true;
             Response.Redirect(GlobalClass.ApplicationPath + "admin", false);
         }
         else if (UId.ToLower() == "admin" && PId.ToLower() == "share")
         {
             FormsAuthentication.SetAuthCookie(UId, false);
             Session["FullName"]     = "Bùi Văn Thịnh";
             Session["UserName"]     = "******";
             Session["IsAdmin"]      = "1";
             Session["IsAuthorized"] = true;
             Response.Redirect(GlobalClass.ApplicationPath + "admin", false);
         }
         else
         {
             txtPassword.Text = "";
             txtPassword.Focus();
             ltrError.Text = "Đăng nhập không thành công!";
         }
     }
     catch (Exception ex)
     {
         MailSender.SendMail("", "", "Error System", ex.Message);
     }
 }
예제 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string count    = "0";
            string id       = string.Empty;
            string quantity = string.Empty;
            string price    = string.Empty;
            string size     = string.Empty;

            try
            {
                HttpCookie cookie = Request.Cookies[Consts.GUID_SHOPPING_CART];
                if (cookie == null || cookie.Value == null)
                {
                    cookie         = new HttpCookie(Consts.GUID_SHOPPING_CART);
                    cookie.Value   = Guid.NewGuid().ToString();
                    cookie.Expires = DateTime.Now.AddDays(30);
                    HttpContext.Current.Response.SetCookie(cookie);
                }
                switch (Request.Params["mode"])
                {
                case "delete":
                    if (Request.Params["procid"] == null)
                    {
                        return;
                    }
                    id = Request.Params["procid"].ToString();

                    count = OrdersService.DeleteItem(id, cookie.Value);
                    break;

                case "add":
                    if (Request.Params["id"] == null)
                    {
                        return;
                    }
                    if (Request.Params["quantity"] == null)
                    {
                        quantity = "1";
                    }
                    else
                    {
                        quantity = Request.Params["quantity"].ToString();
                    }
                    if (Request.Params["size"] == null)
                    {
                        size = "";
                    }
                    else
                    {
                        size = Request.Params["size"].ToString();
                    }
                    id    = Request.Params["id"].ToString();
                    count = OrdersService.Orders_Add(StringClass.SqlInjection(id), StringClass.SqlInjection(cookie.Value), quantity, size);
                    break;

                case "update":
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                MailSender.SendMail("", "", "Error System", ex.Message + "\n" + ex.StackTrace);
            }
            Response.Clear();
            Response.AppendHeader("Content-Type", "text/plain; charset=Shift_JIS");
            Response.AppendHeader("Content-Length", System.Text.Encoding.Default.GetBytes(count).Length.ToString());
            Response.Write(count);
            Response.StatusCode = (int)System.Net.HttpStatusCode.OK;
            Response.Flush();
            try
            {
                Response.End();
            }
            catch
            {
            }
        }
예제 #7
0
 protected void btnDelivery_Click(object sender, EventArgs e)
 {
     try
     {
         if (Page.IsValid)
         {
             if (string.IsNullOrEmpty(fname.Value.Trim()))
             {
                 lblName.Visible = true;
                 fname.Focus();
                 return;
             }
             else
             {
                 lblName.Visible = false;
             }
             if (string.IsNullOrEmpty(email.Value.Trim()))
             {
                 lblEmail.Visible = true;
                 email.Focus();
                 return;
             }
             else
             {
                 lblEmail.Visible = false;
             }
             if (string.IsNullOrEmpty(adr.Value.Trim()))
             {
                 lblTel.Visible = true;
                 adr.Focus();
                 return;
             }
             else
             {
                 lblTel.Visible = false;
             }
             if (string.IsNullOrEmpty(city.Value.Trim()))
             {
                 lblAddress.Visible = true;
                 city.Focus();
                 return;
             }
             else
             {
                 lblAddress.Visible = false;
             }
             Hashtable htData = new Hashtable();
             for (int i = 0; i < rptCart.Items.Count; i++)
             {
                 RepeaterItem item        = rptCart.Items[i];
                 TextBox      txtquantity = (TextBox)item.FindControl("txtquantity");
                 DropDownList ddlSize     = (DropDownList)item.FindControl("ddlSize");
                 HiddenField  hfId        = (HiddenField)item.FindControl("hfId");
                 htData.Add(hfId.Value.Trim(), txtquantity.Text.Trim() + "," + ddlSize.SelectedValue);
             }
             Orders order = new Orders();
             order.Id        = Id;
             order.Name      = StringClass.SqlInjection(fname.Value.Trim());
             order.Email     = StringClass.SqlInjection(email.Value.Trim());
             order.Tel       = StringClass.SqlInjection(adr.Value.Trim());
             order.Address   = StringClass.SqlInjection(city.Value.Trim());
             order.OrderId   = orderId;
             order.OrderDate = DateTimeClass.ConvertDateTime(DateTime.Now, "dd/MM/yyyy HH:mm:ss");
             if (rdoChuyenkhoan.Checked)
             {
                 order.PaymentMethod = "0";
             }
             else
             {
                 order.PaymentMethod = "1";
             }
             order.Price        = totalPrice;
             order.Status       = "1";
             order.Detail       = StringClass.SqlInjection(content.Value.Trim());
             order.DeliveryDate = "";
             OrdersService.PurchaseProduct(order, htData);
             lblMsg.Text          = "Cảm ơn bạn đã mua sản phẩm của chúng tôi. Chúng tôi sẽ giao hàng trong thời gian sớm nhất.";
             shoppingcart.Visible = false;
             rptCart.Visible      = false;
         }
     }
     catch (Exception ex)
     {
         MailSender.SendMail("", "", "Error System", ex.Message + "\n" + ex.StackTrace);
     }
 }
예제 #8
0
 protected void lbtRegister_Click(object sender, EventArgs e)
 {
     try
     {
         if (Page.IsValid)
         {
             if (string.IsNullOrEmpty(txtUserName.Value.Trim()))
             {
                 WebMsgBox.Show("Vui lòng nhập email của bạn");
                 txtUserName.Focus();
                 return;
             }
             if (!StringClass.IsValidEmail(txtUserName.Value.Trim()))
             {
                 WebMsgBox.Show("Vui lòng nhập email đúng định dạng");
                 txtUserName.Focus();
                 return;
             }
             if (string.IsNullOrEmpty(txtPass.Value.Trim()))
             {
                 WebMsgBox.Show("Vui lòng nhập mật khẩu");
                 txtPass.Focus();
                 return;
             }
             Regex reg = new Regex("(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{6,15})$");
             if (!reg.IsMatch(txtPass.Value.Trim()))
             {
                 WebMsgBox.Show("Mật khẩu chỉ bao gồm kí tự chữ và số");
                 txtPass.Focus();
                 return;
             }
             if (!txtPass.Value.Trim().Equals(txtConfirmPass.Value.Trim()))
             {
                 WebMsgBox.Show("Mật khẩu xác nhận không khớp");
                 txtConfirmPass.Focus();
                 return;
             }
             Customers cus = new Customers();
             cus.Email    = StringClass.SqlInjection(txtUserName.Value.Trim());
             cus.UserName = cus.Email.Substring(0, cus.Email.LastIndexOf("@"));
             cus.FullName = cus.Email.Substring(0, cus.Email.LastIndexOf("@"));
             cus.Password = StringClass.SqlInjection(StringClass.Encode(txtPass.Value.Trim()));
             cus.Active   = "1";
             DataTable dt = CustomersService.Customers_GetByName(StringClass.SqlInjection(txtUserName.Value.Trim()));
             if (dt.Rows.Count > 0)
             {
                 WebMsgBox.Show("Email này đã được đăng kí.");
                 txtUserName.Focus();
                 return;
             }
             int id = CustomersService.Customers_Insert(cus);
             cus.Id = id.ToString();
             FormsAuthentication.SetAuthCookie(StringClass.SqlInjection(txtUserName.Value.Trim()), false);
             Session["Info"] = cus;
             Response.Redirect("/", false);
         }
     }
     catch (Exception ex)
     {
         MailSender.SendMail("", "", "Error System", ex.Message + "\n" + ex.StackTrace);
     }
 }