예제 #1
0
        protected void rptProductDetails_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            DataTable dt = new DataTable();

            dt = _product.GetListProductDetail_ByProDelID(int.Parse(e.CommandArgument.ToString()));
            switch (e.CommandName.ToString())
            {
            case "update":
                if (dt.Rows.Count > 0)
                {
                    drpProductCategory.SelectedValue = dt.Rows[0]["ProID"].ToString();
                    txtCode.Text      = dt.Rows[0]["vCode"].ToString();
                    txtName.Text      = dt.Rows[0]["vName"].ToString();
                    txtDesc.Text      = dt.Rows[0]["vDesc"].ToString();
                    txtContent.Text   = dt.Rows[0]["vContent"].ToString();
                    hdImage.Value     = dt.Rows[0]["vImage"].ToString();
                    txtQuantity.Text  = dt.Rows[0]["iQuantity"].ToString();
                    txtPrice.Text     = dt.Rows[0]["vPrice"].ToString();
                    txtView.Text      = dt.Rows[0]["iView"].ToString();
                    chkActive.Checked = ((bool)dt.Rows[0]["Active"]) ? true : false;

                    hdProDelID.Value = e.CommandArgument.ToString();
                    hdInsert.Value   = "update";

                    mul.ActiveViewIndex = 1;
                }
                break;

            case "delete":
                if (dt.Rows.Count > 0)
                {
                    //Xóa hình ảnh project
                    if (System.IO.File.Exists(Server.MapPath("~/Images/" + dt.Rows[0]["vImage"])) == true)
                    {
                        System.IO.File.Delete(Server.MapPath("~/Images/" + dt.Rows[0]["vImage"]));
                    }

                    //Xóa dữ liệu trong csdl
                    _product.DeleteProductDetail(int.Parse(e.CommandArgument.ToString()));
                    Response.Redirect(Request.Url.ToString());
                }
                break;
            }
        }