Пример #1
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);
     }
 }
Пример #2
0
        protected void grdProduct_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            string          strCA  = e.CommandArgument.ToString();
            SqlDataProvider sql    = new SqlDataProvider();
            string          strPri = "";
            DataTable       dtPro  = ProductService.Product_GetById(strCA);

            switch (e.CommandName)
            {
            case "Edit":
                Insert = false;
                Id     = strCA;
                LoadDropDownListGroupProduct();
                LoadCheckBoxChude();
                ddlGroupProduct.SelectedValue = dtPro.Rows[0]["GroupId"].ToString();
                txtName.Text       = dtPro.Rows[0]["Name"].ToString();
                txtImage1.Text     = dtPro.Rows[0]["Image1"].ToString();
                imgImage1.ImageUrl = dtPro.Rows[0]["Image1"].ToString().Length > 0 ? dtPro.Rows[0]["Image1"].ToString() : "";
                txtKichThuoc.Text  = dtPro.Rows[0]["Image5"].ToString();
                txtContent.Text    = dtPro.Rows[0]["Content"].ToString();
                fckDetail.Value    = dtPro.Rows[0]["Detail"].ToString();
                txtPricePro.Text   = StringClass.ConvertPrice(dtPro.Rows[0]["Price"].ToString());
                chkPopular.Checked = dtPro.Rows[0]["IsPopular"].ToString() == "1" || dtPro.Rows[0]["IsPopular"].ToString() == "True";
                List <string> chude = new List <string>(dtPro.Rows[0]["ChudeId"].ToString().Split(','));
                foreach (ListItem item in cklChude.Items)
                {
                    if (chude.Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                }
                //chkHot.Checked = dtPro.Rows[0]["IsHot"].ToString() == "1" || dtPro.Rows[0]["IsHot"].ToString() == "True";
                //chkNew.Checked = dtPro.Rows[0]["IsNew"].ToString() == "1" || dtPro.Rows[0]["IsNew"].ToString() == "True";
                chkSpecial.Checked    = dtPro.Rows[0]["IsSpecial"].ToString() == "1" || dtPro.Rows[0]["IsSpecial"].ToString() == "True";
                txtOrd.Text           = dtPro.Rows[0]["Ord"].ToString();
                chkActive.Checked     = dtPro.Rows[0]["Active"].ToString() == "1" || dtPro.Rows[0]["Active"].ToString() == "True";
                pnView.Visible        = false;
                pnUpdate.Visible      = true;
                pnUpdatePrice.Visible = false;
                break;

            case "Active":
                string strA = "";
                string str  = e.Item.Cells[2].Text;
                strA = str == "1" ? "0" : "1";
                sql.ExecuteNonQuery("Update [Product] set Active=" + strA + "  Where Id='" + strCA + "'");
                BindGrid();
                break;

            case "Delete":
                ProductService.Product_Delete(strCA);
                BindGrid();
                break;

            case "IsPopular":
                strPri = dtPro.Rows[0]["IsPopular"].ToString() == "1" ? "0" : "1";
                sql.ExecuteNonQuery("Update [Product] set [IsPopular]=" + strPri + "  Where Id='" + strCA + "'");
                BindGrid();
                break;

            case "IsHot":
                strPri = dtPro.Rows[0]["IsHot"].ToString() == "1" ? "0" : "1";
                sql.ExecuteNonQuery("Update [Product] set [IsHot]=" + strPri + "  Where Id='" + strCA + "'");
                BindGrid();
                break;

            case "IsNew":
                strPri = dtPro.Rows[0]["IsNew"].ToString() == "1" ? "0" : "1";
                sql.ExecuteNonQuery("Update [Product] set [IsNew]=" + strPri + "  Where Id='" + strCA + "'");
                BindGrid();
                break;

            case "IsSpecial":
                strPri = dtPro.Rows[0]["IsSpecial"].ToString() == "1" ? "0" : "1";
                sql.ExecuteNonQuery("Update [Product] set [IsSpecial]=" + strPri + "  Where Id='" + strCA + "'");
                BindGrid();
                break;

            case "AddPrice":
                Id                    = strCA;
                pnView.Visible        = false;
                pnUpdate.Visible      = false;
                pnUpdatePrice.Visible = true;
                break;
            }
        }