private void btnDelete_Click(object sender, EventArgs e) { if (dgvInvoiceItems.SelectedCells.Count == 1) { if (InvoiceItems_DbCommunication.Exists("Invoice_ID", selectedItemID, "Item_ID", tbCode.Text) == 1) { InvoiceItems_DbCommunication.Delete("Invoice_ID", selectedItemID, "Item_ID", tbCode.Text); dgvInvoiceItems.DataSource = DbCommunication.DisplayData(SearchQuery); ClearTextBoxes(); } } }
private void btnEdit_Click(object sender, EventArgs e) { if (dgvInvoiceItems.SelectedCells.Count == 1) { InvoiceItems_DbCommunication.EditInvoiceItem(OutgoingInvoices.InvoiceNumber, tbCode.Text, decimal.Parse(tbQuantity.Text), decimal.Parse(tbPrice.Text)); MessageBox.Show ( "Артиклот е успешно променет!", "Промени", MessageBoxButtons.OK, MessageBoxIcon.Information ); dgvInvoiceItems.DataSource = DbCommunication.DisplayData(SearchQuery); } }
private void dgvInvoiceItems_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != -1 && e.RowIndex != dgvInvoiceItems.Rows.Count - 1) { selectedItemID = int.Parse(dgvInvoiceItems.Rows[e.RowIndex].Cells[0].Value.ToString()); string Code = dgvInvoiceItems.Rows[e.RowIndex].Cells[1].Value.ToString(); InvoiceItem i = InvoiceItems_DbCommunication.GetItem(Code); tbCode.Text = i.Code; tbName.Text = i.Name; tbTax.Text = i.Tax.ToString(); tbUnit.Text = i.Unit; tbPrice.Text = dgvInvoiceItems.Rows[e.RowIndex].Cells[4].Value.ToString(); tbQuantity.Text = dgvInvoiceItems.Rows[e.RowIndex].Cells[3].Value.ToString(); } else { ClearTextBoxes(); } }
private void btnSave_Click(object sender, EventArgs e) { decimal ItemTrueQuantity = Product_DbCommunication.GetProductQuantity(item.Code); if (item.Quantity <= ItemTrueQuantity) { if (!DuplicateItem(item.Code)) { InvoiceItems_DbCommunication.AddInvoiceItem(OutgoingInvoices.InvoiceNumber, item.Code, item.Quantity, item.Price); dgvInvoiceItems.DataSource = DbCommunication.DisplayData(SearchQuery); ClearTextBoxes(); Product_DbCommunication.DecreaseQuantity(ItemTrueQuantity - item.Quantity, item.Code); } else { MessageBox.Show ( "Ставката веќе постои.", "Грешка", MessageBoxButtons.OK, MessageBoxIcon.Information ); } } else { MessageBox.Show ( "Нема доволно залиха.", "Грешка", MessageBoxButtons.OK, MessageBoxIcon.Error ); } }