public EditInvoiceForm(InvoiceModel factura, InvoicesForm form)
 {
     InitializeComponent();
     this.factura = factura;
     this.form    = form;
     InitForm(this.factura);
 }
Exemple #2
0
        private void BtnFacturi_Click(object sender, EventArgs e)
        {
            LoginForm    login   = new LoginForm();
            InvoicesForm facturi = new InvoicesForm();

            facturi.Show();
            this.Hide();
        }
Exemple #3
0
        private void BtnInvoices_Click(object sender, EventArgs e)
        {
            InvoicesForm invoicesMenu = new InvoicesForm();

            invoicesMenu.UserIdForInvoice = UserId;
            invoicesMenu.Show();
            this.Hide();
            invoicesMenu.FormClosed += FormClosed;
        }
        private void BtnAddInvoice_Click(object sender, EventArgs e)
        {
            InvoiceId += 1;
            if (String.IsNullOrWhiteSpace(txtBoxInvoiceNumber.Text))
            {
                MessageBox.Show("Numarul facturii nu este completat!", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(comboBoxClient.Text))
            {
                MessageBox.Show("Nu este ales nciun partenere!", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(comboBoxClientAddress.Text))
            {
                MessageBox.Show("Nu este ales nciun partenere!", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (dateInvoiceDate.Text.Length == 0)
            {
                MessageBox.Show("Nu ai ales data!", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            DATotCeFolosescLaInvoice invoice = new DATotCeFolosescLaInvoice();
            string   numarfactura            = txtBoxInvoiceNumber.Text;
            DateTime dataFactura             = dateInvoiceDate.Value.Date;
            int      idpar    = ((ClientModel)comboBoxClient.SelectedItem).ClientId;
            int      idadresa = ((ClientAddressModel)comboBoxClientAddress.SelectedItem).ClientAddressId;
            string   obser    = txtBoxObservations.Text;


            List <InvoiceDetailModel> invoiceDetailModels = new List <InvoiceDetailModel>();

            for (int i = 0; i < dGVInvoiceDetails.RowCount; i++)
            {
                InvoiceDetailModel invoicedetail = new InvoiceDetailModel();
                invoicedetail = (InvoiceDetailModel)dGVInvoiceDetails.Rows[i].DataBoundItem;
                invoiceDetailModels.Add(invoicedetail);
            }

            bool status = invoice.insertInvoice(numarfactura, dataFactura, idpar, idadresa, UserId, obser, invoiceDetailModels);

            if (status == true)
            {
                MessageBox.Show("Factura adaugata!", "Wew", MessageBoxButtons.OK, MessageBoxIcon.Information);
                InvoicesForm invoicesForm = new InvoicesForm();
                invoicesForm.Show();
                this.Hide();
                invoicesForm.FormClosed += invoice_from_formClosed;
            }
            else
            {
                MessageBox.Show("Factura neadaugata!", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #5
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();
            }
        }