private void btnPlacements_Click(object sender, EventArgs e)
        {
            MnjEntradaContable mnjEntradaContable = MnjEntradaContable.getInstance();

            mnjEntradaContable.ShowDialog(this);
            mnjEntradaContable.Focus();
        }
        public static MnjEntradaContable getInstance()
        {
            if (instance == null)
            {
                instance = new MnjEntradaContable();
            }

            return(instance);
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool       created   = false;
            placements placement = new placements()
            {
                description   = txtDescription.Text,
                auxiliary_id  = 1,
                date          = DateTime.Now,
                currency_type = ((currencies_types)cbCurrency.SelectedItem).id,
                exchange_rate = ((currencies_types)cbCurrency.SelectedItem).exchange_rate,
                state         = "R"
            };

            String errors = validate(placement);

            if (errors.Length > 0)
            {
                MessageBox.Show(
                    errors,
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );
                return;
            }

            using (var transaction = entities.Database.BeginTransaction()) {
                try
                {
                    entities.placements.Add(placement);

                    foreach (var el in movements)
                    {
                        el.placement_id = placement.id;
                        entities.placements_movements.Add(el);
                    }
                    entities.SaveChanges();

                    MnjEntradaContable.getInstance().mayorize(placement);

                    transaction.Commit();
                    created = true;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    transaction.Rollback();
                }
            };

            if (created)
            {
                MessageBox.Show(
                    "Asiento registrado con éxito",
                    "Información",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                    );

                MnjEntradaContable.getInstance().loadPlacements("");

                this.Close();
            }
            else
            {
                MessageBox.Show(
                    "El asiento no pudo ser registrado",
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );
            }
        }
 private void MnjEntradaContable_FormClosed(object sender, FormClosedEventArgs e)
 {
     instance = null;
 }