Exemplo n.º 1
0
        private void DoAjuste()
        {
            try
            {
                if (gridDetalle.CurrentRow != null)
                {
                    var curCode      = gridDetalle.CurrentRow.Cells["Codigo"].Value;
                    var selectedLine = (from p in detailRep.CartLines
                                        where p.Producto.Codigo == curCode.ToString()
                                        select p).FirstOrDefault();
                    if (selectedLine != null)
                    {
                        var ajusteForm = new AjusteLinea(selectedLine);
                        ajusteForm.ShowDialog();
                        var selectedProduct = (from p in detailRep.CartLines
                                               where p.Producto.Codigo == curCode.ToString()
                                               select p.Producto).FirstOrDefault();
                        if (ajusteForm.BorrarLinea)
                        {
                            /// delete from cart
                            detailRep.RemoveLine(selectedProduct);
                        }
                        /// no hay q actualizar el line porque ya lo hice en e form de ajuste
                        //else
                        //{
                        //    /// update cantidad y monto de descuento
                        //    var cantidadFinal = 0m;
                        //    //if (ajusteForm.cartLine.Cantidad < selectedLine.Cantidad)
                        //    //{
                        //    //    cantidadFinal = selectedLine.Cantidad - (selectedLine.Cantidad - ajusteForm.cartLine.Cantidad);
                        //    //}
                        //    //if (ajusteForm.cartLine.Cantidad > selectedLine.Cantidad)
                        //    //{
                        //    //    cantidadFinal = selectedLine.Cantidad + (ajusteForm.cartLine.Cantidad - selectedLine.Cantidad);
                        //    //}
                        //    cartBL.AddItem(selectedProduct, cantidadFinal,
                        //        ajusteForm.cartLine.MontoDescuento);
                        //}
                        DisplayCartData();

                        this.txtCantidad.Focus(); // hace que se valide el position text
                    }
                    else
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                ControlBusiness.BusinessHelpers.General.DoError(ex, "Control", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }