protected void BT_SubmitProduct_Click(object sender, EventArgs e) { int CategoryID = Convert.ToInt32(DDL_TheLoai.SelectedValue.ToString()); if (CategoryID == 0) { WebMsgBox.Show("Bạn phải chọn thể loại sản phẩm"); LBL_Cate.Visible = true; DDL_TheLoai.SelectedValue = "0"; } else { LBL_Cate.Visible = false; string NameProduct = HtmlRemoval.StripTagsRegex(TB_TenSanPham.Text.Trim()); string ProductCode = HtmlRemoval.StripTagsRegex(TB_MaSanPham.Text.Trim()); double GiaGoc; if (TB_GiaGoc.Text.Trim() == "") { GiaGoc = 0; } else { GiaGoc = Convert.ToDouble(TB_GiaGoc.Text.Trim()); } double GiaBan; if (TB_GiaBan.Text.Trim() == "") { GiaBan = 0; } else { GiaBan = Convert.ToDouble(TB_GiaBan.Text.Trim()); } int GiamGia; if (TB_GiamGia.Text.Trim() == "") { GiamGia = 0; } else { GiamGia = Convert.ToInt32(TB_GiamGia.Text.Trim()); } int QuantityInProduct; if (TB_SoLuongCo.Text.Trim() == "") { QuantityInProduct = 0; } else { QuantityInProduct = Convert.ToInt32(TB_SoLuongCo.Text.Trim()); } int QuantitySalesProduct = 0; if (TB_SoLuongBan.Text.Trim() == "") { QuantitySalesProduct = 0; } else { QuantitySalesProduct = Convert.ToInt32(TB_SoLuongBan.Text.Trim()); } string PartImage = TB_PartImage.Value.Trim(); string DescriptionProduct = TB_MoTa.Text.Trim(); string Details = FCKeditor.Value.Trim(); int Type = Convert.ToInt32(DDL_Type.SelectedValue.ToString()); if (Convert.ToInt32(HD_ID_Product.Value) != 0) { if (ToolsAdmin.Update_Product(Convert.ToInt32(HD_ID_Product.Value), CategoryID, NameProduct, ProductCode, GiaGoc, GiaBan, GiamGia, QuantityInProduct, QuantitySalesProduct, PartImage, DescriptionProduct, Details, Type)) { HD_Select_CategoryID.Value = DDL_SearchCategory.SelectedValue; if (Convert.ToInt32(HD_Select_CategoryID.Value) == 0) { set_Text_Product(); DIV_AddEditProduct.Visible = false; Load_Grid_Products(); } else { set_Text_Product(); DIV_AddEditProduct.Visible = false; Load_SearchProduct_ByCategory(); } } else { WebMsgBox.Show("Error Update"); } } else if (Convert.ToInt32(HD_ID_Product.Value) == 0) { if (ToolsAdmin.Insert_Product(Convert.ToInt32(HD_ID_Product.Value), CategoryID, NameProduct, ProductCode, GiaGoc, GiaBan, GiamGia, QuantityInProduct, QuantitySalesProduct, PartImage, DescriptionProduct, Details, Type)) { HD_Select_CategoryID.Value = DDL_SearchCategory.SelectedValue; if (Convert.ToInt32(HD_Select_CategoryID.Value) == 0) { set_Text_Product(); DIV_AddEditProduct.Visible = false; Load_Grid_Products(); } else { set_Text_Product(); DIV_AddEditProduct.Visible = false; Load_SearchProduct_ByCategory(); } } else { WebMsgBox.Show("Error Insert"); } } //TB_SearchProduct.Text = ""; set_Hidden_DIVProduct(); } }