protected void grvProducts_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     try
     {
         prodBLL.Delete(int.Parse(grvProducts.DataKeys[e.RowIndex].Value.ToString()));
         string message = "Xóa sản phẩm thành công!";
         string url     = "/AdminCP/ListProducts.aspx";
         string script  = "$(document).ready(function (e) {";
         script += "    bootbox.alert('" + message + "', function () {";
         script += "        window.location = '" + url + "';";
         script += "    });";
         script += "});";
         ClientScript.RegisterStartupScript(this.GetType(), "Redirect", script, true);
     }
     catch
     {
         string message = "Sản phẩm đang có trong hóa đơn! <br /. Hãy xóa hóa đơn trước khi xóa sản phẩm này!";
         string url     = "/AdminCP/ListProducts.aspx";
         string script  = "$(document).ready(function (e) {";
         script += "    bootbox.alert('" + message + "', function () {";
         script += "        window.location = '" + url + "';";
         script += "    });";
         script += "});";
         ClientScript.RegisterStartupScript(this.GetType(), "Redirect", script, true);
     }
 }
Пример #2
0
    protected void ibtnDel_OnCommand(object sender, CommandEventArgs e)
    {
        int id     = Convert.ToInt32(e.CommandName);
        int typeid = Convert.ToInt32(e.CommandArgument);

        try
        {
            bll.Delete(id);
            string str = " parentId=" + id + " and categoryId=" + typeid;
            Msg.Show("删除成功!");
            InitData(1, "", -1); //重新绑定
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
        }
    }
Пример #3
0
 public ActionResult DelProducts(int id)
 {
     if (ProductsBLL.Delete(id) > 0)
     {
         return(Content("del_yes"));
     }
     else
     {
         return(Content("del_no"));
     }
 }
Пример #4
0
 public bool Delete(ProductsBOL obj)
 {
     if (obj != null)
     {
         try
         {
             int retVal = objBll.Delete(obj);
             if (retVal > 0)
             {
                 return(true);
             }
         }
         catch
         {
             return(false);
         }
     }
     return(false);
 }
Пример #5
0
 public ActionResult DeleteProduct(int ProductId)
 {
     sessionUserIdCookie = Request.Cookies["UserId"];
     if (Request.IsAjaxRequest() && sessionUserIdCookie != null)
     {
         try
         {
             _productLogic.Delete(ProductId);
             return(Json("Producto eliminado correctamente"));
         }
         catch (PersonalizedException personalizedException)
         {
             return(Json(personalizedException.Message));
         }
     }
     else
     {
         return(RedirectToAction("AccessDenied", "Users"));
     }
 }
Пример #6
0
        private void dgv_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                string   productID = dgv.Rows[e.RowIndex].Cells[1].Value.ToString();
                Products ob        = proBLL.GetProductWithID(productID);
                if (ob != null)
                {
                    txtProductId.Text = ob.ProductId;
                    txtName.Text      = ob.ProductName;
                    //txtImage.Text = ob.Image;
                    //txtUnit.Text = ob.Unit;
                    //rtxtDescription.Text = ob.Notes;
                    txtPrice.Text = ob.Price == "" ? "" : double.Parse(ob.Price).ToString("0,0");

                    /*if (!string.IsNullOrEmpty(ob.ProductType))
                     * {
                     *  //check trong cbo
                     *  //cboProductType.SelectedIndex = 0; ? làm động tác này để làm gì? Vãi các thần !!!!!
                     *  foreach (var item in cboProductType.Items)
                     *  {
                     *      KeyValuePair<string, string> itm = (KeyValuePair<string, string>)item;
                     *      if (itm.Key == ob.ProductType)
                     *      {
                     *          cboProductType.SelectedValue = ob.ProductType;
                     *          break;
                     *      }
                     *  }
                     * }*/


                    // load hinh tu web
                    //pbImgProduct.SizeMode = PictureBoxSizeMode.Zoom;
                    //bImgProduct.Image = VVPosM1.Common.Utility.GetImageFromService("Products", ob.Image);
                }

                //// Xóa
                if (e.ColumnIndex == 5)
                {
                    if (CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("KhoaNv"),
                                                                         Common.clsLanguages.GetResource("Information"),
                                                                         Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                         Common.Config.CUSTOM_MESSAGEBOX_BUTTON.YESNO) == DialogResult.Yes)
                    {
                        int Xoa = proBLL.Delete(productID);
                        if (Xoa == 1) // xóa thành côg
                        {
                            CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("KhoaTCong"),
                                                                             Common.clsLanguages.GetResource("Information"),
                                                                             Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                             Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                            dgv.Rows.RemoveAt(e.RowIndex);
                            foreach (Control c in this.pInput.Controls)
                            {
                                if (c is TextBox)
                                {
                                    ((TextBox)c).Text = String.Empty;
                                }
                                if (c is RichTextBox)
                                {
                                    ((RichTextBox)c).Text = String.Empty;
                                }
                                if (c is ComboBox)
                                {
                                    ((ComboBox)c).SelectedIndex = 0;
                                }
                                if (c is CheckBox)
                                {
                                    ((CheckBox)c).Checked = false;
                                }
                                lblTB1.Text = "...";
                                lblTB.Text  = "...";
                            }
                            DanhLaiSTT();
                        }
                    }
                }
            }
        }
        public ActionResult Delete(int Id)
        {
            var result = _get.Delete(Id);

            return(Json(new { success = result.success, messenger = result.messenger }, JsonRequestBehavior.AllowGet));
        }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region  除产品操作
            int deleteid = Request["deleteid"].ToInt32(0);
            if (deleteid != 0)
            {
                productsBLL.Delete(deleteid);
            }
            #endregion

            #region 修改状态
            int status = Request["status"].ToInt32(-1);
            if (status == 0)
            {
                int      sid = Request["sid"].ToInt32();
                Products tmp = productsBLL.QuerySingle(sid);
                if (tmp != null)
                {
                    tmp.productStatus = 1;
                    productsBLL.Update(tmp);
                }
            }
            if (status == 1)
            {
                int      sid = Request["sid"].ToInt32();
                Products tmp = productsBLL.QuerySingle(sid);
                if (tmp != null)
                {
                    tmp.productStatus = 0;
                    productsBLL.Update(tmp);
                }
            }
            #endregion

            keyword = Request["keyword"];
            page    = Request["page"].ToInt32(1);
            size    = Request["size"].ToInt32(15);
            desc    = Request["desc"].ToInt32(1);
            orderby = Request["orderby"] ?? "productId";
            if (string.IsNullOrEmpty(keyword))
            {
                pageCount = (int)Math.Ceiling(productsBLL.QueryCount(null) / size * 1.0);
                products  = productsBLL.QueryList(page, size, null, orderby, Convert.ToBoolean(desc));
            }
            else
            {
                slt = Request["slt"].ToInt32(-1);
                if (slt == 1)
                {
                    products  = productsBLL.QueryList(-1, -1, new { productId = keyword.ToInt32(0) }, "");
                    pageCount = productsBLL.QueryCount(new { productId = keyword.ToInt32(0) });
                }
                else
                {
                    string where = "%" + keyword + "%";
                    products     = productsBLL.SearchProduct(page, size, new { productName = where }, orderby, Convert.ToBoolean(desc));
                    var tmp = productsBLL.SearchProduct(-1, -1, new { productName = where }, orderby);
                    if (tmp != null)
                    {
                        pageCount = tmp.Count();
                    }
                    pageCount = (int)Math.Ceiling((double)pageCount / size);
                }
            }
        }