Beispiel #1
0
 private void StergereClientToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (filled)
     {
         if (dataGridViewClienti.SelectedRows.Count > 0)
         {
             int        clientId  = -2;
             BLClients  blClients = new BLClients();
             BLAddress  bLAddress = new BLAddress();
             BLInvoices blInvoice = new BLInvoices();
             foreach (DataGridViewRow row in dataGridViewClienti.SelectedRows)
             {
                 clientId = Convert.ToInt32(row.Cells[0].Value.ToString());
             }
             DataTable facturiClient = blInvoice.GetInvoicesById(clientId);
             if (facturiClient.Rows.Count <= 0)
             {
                 DialogResult dialogResult = MessageBox.Show("Sigur doriti sa stergeti datele clientului?",
                                                             "Stergere Client", MessageBoxButtons.YesNo);
                 if (dialogResult == DialogResult.Yes)
                 {
                     bLAddress.DeleteAllAddresses(clientId, out string errorMessage);
                     blClients.DeleteClient(clientId, out string message);
                     MessageBox.Show(message, "Status", MessageBoxButtons.OK,
                                     MessageBoxIcon.Information);
                     initializareDataGridView();
                 }
                 else if (dialogResult == DialogResult.No)
                 {
                     this.Hide();
                 }
             }
             else
             {
                 MessageBox.Show("Nu se poate sterge clientul, deoarece are facturi inregistrate!", "Status", MessageBoxButtons.OK,
                                 MessageBoxIcon.Information);
                 initializareDataGridView();
             }
         }
         else
         {
             MessageBox.Show("Selectati un client pentru stergere!", "Status", MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("Lista clieti goala! Efectuati o cautare!", "Status", MessageBoxButtons.OK,
                         MessageBoxIcon.Information);
     }
 }
Beispiel #2
0
        public void initializareDataGridView()
        {
            int id = LoginForm.UserId;

            try
            {
                BLInvoices blFacturi = new BLInvoices();
                DataTable  dt        = new DataTable();
                dt = blFacturi.GetInvoices(id);
                dataGridViewFacturi.DataSource = dt;
                filled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            BLInvoices   bLInvoices    = new BLInvoices();
            InvoiceModel facturaCreata = new InvoiceModel();

            if (String.IsNullOrWhiteSpace(tbNumar.Text))
            {
                errorProvider1.SetError(tbNumar, "Camp obligatoriu!");
            }
            else if (cbAdrese.SelectedIndex == -1)
            {
                errorProvider1.SetError(cbAdrese, "Nu se poate adauga un client fara adrese pe factura!");
            }
            else
            {
                try
                {
                    string nrFactura = tbNumar.Text;
                    facturaCreata.InvoiceId               = factura.InvoiceId;
                    facturaCreata.InvoiceNumber           = nrFactura;
                    facturaCreata.InvoiceDate             = dateTimePickerFactura.Value;
                    facturaCreata.Observations            = tbObs.Text;
                    facturaCreata.adresa.PartnerId        = Convert.ToInt32(cbClient.SelectedValue);
                    facturaCreata.client.ClientId         = Convert.ToInt32(cbClient.SelectedValue);
                    facturaCreata.adresa.PartnerAddressId = Convert.ToInt32(cbAdrese.SelectedValue);

                    DialogResult dialogResult = MessageBox.Show("Sigur doriti sa modificati datele clientului?", "Adresa Client", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        bLInvoices.UpdateInvoice(facturaCreata, out bool status, out string message);
                        MessageBox.Show(message, "Status", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                        form.initializareDataGridView();
                        this.Close();
                    }
                    else if (dialogResult == DialogResult.No)
                    {
                        this.Hide();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Beispiel #4
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            BLInvoices   bLInvoices    = new BLInvoices();
            InvoiceModel facturaCreata = new InvoiceModel();

            if (String.IsNullOrWhiteSpace(tbNumar.Text))
            {
                errorProvider1.SetError(tbNumar, "Camp obligatoriu!");
            }
            else
            {
                string nrFactura = tbNumar.Text;
                facturaCreata.InvoiceNumber    = nrFactura;
                facturaCreata.InvoiceDate      = dateTimePickerFactura.Value;
                facturaCreata.Observations     = tbObs.Text;
                facturaCreata.user.UserId      = LoginForm.UserId;
                facturaCreata.adresa.PartnerId = Convert.ToInt32(cbClient.SelectedValue);
                facturaCreata.client.ClientId  = Convert.ToInt32(cbClient.SelectedValue);
                if (string.IsNullOrEmpty(cbAdrese.Text) || cbAdrese.SelectedIndex == -1)
                {
                    MessageBox.Show("Nu se poate face factura pentru un client fara adrese!", "Status", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
                else
                {
                    facturaCreata.adresa.PartnerAddressId = Convert.ToInt32(cbAdrese.SelectedValue);
                    bLInvoices.InsertInvoice(facturaCreata, out bool status, out string message);
                    MessageBox.Show(message, "Status", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    DialogResult dialogResult = MessageBox.Show("Doriti sa adaugati si detalii pentru factura introdusa?", "Detalii Factura", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        InvoiceDetailsForm form = new InvoiceDetailsForm(facturaCreata);
                        form.Show();
                    }
                    else if (dialogResult == DialogResult.No)
                    {
                        this.Hide();
                    }
                }
                InvoicesForm invoicesForm = new InvoicesForm();
                invoicesForm.initializareDataGridView();
            }
        }
Beispiel #5
0
 private void BtnDelete_Click(object sender, EventArgs e)
 {
     if (filled)
     {
         if (dataGridViewFacturi.SelectedRows.Count > 0)
         {
             int              invoiceId        = -2;
             BLInvoices       blInvoices       = new BLInvoices();
             BLInvoiceDetails bLInvoiceDetails = new BLInvoiceDetails();
             foreach (DataGridViewRow row in dataGridViewFacturi.SelectedRows)
             {
                 invoiceId = Convert.ToInt32(row.Cells[0].Value.ToString());
             }
             DialogResult dialogResult = MessageBox.Show("Sigur doriti sa stergeti datele facturii selectate?",
                                                         "Stergere Factura", MessageBoxButtons.YesNo);
             if (dialogResult == DialogResult.Yes)
             {
                 bLInvoiceDetails.DeleteAllDetails(invoiceId, out string errormessage);
                 blInvoices.DeleteInvoice(invoiceId, out string message);
                 MessageBox.Show(message, "Status", MessageBoxButtons.OK,
                                 MessageBoxIcon.Information);
                 initializareDataGridView();
             }
             else if (dialogResult == DialogResult.No)
             {
                 this.Hide();
             }
         }
         else
         {
             MessageBox.Show("Selectati o factura pentru stergere!", "Status", MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("Lista facturi goala! Efectuati o cautare!", "Status", MessageBoxButtons.OK,
                         MessageBoxIcon.Information);
     }
 }