Beispiel #1
0
        private void productoBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (!ValidateFields())
            {
                return;
            }

            productoBindingSource.EndEdit();

            var selectedProduct = commB.SetEntity <Producto>(productoBindingSource.Current);

            if (selectedProduct != null)
            {
                var selectedProveedor = commB.SetEntity <Proveedore>(cboProveedores.SelectedItem);
                var selectedCategory  = commB.SetEntity <Categoria>(cboCategorias.SelectedItem);
                var selectedUnidad    = commB.SetEntity <UnidadesMedida>(cboUnidadesMedidas.SelectedItem);

                selectedProduct.IdProveedor    = selectedProveedor.IdProveedor;
                selectedProduct.IdCategoria    = selectedCategory.IdCategoria;
                selectedProduct.IdUnidadMedida = selectedCategory.IdCategoria;
                //selectedProduct.PrecioVenta = selectedProduct.PrecioUnitario * (1 + selectedProduct.Utilidad / 100);
                commB.UpdateEntity <Producto>(selectedProduct);
            }
            productoBindingSource.ResetBindings(true);
        }
Beispiel #2
0
 private void estudianteBindingNavigatorSaveItem_Click(object sender, EventArgs e)
 {
     try
     {
         cboCantones.SelectedValue   = cboListaCantones.SelectedValue;
         cboProvincias.SelectedValue = cboListaProvincias.SelectedValue;
         cboDistritos.SelectedValue  = cboListaDistritos.SelectedValue;
         if (!ValidateFields())
         {
             return;
         }
         estudianteBindingSource.EndEdit();
         var selectedEstudiante = commB.SetEntity <Estudiante>(estudianteBindingSource.Current);
         if (selectedEstudiante != null)
         {
             commB.UpdateEntity <Estudiante>(selectedEstudiante);
         }
         estudianteBindingSource.ResetBindings(true);
         commB.SaveBitacora(this.Name + " Guardado estudiante: " + selectedEstudiante.IdEstudiante, false, Tools.UserCredentials.UserId);
         lblInfoMessage.Text = "Estudiante guardado satisfactoriamente";
     }
     catch (Exception ex)
     {
         CursosBusiness.BusinessHelpers.General.LogInfo(ex, "Control", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
     }
 }
Beispiel #3
0
        private void clienteBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (!ValidateFields())
            {
                return;
            }
            clienteBindingSource.EndEdit();
            var selectedCliente = commB.SetEntity <Cliente>(clienteBindingSource.Current);

            if (selectedCliente != null)
            {
                commB.UpdateEntity <Cliente>(selectedCliente);
            }
            clienteBindingSource.ResetBindings(true);
        }
Beispiel #4
0
        private void parametrosVentaBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (!ValidateFields())
            {
                return;
            }
            parametrosVentaBindingSource.EndEdit();
            var selectedParam = commB.SetEntity <ParametrosVenta>(parametrosVentaBindingSource.Current);

            if (selectedParam != null)
            {
                commB.UpdateEntity <ParametrosVenta>(selectedParam);
            }
            parametrosVentaBindingSource.ResetBindings(true);
        }
        private void unidadesMedidaBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (!ValidateFields())
            {
                return;
            }
            unidadesMedidaBindingSource.EndEdit();
            var selectedUni = commB.SetEntity <UnidadesMedidaForm>(unidadesMedidaBindingSource.Current);

            if (selectedUni != null)
            {
                commB.UpdateEntity <UnidadesMedidaForm>(selectedUni);
            }
            unidadesMedidaBindingSource.ResetBindings(true);
        }
        private void tarjetasBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (!ValidateFields())
            {
                return;
            }
            tarjetasBindingSource.EndEdit();
            var selectedTarjeta = commB.SetEntity <ControlEntity.Tarjeta>(tarjetasBindingSource.Current);

            if (selectedTarjeta != null)
            {
                commB.UpdateEntity <Tarjeta>(selectedTarjeta);
            }
            tarjetasBindingSource.ResetBindings(true);
        }
Beispiel #7
0
        private void frecuenciasPagoesBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (!ValidateFields())
            {
                return;
            }

            frecuenciasPagoesBindingSource.EndEdit();

            var selectedFrec = commB.SetEntity <ControlEntity.FrecuenciasPago>(frecuenciasPagoesBindingSource.Current);

            if (selectedFrec != null)
            {
                commB.UpdateEntity <ControlEntity.FrecuenciasPago>(selectedFrec);
            }
            frecuenciasPagoesBindingSource.ResetBindings(true);
        }
Beispiel #8
0
        private void usuarioBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (!ValidateFields())
            {
                return;
            }

            usuarioBindingSource.EndEdit();

            var selectedUser = commB.SetEntity <Usuario>(usuarioBindingSource.Current);

            if (selectedUser != null)
            {
                commB.UpdateEntity <Usuario>(selectedUser);
            }
            usuarioBindingSource.ResetBindings(true);
        }
        private void bancosBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (!ValidateFields())
            {
                return;
            }

            bancosBindingSource.EndEdit();

            var selectedBanco = commB.SetEntity <ControlEntity.Banco>(bancosBindingSource.Current);

            if (selectedBanco != null)
            {
                commB.UpdateEntity <ControlEntity.Banco>(selectedBanco);
            }
            bancosBindingSource.ResetBindings(true);
        }
Beispiel #10
0
        private void proveedorBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (!ValidateFields())
            {
                return;
            }

            proveedorBindingSource.EndEdit();

            var selectedProveedor = commB.SetEntity <Proveedore>(proveedorBindingSource.Current);

            if (selectedProveedor != null)
            {
                commB.UpdateEntity <Proveedore>(selectedProveedor);
            }
            proveedorBindingSource.ResetBindings(true);
        }
        private string GetConsecutivo(bool updateConsecutivo)
        {
            var Consecutivo = "";

            if (UsaConsecutivoGlobal)
            {
                // traer el consecutivo global de la tabla de parametros ventas
                var ventasParams = ventasB.GetVentasParams();
                if (ventasParams != null)
                {
                    Consecutivo = ventasParams.ConsecutivoGlobalFacturas.ToString();
                }
                else
                {
                    MessageBox.Show("No está definido el consecutivo global de facturación");
                    DisableButtons();
                }
                if (updateConsecutivo)
                {
                    ventasB.UpdateConsecutivoGlobal();
                }
            }
            else
            {
                // traer el consecutivo de la caja
                var cajaParams = ventasB.GetCajaById(curCaja);
                if (cajaParams != null)
                {
                    Consecutivo = cajaParams.Consecutivo.ToString();
                }
                else
                {
                    MessageBox.Show("No esta definido el consecutivo de facturas en cajas");
                    DisableButtons();
                }
                if (updateConsecutivo)
                {
                    cajaParams.Consecutivo += 1;
                    commB.UpdateEntity <ControlEntity.Caja>(cajaParams);
                    // actualizar consecutivo tabla cajas
                }
            }
            return(Consecutivo);
        }
Beispiel #12
0
        private void cajaBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (!ValidateFields())
            {
                return;
            }
            cajaBindingSource.EndEdit();
            var selectedCaja = commB.SetEntity <ControlEntity.Caja>(cajaBindingSource.Current);

            try
            {
                if (selectedCaja != null)
                {
                    commB.UpdateEntity <ControlEntity.Caja>(selectedCaja);
                }
            }
            catch (Exception ex)
            {
                ControlBusiness.BusinessHelpers.General.DoError(ex, "Control", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }

            cajaBindingSource.ResetBindings(true);
        }
 private void tipoIdBindingNavigatorSaveItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (!ValidateFields())
         {
             return;
         }
         tipoIdBindingSource.EndEdit();
         var selectedTipoId = commB.SetEntity <TipoId>(tipoIdBindingSource.Current);
         if (selectedTipoId != null)
         {
             commB.UpdateEntity <TipoId>(selectedTipoId);
         }
         tipoIdBindingSource.ResetBindings(true);
         commB.SaveBitacora(this.Name + " Guardado tipo Id: " + selectedTipoId.IdTipoId, false, Tools.UserCredentials.UserId);
         lblInfoMessage.Text = "Tipo Id guardado satisfactoriamente";
     }
     catch (Exception ex)
     {
         CursosBusiness.BusinessHelpers.General.LogInfo(ex, "Control", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
     }
 }
 private void usuarioBindingNavigatorSaveItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (!ValidateFields())
         {
             return;
         }
         usuarioBindingSource.EndEdit();
         var selectedUsuario = commB.SetEntity <Usuario>(usuarioBindingSource.Current);
         if (selectedUsuario != null)
         {
             commB.UpdateEntity <Usuario>(selectedUsuario);
         }
         commB.SaveBitacora("Usuario guardado: " + selectedUsuario.IdUsuario, false, Tools.UserCredentials.UserId);
         usuarioBindingSource.ResetBindings(true);
         lblInfoMessage.Text = "Usuario guardado satisfactoriamente";
     }
     catch (Exception ex)
     {
         General.LogInfo(ex, "Control", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
     }
 }
 private void aulaBindingNavigatorSaveItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (!ValidateFields())
         {
             return;
         }
         aulaBindingSource.EndEdit();
         var selectedAula = commB.SetEntity <Aula>(aulaBindingSource.Current);
         if (selectedAula != null)
         {
             commB.UpdateEntity <Aula>(selectedAula);
         }
         aulaBindingSource.ResetBindings(true);
         commB.SaveBitacora(this.Name + " Guardada aula: " + selectedAula.IdAula, false, Tools.UserCredentials.UserId);
         lblInfoMessage.Text = "Aula guardada satisfactoriamente";
     }
     catch (Exception ex)
     {
         General.LogInfo(ex, "Control", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
     }
 }
        private void btnAsignar_Click(object sender, EventArgs e)
        {
            var hayCerrar = (from a in cp
                             where a.Cerrar
                             select a).Count();

            if (hayCerrar > 0)
            {
                foreach (CursosDtos.CursosProfesorCerrarList item in cp)
                {
                    if (item.Cerrar)
                    {
                        try
                        {
                            var curp = commB.FindCursoProfesorByIdCursoHorarioIdProfesor(item.IdCursosHorarios,
                                                                                         Convert.ToInt32(txtIdProfesor.Text));
                            curp.Activo = false;
                            commB.UpdateEntity <CursosProfesor>(curp);
                            commB.SaveBitacora(this.Name + " Curso cerrado: " + item.Id, false, Tools.UserCredentials.UserId);
                        }
                        catch (Exception ex)
                        {
                            General.LogInfo(ex, "Control", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                        }
                    }
                }
                CargarCursos();
                lblInfoMessage.Text = "Proceso terminado";
                //MessageBox.Show("Proceso terminado", "Cerrar Cursos",
                //    MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            else
            {
                MessageBox.Show("Debe marcar al menos un curso a cerrar", "Cerrar Cursos",
                                MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
        }
 private void okButton1_Click(object sender, EventArgs e)
 {
     if (!ValidaAjuste())
     {
         return;
     }
     try
     {
         bool continuar  = true;
         var  producto   = inventBL.GetProductoByCode(txtCodigoProducto.Text.Trim());
         var  existencia = inventBL.GetProductoExistencias(producto.IdProducto);
         if (producto != null)
         {
             var precioUnitario = 0m;
             genB.BeginTran();
             var montoAjuste = Convert.ToDecimal(txtMontoAjuste.Text) * (rdoDebito.Checked ? 1 : -1);
             if (existencia.CantidadTotal > 0)
             {
                 precioUnitario = ((producto.PrecioUnitario * existencia.CantidadTotal) + montoAjuste) / existencia.CantidadTotal;
                 if (precioUnitario < 0)
                 {
                     lblMensaje.Text = "El monto del ajuste es mayor al costo de todos los productos";
                     continuar       = false;
                 }
             }
             else
             {
                 if (montoAjuste > 0)
                 {
                     precioUnitario = montoAjuste;
                 }
                 else
                 {
                     lblMensaje.Text = "No se puede aplicar una nota de crédito a un producto sin existencia.";
                     continuar       = false;
                 }
             }
             if (continuar)
             {
                 producto.PrecioUnitario = precioUnitario;
                 genB.UpdateEntity <Producto>(producto);
                 genB.Commit();
                 SetForm();
                 MessageBox.Show("Proceso aplicado", "Control", MessageBoxButtons.OK, MessageBoxIcon.Information,
                                 MessageBoxDefaultButton.Button1);
             }
             else
             {
                 genB.Rollback();
             }
         }
         else
         {
             lblMensaje.Text = "No se puede aplicar una nota de crédito a un producto sin existencia.";
         }
     }
     catch (Exception ex)
     {
         ControlBusiness.BusinessHelpers.General.DoError(ex, "Control", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
     }
 }
        /// <summary>
        /// usa un context general un nuevo control context para hacer la transaction
        /// hace llamdos a metodos del inventBL que a su vez usa el mismo context
        /// </summary>
        /// <returns></returns>
        private int SaveAjusteCurrentContext()
        {
            var continuar   = true;
            var consecutivo = 1;

            /// current context
            /// usamos el de invent porque solo esas tablas se modifican
            /// por el momento no hay un context general para todos nucleos
            /// podria ponerse en una interface padre
            ////var context = inventBL.dbCtx;
            /// inicio la transaction con el context actual
            //using (var dbcxtransaction = context.Database.BeginTransaction())
            commB.BeginTran();
            {
                try
                {
                    foreach (var item in detailAjustes.AjustesLines)
                    {
                        var producto = inventBL.GetProductoById(item.IdProducto);
                        if (producto != null)
                        {
                            /// actualizar costo: get costo
                            producto.PrecioVenta = item.Precio;
                            commB.UpdateEntity <Producto>(producto);
                            /// solo para los q tienen existencia, para los demas no se acualiz su existencia
                            if (producto.VerificaDisponible)
                            {
                                var existencia = inventBL.GetExistenciaByIdProducto(item.IdProducto);
                                var cantidad   = item.Cantidad;
                                if (rdoSalida.Checked)
                                {
                                    cantidad = cantidad * -1;
                                }
                                if (existencia != null)
                                {
                                    if (existencia.Cantidad + cantidad >= 0)
                                    {
                                        inventBL.UpdateExistencia(existencia, cantidad);
                                        commB.Commit();
                                    }
                                    else
                                    {
                                        commB.Rollback();
                                        commB.Reload(producto);
                                        lblMensaje.Text = "El producto " + item.Descripcion +
                                                          " no puede tener existencias negativas.";
                                        continuar = false;
                                        break;
                                    }
                                }
                                else
                                {
                                    var newExist = inventBL.InsertExistencia(item.IdProducto, cantidad);
                                    ///dbcxtransaction.Commit();
                                    commB.Commit();
                                }
                            }
                        }
                        else
                        {
                            ///dbcxtransaction.Rollback();
                            commB.Rollback();
                            lblMensaje.Text = "El producto " + item.Descripcion +
                                              " no existe en el inventario";
                            continuar = false;
                            break;
                        }
                    }
                    if (!continuar)
                    {
                        return(0);
                    }
                    MessageBox.Show("Ajuste aplicado", "Control", MessageBoxButtons.OK, MessageBoxIcon.Information,
                                    MessageBoxDefaultButton.Button1);
                    return(consecutivo);
                }
                catch (Exception ex)
                {
                    ///dbcxtransaction.Rollback();
                    commB.Rollback();
                    ControlBusiness.BusinessHelpers.General.DoError(ex, "Control", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    return(0);
                }
            }
        }