public VendasBalcao(Vendas sales, ObservableCollection <Item> items, DateTime dateSale, bool editing = false, int num = -1, string observations = "") { InitializeComponent(); sqlProduct = new Sql.Product(); Items = new ObservableCollection <Item>(); gridProduct.DataContext = Items; foreach (Item it in items) { Items.Add(it); } this.sales = sales; Closed += VendasBalcao_Closed; Loaded += VendasBalcao_Loaded; search.PreviewKeyDown += Search_PreviewKeyDown; search.PreviewTextInput += Search_PreviewTextInput; search.TextChanged += Search_TextChanged; gridSearch.PreviewKeyDown += GridSearch_PreviewKeyDown; gridSearch.MouseDoubleClick += GridSearch_MouseDoubleClick; quantity.PreviewKeyDown += Quantity_PreviewKeyDown; quantity.PreviewTextInput += (s, e) => e.Handled = new Regex("[^0-9]+").IsMatch(e.Text); numTable.PreviewTextInput += (s, e) => e.Handled = new Regex("[^0-9]+").IsMatch(e.Text);; gridProduct.BeginningEdit += (sender, e) => e.Cancel = true; gridProduct.PreviewKeyDown += GridProduct_PreviewKeyDown; numTable.PreviewKeyDown += (sender, e) => { if (e.Key == Key.Enter) { Confirm_Click(null, null); } }; observation.PreviewKeyDown += (sender, e) => { if (e.Key == Key.Enter) { quantity.Focus(); } }; confirm.Click += Confirm_Click; if (editing) { isEditing = true; oldNumTable = num; numTable.Text = num.ToString(); labelTotalSale.Content = "TOTAL:" + TotalSale().ToString("C2"); this.dateSale = dateSale; observation.Text = observations; } }
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)); } }