Ejemplo n.º 1
0
        /// <summary>
        /// Método para guardar los nuevos movimientos de inventario a la base de datos.
        /// </summary>
        /// <history>
        /// [edgrodriguez] 22/Feb/2016 Created
        /// </history>
        private async void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (!ValidateCurrentDate() || _lstobjWhsMovs.Count <= 0 ||
                _lstobjWhsMovs.Any(c => c.wmQty == 0 || c.wmgi == null || c.wmgi == ""))
            {
                return;
            }

            _lstobjWhsMovs.ForEach(c =>
            {
                c.wmD  = dtpDate.Value.Value;
                c.wmwh = Context.User.Warehouse.whID;
                c.wmpe = Context.User.User.peID;
            });

            List <WarehouseMovement> lstWhsMov = _lstobjWhsMovs.Select(c => new WarehouseMovement
            {
                wmComments = c.wmComments,
                wmD        = c.wmD,
                wmgi       = c.wmgi,
                wmID       = c.wmID,
                wmpe       = c.wmpe,
                wmQty      = c.wmQty,
                wmwh       = c.wmwh
            }).ToList();

            try
            {
                int nRes = await BREntities.OperationEntities(lstWhsMov, EnumMode.Add);

                if (nRes > 0)
                {
                    UIHelper.ShowMessage("The warehouse movements was saved successfully.", title: "Intelligence Marketing");
                    InitializeGrdNew();
                    _whsMovViewSource.Source = BRWarehouseMovements.GetWarehouseMovements(Context.User.Warehouse.whID,
                                                                                          dtpDate.Value.Value.Date);
                }
                else
                {
                    UIHelper.ShowMessage("The warehouse movements was not saved.", MessageBoxImage.Error,
                                         "Intelligence Marketing");
                }
            }
            catch (Exception ex)
            {
                UIHelper.ShowMessage(ex);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Método que se ejecuta al dispararse el evento SelectedDateChanged,
        /// si existió un cambio se realiza la consulta a la base de datos para
        /// actualizar el grid.
        /// </summary>
        /// <history>
        /// [edgrodriguez] 19/Feb/2016 Created
        /// </history>
        private void dtpDate_SelectedDateChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            // [wtorres] 15/Mar/2016 validamos que el formulario ya se haya inicializado
            if (!IsInitialized || string.IsNullOrEmpty(dtpDate.Text))
            {
                return;
            }

            if (dtpDate.Value != null && _dtmcurrent != dtpDate.Value.Value)
            {
                _whsMovViewSource = ((CollectionViewSource)FindResource("whsMovViewSource"));
                // Load data by setting the CollectionViewSource.Source property:
                _whsMovViewSource.Source = BRWarehouseMovements.GetWarehouseMovements(Context.User.Warehouse.whID, dtpDate.Value.Value.Date);
                StatusBarReg.Content     = $"{grd.SelectedItems.Count}/{_whsMovViewSource.View.SourceCollection.Cast<WarehouseMovementShort>().Count()}";
            }
            if (dtpDate.Value != null)
            {
                _dtmcurrent = dtpDate.Value.Value;
            }
        }