private void btnNew_Click(object sender, EventArgs e) { if (tbCustomer.Text != "") { InvoiceNumber = Invoice_DbCommunication.GetInvoiceNumber(); InvoiceCounter++; Invoice_DbCommunication.AddInvoice(Customer_DbCommunication.GetCustomerDBID(CustomerPick.selectecCustomerInfo.Name), InvoiceCounter, mtbDate.Text, tbValuta.Text, cbDocType.SelectedItem.ToString(), tbDescription.Text); dgvInvoices.DataSource = DbCommunication.DisplayData(SearchQuery); ResetBoxes(); SetInvoiceNumberTextBox(); } else { MessageBox.Show ( "Одберете купувач (F1).", "Грешка", MessageBoxButtons.OK, MessageBoxIcon.Error ); } }
private void Search() { if (tbSearch.Text != "") { if (rbtnName.Checked) { dgvCustomers.DataSource = Customer_DbCommunication.FilterCustomers("Назив", tbSearch.Text); } else if (rbtnCity.Checked) { dgvCustomers.DataSource = Customer_DbCommunication.FilterCustomers("Град", tbSearch.Text); } else if (rbtnTaxNum.Checked) { dgvCustomers.DataSource = Customer_DbCommunication.FilterCustomers("Даночен_број", tbSearch.Text); } else { MessageBox.Show ( "Одберете начин на филтрирање!", "Грешка", MessageBoxButtons.OK, MessageBoxIcon.Error ); } } }
private void btnSave_Click(object sender, EventArgs e) { if (tbTaxNum.Text == "" || tbAddress.Text == "" || tbCity.Text == "" || tbName.Text == "") { errorProviderTaxNum.SetError(tbTaxNum, "Задолжително внесете даночен број"); errorProviderAddress.SetError(tbAddress, "Задолжително внесете адреса и град"); errorProviderName.SetError(tbName, "Задолжително внесете назив на коминтент"); } else { errorProviderTaxNum.SetError(tbTaxNum, null); if (DbCommunication.Exists("Customers", "Даночен_број", tbTaxNum.Text) < 1) { Customer_DbCommunication.AddCustomer ( tbName.Text, tbTaxNum.Text, tbEMBS.Text, tbBankNum1.Text, tbBankNum2.Text, cbBank.GetItemText(cbBank.SelectedItem), tbAddress.Text, tbCity.Text, tbZipCode.Text, tbContactPerson1.Text, tbContactPerson2.Text, tbPhone1.Text, tbPhone2.Text, tbEmail.Text, tbDescription.Text ); UpdateTable(); MessageBox.Show ( "Коминтентот е успешно додаден!", "Сними", MessageBoxButtons.OK, MessageBoxIcon.Information ); } else { MessageBox.Show ( "Тој коминтент веќе постои!", "Грешка", MessageBoxButtons.OK, MessageBoxIcon.Error ); } } }
private void btnEdit_Click(object sender, EventArgs e) { if (dgvCustomers.SelectedCells.Count == 1) { Customer_DbCommunication.EditCustomer(Customer.TaxNumber, tbName.Text, tbTaxNum.Text, tbEMBS.Text, tbBankNum1.Text, tbBankNum2.Text, cbBank.SelectedItem.ToString(), tbAddress.Text, tbCity.Text, tbZipCode.Text, tbContactPerson1.Text, tbContactPerson2.Text, tbPhone1.Text, tbPhone2.Text, tbEmail.Text, tbDescription.Text); Customer.TaxNumber = tbTaxNum.Text; MessageBox.Show ( "Коминтентот е успешно променет!", "Промени", MessageBoxButtons.OK, MessageBoxIcon.Information ); UpdateTable(); } }
private void UpdateTable() { dgvCustomers.DataSource = Customer_DbCommunication.DisplayData(SearchQuery); }