Example #1
0
        /// <summary>
        /// Agrega|Actualiza products
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 21/05/2016
        /// </history>
        private async void btnAccept_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string      richText = UIRichTextBoxHelper.getRTFFromRichTextBox(ref richTextBox);
                List <Gift> lstGift  = (List <Gift>)dgrGift.ItemsSource;
                if (enumMode != EnumMode.Add && _productLegend.pxText == richText.Trim() && ObjectHelper.IsEquals(product, oldProduct) && ObjectHelper.IsListEquals(lstGift, _oldlstGifts))
                {
                    blnClosing = true;
                    Close();
                }
                else
                {
                    StaStart("Saving Data...");
                    string strMsj = ValidateHelper.ValidateForm(this, "Product", blnDatagrids: true);
                    if (strMsj == "")
                    {
                        _productLegend.pxText = richText;
                        List <Gift> lstAdd = lstGift.Where(gi => !_oldlstGifts.Any(gii => gii.giID == gi.giID)).ToList();
                        List <Gift> lstDel = _oldlstGifts.Where(gi => !lstGift.Any(gii => gii.giID == gi.giID)).ToList();
                        int         nRes   = await BRProducts.SaveProduct(product, (enumMode == EnumMode.Edit), _productLegend, lstAdd, lstDel);

                        UIHelper.ShowMessageResult("Product", nRes);

                        if (nRes > 0)
                        {
                            blnClosing   = true;
                            DialogResult = true;
                            Close();
                        }
                    }
                    else
                    {
                        UIHelper.ShowMessage(strMsj);
                    }
                }
            }
            catch (Exception ex)
            {
                UIHelper.ShowMessage(ex);
            }
            finally
            {
                StaEnd();
            }
        }
Example #2
0
        /// <summary>
        /// Llena el grid de products
        /// </summary>
        /// <param name="product">Objeto a seleccionar</param>
        /// <history>
        /// [emoguel] created 20/05/2016
        /// </history>
        private async void LoadProducts(Product product = null)
        {
            try
            {
                int            nIndex      = 0;
                List <Product> lstProducts = await BRProducts.GetProducts(_nStatus, _productFilter);

                dgrProducts.ItemsSource = lstProducts;
                if (lstProducts.Count > 0 && product != null)
                {
                    product = lstProducts.Where(pr => pr.prID == product.prID).FirstOrDefault();
                    nIndex  = lstProducts.IndexOf(product);
                }
                GridHelper.SelectRow(dgrProducts, nIndex);
                StatusBarReg.Content = lstProducts.Count + " Products.";
                status.Visibility    = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                UIHelper.ShowMessage(ex);
            }
        }