Beispiel #1
0
        private void btnGrabar_Click(object sender, EventArgs e)
        {
            try
            {
                using (var uow = UnitOfWorkProvider.BeginUnitOfWork())
                {
                    if (_comercioId > 0)
                    {
                        ComerciosService.ActualizarComercio(_comercioId, txtRazonSocial.Text, txtDireccion.Text);
                    }
                    else
                    {
                        ComerciosService.AgregarComercio(txtRazonSocial.Text, txtCuit.Text, txtDireccion.Text);
                    }

                    uow.Commit();
                }

                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #2
0
        private void PrepararComercioParaEdicion()
        {
            var comercio = ComerciosService.TraerComercioPorId(_comercioId);

            txtCuit.Text        = comercio.CUIT;
            txtCuit.Enabled     = false;
            txtDireccion.Text   = comercio.Direccion;
            txtRazonSocial.Text = comercio.RazonSocial;
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (ComercioSeleccionado == -1)
            {
                MessageBox.Show("Seleccione un Comercio a eliminar", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                return;
            }
            var comercio = gridComercios.CurrentRow.Cells[1].Value;
            var result   = MessageBox.Show("Confirma eliminar el comercio " + comercio + "?", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                           MessageBoxDefaultButton.Button2);

            if (result == DialogResult.Yes)
            {
                using (var uow = UnitOfWorkProvider.BeginUnitOfWork())
                {
                    ComerciosService.EliminarComercio(ComercioSeleccionado);
                    uow.Commit();
                }
                CargarComercios();
            }
        }