public bool Delete(product pProduct)
 {
     try
     {
         db.products.DeleteOnSubmit(pProduct);
         db.SubmitChanges();
         return true;
     }
     catch(Exception ex)
     {
         throw ex;
     }
 }
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (txtTenSanPham.Text == string.Empty)
            {
                CheckLoi(lbTenSanPham.Text);
                txtTenSanPham.Focus();
            }
            if (txtDonViTinh.Text == string.Empty)
            {
                CheckLoi(lbDonViTinh.Text);
                txtDonViTinh.Focus();
            }
            if(txtBaoHanh.Text == string.Empty)
            {
                CheckLoi(lbBaoHanh.Text);
                txtBaoHanh.Focus();
            }
            if(txtDonGia.Text == string.Empty)
            {
                CheckLoi(lbDonGia.Text);
                txtDonGia.Focus();
            }
            if (lkDanhMucSP.EditValue == string.Empty)
            {
                CheckLoi(lbDanhMucSP.Text);
                return;
            }

            product p = new product();
            p.id = txtMaSanPham.Text;
            p.name = txtTenSanPham.Text;
            p.describe = txtMoTa.Text;
            p.created = DateTime.Now;
            p.warranty = int.Parse(txtBaoHanh.Text);
            p.quantity = int.Parse(numSoLuong.Value.ToString());
            p.unit = txtDonViTinh.Text;
            p.price = int.Parse(txtDonGia.Text);
            category cat = (category)lkDanhMucSP.GetSelectedDataRow();
            cat.products.Add(p);

            if (busHangHoa.Save())
            {
                this.Close();
                DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            else
            {
                XtraMessageBox.Show("Thêm sản phẩm bị lỗi", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                DialogResult = System.Windows.Forms.DialogResult.Cancel;
            }
        }
        private void btn_Save(object sender, RoutedEventArgs e)
        {
            DAL.product r = new DAL.product();
            r.name           = tb_name.Text;
            r.saleprice      = Convert.ToInt32(tb_saleprice.Text);
            r.purchaseprice  = Convert.ToInt32(tb_purchaseprice.Text);
            r.discount       = Convert.ToInt32(tb_discount.Text);
            r.carrycost      = Convert.ToInt32(tb_carrycost.Text);
            r.barcode        = tb_barcode.Text;
            r.quantity       = Convert.ToInt32(tb_quantity.Text);
            r.type           = (string)cb_Type.SelectedValue;
            r.saleactive     = cbx_SaleActive.IsChecked.Value;
            r.purchaseactive = cbx_PurchaseActive.IsChecked.Value;
            RMSDBEntities db = DBContext.getInstance();

            db.product.Add(r);
            db.SaveChanges();
            Close();
            new ProductAdd().Show();
        }
 public bool Update(product pProduct)
 {
     try
     {
         pProduct.modified = DateTime.Now;
         db.SubmitChanges();
         return true;
     }
     catch(Exception ex)
     {
         throw ex;
     }
 }
 public bool KiemTraTonTai(receipt pnh, product sp)
 {
     try
     {
         var p = from d in pnh.receipt_details
                 where d.product_id.Equals(sp.id)
                 select d;
         return p.Count() == 1;
     }
     catch(Exception ex)
     {
         throw ex;
     }
 }
 public bool KiemTraTonTai(bill bl, product sp)
 {
     try
     {
         var p = from b in bl.bill_details
                 where b.product_id.Equals(sp.id)
                 select b;
         return p.Count() == 1;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 partial void Deleteproduct(product instance);
 partial void Updateproduct(product instance);
 partial void Insertproduct(product instance);
		private void detach_products(product entity)
		{
			this.SendPropertyChanging();
			entity.category = null;
		}
		private void attach_products(product entity)
		{
			this.SendPropertyChanging();
			entity.category = this;
		}
Exemplo n.º 12
0
 public void Update(product entity)
 {
     _repository.Update(entity);
 }
Exemplo n.º 13
0
 public void Insert(product entity)
 {
     _repository.Insert(entity);
 }
Exemplo n.º 14
0
 public void Delete(product entity)
 {
     _repository.Delete(entity);
 }