Example #1
0
        private void facturasToolStripMenuItem_Click_1(object sender, System.EventArgs e)
        {
            var indexFacturas = new IndexFacturasForm();

            this.Hide();
            indexFacturas.Show();
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var errores = this.validarCamposCreateOrEdit();

            if (errores.Count == 0)
            {
                try
                {
                    Factura factura = new Factura();

                    factura.Nro              = decimal.Parse(txtNroFactura.Text);
                    factura.EmpresaCuit      = ((ComboBoxItemStringValue)cboEmpresa.SelectedItem).Value;
                    factura.ClienteDNI       = decimal.Parse(txtDNI.Text);
                    factura.Fecha            = txtFecha.Value;
                    factura.Estado           = 0;
                    factura.FechaVencimiento = txtFechaVencimiento.Value;

                    int i = 1;

                    foreach (ItemFactura itemFactura in listBox1.Items)
                    {
                        itemFactura.NroFactura = decimal.Parse(txtNroFactura.Text);
                        itemFactura.NroItem    = i;

                        listaItems.Add(itemFactura);

                        i++;
                    }

                    FacturasRepository.EditarFactura(factura, listaItems, nroFacturaOriginal);

                    MessageBox.Show("La factura fue modificada correctamente");

                    var index = new IndexFacturasForm();
                    this.Hide();
                    index.Show();
                }
                catch (SqlException sqlexc)
                {
                    //Violacion de primary key
                    if (sqlexc.Number == 547)
                    {
                        MessageBox.Show("No hay ningun cliente registrado con ese DNI");
                    }

                    conn.Close();
                }
            }
            else
            {
                string errorMessage = string.Join("\n", errores.ToArray());
                MessageBox.Show(errorMessage);
            }

            listaItems.Clear();
        }