public virtual void Remove(int id)
 {
     try
     {
         PRODUCT_DETAIL_MATERIAL cus = this.GetById(id);
         this.Remove(cus);
     }
     catch //(Exception e)
     {
         //throw new Exception(e.Message);
     }
 }
 public virtual void Remove(PRODUCT_DETAIL_MATERIAL cus)
 {
     try
     {
         db.PRODUCT_DETAIL_MATERIALs.DeleteOnSubmit(cus);
         db.SubmitChanges();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
 public virtual void Create(PRODUCT_DETAIL_MATERIAL cus)
 {
     try
     {
         this.db.PRODUCT_DETAIL_MATERIALs.InsertOnSubmit(cus);
         db.SubmitChanges();
     }
     catch// (Exception e)
     {
         //throw new Exception(e.Message);
     }
 }
 public virtual int Delete(int id)
 {
     try
     {
         PRODUCT_DETAIL_MATERIAL cus = this.GetById(id);
         return(this.Delete(cus));
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
 public virtual void Update(PRODUCT_DETAIL_MATERIAL cus)
 {
     try
     {
         PRODUCT_DETAIL_MATERIAL cusOld = this.GetById(cus.ID);
         cusOld = cus;
         db.SubmitChanges();
     }
     catch //(Exception e)
     {
         //throw new Exception(e.Message);
     }
 }
 public virtual int Delete(PRODUCT_DETAIL_MATERIAL cus)
 {
     try
     {
         //user.IsDelete = true;
         db.SubmitChanges();
         return(0);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Exemplo n.º 7
0
        private void Save()
        {
            try
            {
                int productDetailId      = Utils.CIntDef(ddlProductDetail.SelectedValue);
                int productDetailSizeId  = Utils.CIntDef(ddlProductDetailSize.SelectedValue);
                int materialId           = Utils.CIntDef(ddlMaterial.SelectedValue);
                var ProductDetailMateria = _ProductDetailMaterialRepo.GetByProductDetailIdAndMaterialId(productDetailId, productDetailSizeId, materialId);
                if (ProductDetailMateria != null)
                {
                    ProductDetailMateria.PRODUCT_DETAIL_ID      = productDetailId;
                    ProductDetailMateria.PRODUCT_DETAIL_SIZE_ID = productDetailSizeId;
                    ProductDetailMateria.MATERIAL_ID            = materialId;
                    ProductDetailMateria.QUANTITY = Utils.CDecDef(txtQuantity.Value);

                    _ProductDetailMaterialRepo.Update(ProductDetailMateria);
                }
                else
                {
                    ProductDetailMateria = new PRODUCT_DETAIL_MATERIAL();
                    ProductDetailMateria.PRODUCT_DETAIL_ID      = productDetailId;
                    ProductDetailMateria.PRODUCT_DETAIL_SIZE_ID = productDetailSizeId;
                    ProductDetailMateria.MATERIAL_ID            = materialId;
                    ProductDetailMateria.QUANTITY = Utils.CDecDef(txtQuantity.Value);

                    _ProductDetailMaterialRepo.Create(ProductDetailMateria);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                Response.Redirect("nguyen-lieu-can-cho-san-pham.aspx?id=" + ddlProductDetail.SelectedValue);
            }
        }