private void Print_Click(object sender, RoutedEventArgs e) { if (typeSale == 1) { TXT.Sale(dateSale, Convert.ToDecimal(bruteValue.Content), Convert.ToDecimal(discount.Text), Convert.ToDecimal(totalValue.Content), Convert.ToDecimal(valuePay.Text), Convert.ToDecimal(change.Content), payment.Text, Sales.Log.Products(dateSale)); } else { TXT.Sale(dateSale, Convert.ToDecimal(bruteValue.Content), Convert.ToDecimal(discount.Text), Convert.ToDecimal(totalValue.Content), Convert.ToDecimal(valuePay.Text), Convert.ToDecimal(change.Content), payment.Text, items); } new Impressao().ShowDialog(); Confirm_Click(null, null); }
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(); } }
private void GridSales_PreviewMouseUp(object sender, MouseButtonEventArgs e) { if (gridSales.HasItems == false || gridSales.CurrentCell.IsValid == false) { return; } View.Sale it = (View.Sale)gridSales.SelectedItem; if (it == null) { return; } // Delete if (gridSales.CurrentCell.Column.DisplayIndex == 6) { if (it.Type == 0) { if (MessageBox.Show("Tem certeza que deseja excluir a venda?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { Sales.Log.Delete(it.Date); sales.Remove(it); } } else { if (MessageBox.Show("Tem certeza que deseja excluir a venda?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { Sales.Log.Delete(it.Date); sales.Remove(it); } } } // Edit else if (gridSales.CurrentCell.Column.DisplayIndex == 7) { if (it.Type == 0) { VendasBalcao balcao = new VendasBalcao(this, Sales.Log.Products(it.Date), it.Date, true, Sales.Log.NumTable(it.Date)); balcao.ShowDialog(); } else { Tables.Client client = Sales.Log.Client(it.Date); string[] info = Sales.Log.InfoDelivery(it.Date); VendasDelivery delivery = new VendasDelivery(this, Sales.Log.Products(it.Date), client, it.Date, true, info[0], info[1], info[2], info[3]); delivery.ShowDialog(); } } // Print else if (gridSales.CurrentCell.Column.DisplayIndex == 8) { if (it.Type == 0) { MessageBox.Show("Somente vendas Deliveries podem ser impressas antes de finalizadas!!!"); return; } else { Tables.Client client = Sales.Log.Client(it.Date); string[] info = Sales.Log.InfoDelivery(it.Date); string payment = info[0]; decimal discount = Convert.ToDecimal(info[1]); decimal valuePay = Convert.ToDecimal(info[2]); decimal change = Convert.ToDecimal(info[3]); ObservableCollection <Item> items = Sales.Log.Products(it.Date); TXT.Sale(client, it.Date, it.Total + discount, discount, it.Total, payment, valuePay, change, items); new Impressao().ShowDialog(); } } // Confirm else if (gridSales.CurrentCell.Column.DisplayIndex == 9) { if (it.Type == 0) { new VendasPagamento(it.Total) { typeSale = 1, sales = this, numTable = Sales.Log.NumTable(it.Date), dateSale = it.Date }.ShowDialog(); UpdateGrid(); } else { Tables.Client client = Sales.Log.Client(it.Date); string[] info = Sales.Log.InfoDelivery(it.Date); if (MessageBox.Show("Tem certeza de que deseja FINALIZAR a venda do Cliente " + client.Name + "??", "", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No) { return; } string payment = info[0]; decimal discount = Convert.ToDecimal(info[1]); decimal valuePay = Convert.ToDecimal(info[2]); decimal change = Convert.ToDecimal(info[3]); ObservableCollection <Item> items = Sales.Log.Products(it.Date); new Sql.Sale().Insert(client, it.Date, it.Total + discount, discount, it.Total, payment, items); if (MessageBox.Show("Deseja imprimir o CUPOM NÃO FISCAL??", "", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { TXT.Sale(client, it.Date, it.Total + discount, discount, it.Total, payment, valuePay, change, items); new Impressao().ShowDialog(); } Sales.Log.Delete(it.Date); sales.Remove(it); } } }