Пример #1
0
 /// <summary>
 /// Cập nhật thông tin
 /// </summary>
 /// <param name="orderImport"></param>
 public void Update(OrderImport orderImport)
 {
     _context.OrderImports.Attach(orderImport);
     _context.Entry(orderImport).State = EntityState.Modified;
     SaveChanges();
 }
Пример #2
0
        /// <summary>
        /// Lưu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(gridLookUpEditSuppliers.Text))
            {
                gridLookUpEditSuppliers.Properties.Appearance.BorderColor = System.Drawing.Color.Red;
                XtraMessageBox.Show("Vui lòng chọn Nhà cung cấp!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                gridLookUpEditSuppliers.Focus();
            }
            else if (string.IsNullOrEmpty(gridLookUpEditEmployee.Text))
            {
                gridLookUpEditEmployee.Properties.Appearance.BorderColor = System.Drawing.Color.Red;
                XtraMessageBox.Show("Vui lòng chọn Nhân viên!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                gridLookUpEditEmployee.Focus();
            }
            else
            {
                var orderImport = new OrderImport()
                {
                    OrderImportID = txtOrderImportID.Text,
                    SupplierID = gridLookUpEditSuppliers.EditValue.ToString(),
                    EmployeeID =  _employeeId,
                    ImportDate = dateEditImportDate.DateTime,
                    TotalMoney = Convert.ToInt32(_total),
                    //Price = Convert.ToInt32(_price),
                    IsActive = true,
                };

                try
                {
                    _orderImportService.Add(orderImport);
                    foreach (Cart cart in _order.Carts)
                    {
                        InsertOrderImportDetail(txtOrderImportID.Text, cart.ProductId, cart.Quantity, cart.Price, cart.Total);
                        _inventoryService.InsertOrUpdateInventoryImport(cart.ProductId, cart.Quantity, txtOrderImportID.Text);
                    }
                    if (_order.Carts.Count > 0)
                    {
                        _order.Carts.Clear();
                    }
                    
                    
                    XtraMessageBox.Show("Nhập hàng thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    gridControlStockImport.DataSource = null;
                    ResetProductControls();
                    ResetSupplierControls();
                    EnabledButtonSaveAndPrint(false);
                    // Tạo tiếp ID
                    txtOrderImportID.Text = _orderImportService.NextId();
                    gridLookUpEditEmployee.EditValue = _employeeId;

                }
                catch (SqlException ex)
                {
                    XtraMessageBox.Show(string.Format("Lỗi! \n {0}", ex.Message), "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show(string.Format("Lỗi! \n {0}", ex.Message), "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #3
0
 /// <summary>
 /// Thêm mới
 /// </summary>
 /// <param name="orderImport"></param>
 /// <returns></returns>
 public void Add(OrderImport orderImport)
 {
     _context.OrderImports.Add(orderImport);
     SaveChanges();
 }