Exemplo n.º 1
0
 private void BtnDetails_Click(object sender, EventArgs e)
 {
     if (filled)
     {
         if (dataGridViewFacturi.SelectedRows.Count > 0)
         {
             InvoiceModel factura = new InvoiceModel();
             foreach (DataGridViewRow row in dataGridViewFacturi.SelectedRows)
             {
                 factura.InvoiceId               = Convert.ToInt32(row.Cells[0].Value.ToString());
                 factura.InvoiceNumber           = row.Cells[1].Value.ToString();
                 factura.InvoiceDate             = Convert.ToDateTime(row.Cells[2].Value.ToString());
                 factura.client.ClientId         = Convert.ToInt32(row.Cells[3].Value.ToString());
                 factura.adresa.PartnerAddressId = Convert.ToInt32(row.Cells[4].Value.ToString());
                 factura.user.UserId             = Convert.ToInt32(row.Cells[5].Value.ToString());
                 factura.Observations            = row.Cells[6].Value.ToString();
                 factura.client.Nume             = row.Cells[7].Value.ToString();
             }
             InvoiceDetailsForm form = new InvoiceDetailsForm(factura);
             form.Show();
         }
         else
         {
             MessageBox.Show("Selectati o factura pentru a putea vedea detalii!", "Status", MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("Lista facturi goala! Efectuati o cautare!", "Status", MessageBoxButtons.OK,
                         MessageBoxIcon.Information);
     }
 }
Exemplo n.º 2
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();
            }
        }