private void Button15_Click(object sender, EventArgs e)//stok düşme
        {
            int productStock = selectedSaleProduct.stockCount;
            var newStock     = productStock - (Convert.ToInt32(sellProductCountTxt.Text));

            if (newStock >= 0)
            {
                selectedSaleProduct.stockCount = newStock;

                var status = ProductHelper.ProductCUD(selectedSaleProduct, System.Data.Entity.EntityState.Modified);
                //LoadSaleProductList();
                if (status.isSuccess)
                {
                    MessageBox.Show(status.message, "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    var saleDepartment = new SaleDapertment
                    {
                        customerId = saleSelectedCustomers.customerId,
                        productId  = selectedSaleProduct.productId,
                        sellDate   = DateTime.Now
                    };

                    SalesHelper.AddSale(saleDepartment);
                }
            }
            else
            {
                MessageBox.Show("Seçilen ürünün yeterli stoğu bulunmamaktadır. Satış işlemi yapılamadı", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemple #2
0
        private void NewProcess()
        {
            CurrentOperation = Operations.Process;
            var autorizacion = SalesDetailsCollection.ToList().Any(dc => dc.PriceEdited);

            if (!UserIsValid && autorizacion)
            {
                ShowUserValidatorPicker();
                return;
            }

            IsBusy = IsDetailsBusy = true;
            if (SalesHelper.VerifyNumAtCard(SelectedSale))
            {
                if (!ShowWarningMessage("Numero de Factura Repetido, Desea continuar de todas formas ?"))
                {
                    IsBusy = IsDetailsBusy = false;
                    return;
                }
            }

            if (!ConfirmDialog("Desea procesar la venta?", "procesar"))
            {
                UndoChanges();
                IsBusy = IsDetailsBusy = false;
                return;
            }
            ViewModelManager.CloseModal();
            ShowProcessLoader(this);
            AsyncHelper.DoAsync(() =>
            {
                if (!Exento && !WithHolding)
                {
                    CheckIVACOM(true);
                }
                else
                {
                    CheckIVAEXE(Exento);
                    CheckIVARET(WithHolding);
                }

                //SelectedSale.StateL = LocalStatus.Pendiente;
                SalesHelper.AddSale(SelectedSale);
                if (HasDownPayment && SelectedDownPayment != null)
                {
                    SelectedDownPayment         = SelectedDownPayment.ForceUpdateToDataBase();
                    SelectedDownPayment.IdSaleL = SelectedSale.IdSaleL;
                }
                else if (SelectedDownPayment != null)
                {
                    SelectedDownPayment.IdSaleL = null;
                }

                SaveChanges();

                CheckBookHelper.SetNextCheckBookNumber((int)SelectedSale.Series,
                                                       Convert.ToInt32(selectedSale.NumAtCard));


                Synchronization.Synchronize(SelectedSale);


                IsBusy = IsDetailsBusy = false;

                SaveChanges();
                RefreshItemSource();
            }, ViewModelManager.CloseProcessLoader);
        }
Exemple #3
0
        private void SaveNewDetails()
        {
            CurrentOperation = Operations.Save;
            var autorizacion = SalesDetailsCollection.ToList().Any(dc => dc.PriceEdited);

            if (!UserIsValid && autorizacion)
            {
                ShowUserValidatorPicker();
                return;
            }

            if (SalesHelper.VerifyNumAtCard(SelectedSale))
            {
                if (ShowWarningMessage("Numero de Factura Repetido, Desea continuar de todas formas ?"))
                {
                    return;
                }
                IsBusy = IsDetailsBusy = false;
                return;
            }


            if (!ConfirmDialog("Desea Guardar Los Cambios", "Guardar"))
            {
                UndoChanges();
                return;
            }

            // Excluir articulos no inventariables.
            var productsToExclude = ArticlesHelper.GetProductsOnInventory(SalesDetailsCollection.Select(d => d.ItemCode).ToList());

            //.Where(p=> p.OITM_Articles.InvntItem.Contains("Y"))
            var isnotValid = SalesDetailsCollection.Where(p => !productsToExclude.Contains(p.ItemCode))

                             .Any(d =>
            {
                if (d.Quantity > d.OnHand)
                {
                    ErrorMessage = string.Format("El Articulo : {0} Codigo {1} ,Quedara en Negativo", d.Dscription, d.ItemCode);
                    ShowErrorMessageBox(ErrorMessage);
                    return(true);
                }

                ErrorMessage = string.Empty;
                return(false);
            });

            if (isnotValid)
            {
                return;
            }

            if (!Exento && !WithHolding)
            {
                CheckIVACOM(true);
            }
            else
            {
                CheckIVAEXE(Exento);
                CheckIVARET(WithHolding);
            }
            if (!HasDownPayment)
            {
                SelectedSale.dpEntry = 0;
            }
            SalesHelper.AddSale(SelectedSale);
            //if (SelectedDownPayment != null)
            //{
            //    if (HasDownPayment) SelectedDownPayment.IdSaleL = SelectedSale.IdSaleL; else SelectedDownPayment.IdSaleL = null;
            //}


            SaveChanges();

            // TODO validar los valores Series y NumAtCard  son diferentes de null ,
            //y considerar el caso en que los valores son 0

            if (SelectedSale == null)
            {
                return;                       // TODO Show error Message
            }
            var serieNumber = (int)(SelectedSale.Series.HasValue? SelectedSale.Series : 0);
            var numAtcoard  = !string.IsNullOrEmpty(SelectedSale.NumAtCard)
                            ? Convert.ToInt32(SelectedSale.NumAtCard)
                            : 0;

            CheckBookHelper.SetNextCheckBookNumber(serieNumber, numAtcoard);
            ViewModelManager.CloseModal();
            RefreshItemSource();
        }