Example #1
0
        /// <summary>
        /// Thêm Hóa đơn nhập chi tiết
        /// </summary>
        /// <param name="receiptId">Mã hóa đơn nhập</param>
        /// <param name="productId">Mã mặt hàng</param>
        /// <param name="quantity">Số lượng nhập</param>
        /// <param name="price">Thành tiền</param>
        /// <param name="total"></param>
        private void InsertReceiptDetails(string receiptId, string productId, int quantity, int price, int total)
        {
            var receiptDetail = new ReceiptDetail()
            {
                ReceiptID = receiptId,
                ProductID = productId,
                Quantity = quantity,
                Price = price,
                Active = true,
                Total = total,
            };

            try
            {
                _receiptDetailService.Add(receiptDetail);
            }
            catch (SqlException ex)
            {
                MessageBoxHelper.ShowMessageBoxError(ex.Message);
            }
            catch (Exception ex)
            {
                MessageBoxHelper.ShowMessageBoxError(ex.Message);
            }
        }
Example #2
0
 /// <summary>
 /// Cập nhật thông tin
 /// </summary>
 /// <param name="receiptDetail"></param>
 public void Update(ReceiptDetail receiptDetail)
 {
     _context.ReceiptDetails.Attach(receiptDetail);
     _context.Entry(receiptDetail).State = EntityState.Modified;
     SaveChanges();
 }
Example #3
0
        /// <summary>
        /// Thêm Hóa đơn nhập chi tiết
        /// </summary>
        /// <param name="receiptId">Mã hóa đơn nhập</param>
        /// <param name="productId">Mã mặt hàng</param>
        /// <param name="quantityReceipt">Số lượng nhập</param>
        /// <param name="price">Thành tiền</param>
        /// <param name="total"></param>
        private void InsertReceiptDetails(string receiptId, string productId, int quantityReceipt, int price, int total)
        {
            var receiptDetail = new ReceiptDetail()
            {
                ReceiptID = receiptId,
                ProductID = productId,
                Quantity = quantityReceipt,
                Price = price,
                Active = true,
                Total = total,
            };

            try
            {
                _receiptDetailService.Add(receiptDetail);
            }
            catch (SqlException ex)
            {
                messagebox.InnerHtml = string.Format("<div class='alert alert-danger'>" +
                                           "<strong>Lỗi!</strong> {0} .</div>", ex.Message);
            }
            catch (Exception ex)
            {
                messagebox.InnerHtml = string.Format("<div class='alert alert-danger'>" +
                                           "<strong>Lỗi!</strong> {0} .</div>", ex.Message);
            }
        }
Example #4
0
 /// <summary>
 /// Thêm mới
 /// </summary>
 /// <param name="receiptDetail"></param>
 /// <returns></returns>
 public void Add(ReceiptDetail receiptDetail)
 {
     _context.ReceiptDetails.Add(receiptDetail);
     SaveChanges();
 }