private void Confirm_Click(object sender, RoutedEventArgs e)
        {
            // TABLE
            if (typeSale == 1)
            {
                new Sql.Sale().Insert(numTable, dateSale, Convert.ToDecimal(bruteValue.Content), Convert.ToDecimal(discount.Text), Convert.ToDecimal(totalValue.Content), payment.Text, Sales.Log.Products(dateSale));

                Sales.Log.Delete(dateSale);

                sales.UpdateGrid();
            }
            // FAST
            else
            {
                new Sql.Sale().Insert(dateSale, Convert.ToDecimal(bruteValue.Content), Convert.ToDecimal(discount.Text), Convert.ToDecimal(totalValue.Content), payment.Text, items);
            }

            Confirmed = true;

            MessageBox.Show("Venda confirmada!!!");

            Close();
        }
Exemplo n.º 2
0
        private void Confirm_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(searchName.Text) ||
                string.IsNullOrEmpty(street.Text) ||
                string.IsNullOrEmpty(number.Text) ||
                string.IsNullOrEmpty(district.Text))
            {
                MessageBox.Show("Por favor preencha todas as informações");
                return;
            }
            else if (gridProduct.HasItems == false)
            {
                MessageBox.Show("É necessário ter produtos a venda");
                return;
            }

            Tables.Client client = new Tables.Client(searchName.Text, street.Text, Convert.ToInt32(number.Text), district.Text, complement.Text, telephone.Text, Reference.Text);

            decimal tempTotalSale = TotalSale(Convert.ToDecimal(discount.Text));
            decimal tempDiscount  = Convert.ToDecimal(discount.Text);
            decimal tempValuePay  = Convert.ToDecimal(valuePay.Text);
            decimal tempChange    = tempValuePay - tempTotalSale;

            if (isEditing == false)
            {
                Sales.Log.Create(DateTime.Now, client, payment.Text, tempDiscount, tempValuePay, tempChange, Items);

                if (MessageBox.Show("Venda adicionada com sucesso!!!\nDeseja imprimir o CUPOM NÃO FISCAL??", "", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    TXT.Sale(client, DateTime.Now, tempTotalSale + tempDiscount, tempDiscount, tempTotalSale, payment.Text, tempValuePay, tempChange, Items);
                    new Impressao().ShowDialog();
                }

                searchName.Text = "";
                street.Text     = "";
                complement.Text = "";
                district.Text   = "";
                number.Text     = "";
                discount.Text   = "0,00";
                telephone.Text  = "";
                Reference.Text  = "";

                Items.Clear();
                labelTotalSale.Content = "TOTAL:R$0,00";
                valuePay.Text          = "0,00";
                Switch(Convert.ToDecimal(valuePay.Text));
                quantity.Text = "";
                searchName.Focus();

                sales.UpdateGrid();
            }
            else
            {
                Sales.Log.Create(dateSale, client, payment.Text, tempDiscount, tempValuePay, tempChange, Items);

                if (MessageBox.Show("Venda alterada com sucesso!!!\nDeseja imprimir o CUPOM NÃO FISCAL??", "", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    TXT.Sale(client, dateSale, tempTotalSale + tempDiscount, tempDiscount, tempTotalSale, payment.Text, tempValuePay, tempChange, Items);
                    new Impressao().ShowDialog();
                }

                Close();
            }
        }
Exemplo n.º 3
0
 private void VendasBalcao_Closed(object sender, EventArgs e)
 {
     sales.UpdateGrid();
 }
Exemplo n.º 4
0
        public VendasDelivery(Vendas sales, ObservableCollection <Item> items, Tables.Client oldAddress, DateTime dateSale, bool isEditing = false, string payment = "", string discounts = "", string valuePays = "", string changes = "")
        {
            InitializeComponent();

            sqlClient  = new Sql.Client();
            sqlProduct = new Sql.Product();

            Items = new ObservableCollection <Item>();
            gridProduct.DataContext = Items;

            foreach (Item it in items)
            {
                Items.Add(it);
            }

            this.sales = sales;
            Closed    += (sender, e) => sales.UpdateGrid();
            Loaded    += VendasDelivery_Loaded;

            // CLIENT

            searchName.PreviewKeyDown += SearchName_PreviewKeyDown;
            searchName.TextChanged    += SearchName_TextChanged;

            gridClient.MouseDoubleClick += GridClient_MouseDoubleClick;

            number.PreviewTextInput += (sender, e) => e.Handled = new Regex("[^0-9]+").IsMatch(e.Text);

            discount.GotFocus         += Discount_GotFocus;
            discount.LostFocus        += Discount_LostFocus;
            discount.PreviewTextInput += (sender, e) => e.Handled = new Regex("[^0-9,]+").IsMatch(e.Text);
            discount.TextChanged      += Discount_TextChanged;

            // Product

            searchProduct.PreviewKeyDown   += SearchProduct_PreviewKeyDown;
            searchProduct.PreviewTextInput += SearchProduct_PreviewTextInput;
            searchProduct.TextChanged      += SearchProduct_TextChanged;

            gridSearch.PreviewKeyDown   += GridSearch_PreviewKeyDown;
            gridSearch.MouseDoubleClick += GridSearch_MouseDoubleClick;

            observation.PreviewKeyDown += (sender, e) => { if (e.Key == Key.Enter)
                                                           {
                                                               quantity.Focus();
                                                           }
            };

            quantity.PreviewKeyDown   += Quantity_PreviewKeyDown;
            quantity.PreviewTextInput += (sender, e) => e.Handled = new Regex("[^0-9]+").IsMatch(e.Text);

            gridProduct.BeginningEdit  += (sender, e) => e.Cancel = true;
            gridProduct.PreviewKeyDown += GridProduct_PreviewKeyDown;

            searchName.LostFocus += (sender, e) => CheckClient();
            street.LostFocus     += (sender, e) => CheckClient();;
            number.LostFocus     += (sender, e) => CheckClient();;
            district.LostFocus   += (sender, e) => CheckClient();;

            // BUTTONS

            this.payment.SelectionChanged += Payment_SelectionChanged;

            valuePay.PreviewTextInput += (sender, e) => e.Handled = new Regex("[^0-9,]+").IsMatch(e.Text);
            valuePay.GotFocus         += ValuePay_GotFocus;
            valuePay.LostFocus        += ValuePay_LostFocus;
            valuePay.TextChanged      += ValuePay_TextChanged;

            newClient.Click += NewClient;
            confirm.Click   += Confirm_Click;

            if (isEditing)
            {
                this.isEditing = true;
                this.dateSale  = dateSale;

                searchName.Text = oldAddress.Name;
                number.Text     = oldAddress.Number.ToString();
                street.Text     = oldAddress.Street;
                district.Text   = oldAddress.District;
                complement.Text = oldAddress.Complement;
                telephone.Text  = oldAddress.Telephone;
                Reference.Text  = oldAddress.Reference;

                switch (payment)
                {
                case "Á VISTA":
                    this.payment.SelectedIndex = 0;
                    break;

                case "CRÉDITO":
                    this.payment.SelectedIndex = 1;
                    break;

                case "DÉBITO":
                    this.payment.SelectedIndex = 2;
                    break;
                }

                this.discount.Text     = discounts;
                this.valuePay.Text     = valuePays;
                labelTotalSale.Content = "TOTAL:" + TotalSale(Convert.ToDecimal(discount.Text)).ToString("C2");
                Switch(Convert.ToDecimal(valuePay.Text));
            }
        }