private void btnAddInvoice_Click(object sender, EventArgs e)
        {
            if (!CheckInvoiceInputs())
            {
                return;
            }

            InvoiceHeader invoiceHeader = new InvoiceHeader()
            {
                InvoieceID         = _invoiceID,
                invoicedetail      = _invoiceDetail,
                InvoiceDateTime    = DateTime.Now,
                DeliveryNoteNumber = Convert.ToInt32(txtDeliveryNumber.Text),
                CustomerID         = _selectedCustomer.CustomerID,
                PaymentDateTime    = dtpPaymentDate.Value,
                InvoiceAmount      = _invoiceDetail.Select(f => f.TotalAmount).Sum()
            };

            DbContextTransaction tran = _db.Database.BeginTransaction();

            try
            {
                _db.InvoiceHeaders.Add(invoiceHeader);
                _db.SaveChanges();
                ClearFaturaInputs();
                tran.Commit();
            }
            catch (Exception)
            {
                tran.Rollback();
                MessageBox.Show("Beklenmeyen bir hata meydana geldi");
            }
        }
예제 #2
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1 || dataGridView1.CurrentRow == null)
            {
                return;
            }

            InvoiceHeader faturaMaster = (InvoiceHeader)dataGridView1.CurrentRow.DataBoundItem;

            dataGridView1.DataSource = faturaMaster.invoicedetail.ToList();
        }