Ejemplo n.º 1
0
        public static ObservableCollection <Item> Products(DateTime dateSale)
        {
            ObservableCollection <Item> it = new ObservableCollection <Item>();

            string[] lines = File.ReadAllLines(DefaultPath() + dateSale.ToString("yyyy-MM-dd HH+mm+ss") + ".bin");

            int index = 0;

            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i].StartsWith("-PRODUTOS-"))
                {
                    index = i + 1;
                    break;
                }
            }

            for (int i = index; i < lines.Length; i++)
            {
                string[] requests = lines[i].Split('>');

                int    id       = Convert.ToInt32(requests[0]);
                string obs      = requests[1];
                int    quantity = Convert.ToInt32(requests[2]);

                var p = new Sql.Product().GetProduct(id);
                it.Add(new Item(id, p.Cod, p.Name + " " + obs, p.Price, quantity));
            }

            return(it);
        }
Ejemplo n.º 2
0
        public ProdutosAdd(Tables.Product product = null)
        {
            InitializeComponent();

            sqlProduct = new Sql.Product();

            if (product != null)
            {
                idProduct        = product.Id;
                codProduct       = product.Cod;
                Description.Text = product.Name;
                Code.Text        = product.Cod.ToString();
                Price.Text       = product.Price.ToString();
            }

            Loaded += ProdutosAdd_Loaded;

            Description.PreviewKeyDown += Description_PreviewKeyDown;
            Code.PreviewKeyDown        += Code_PreviewKeyDown;
            Price.PreviewKeyDown       += Price_PreviewKeyDown;

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

            ClearBtn.Click += ClearBtn_Click;
            SaveBtn.Click  += SaveBtn_Click;
        }
Ejemplo n.º 3
0
        public Produtos()
        {
            InitializeComponent();

            sqlProduct = new Sql.Product();

            Search.Visibility = Visibility.Collapsed;

            Loaded += Produtos_Loaded;

            GridProdutos.PreviewMouseDoubleClick += GridProdutos_PreviewMouseDoubleClick;

            Search.GotFocus         += Search_GotFocus;
            Search.PreviewKeyDown   += Search_PreviewKeyDown;
            Search.PreviewTextInput += Search_PreviewTextInput;
            Search.TextChanged      += Search_TextChanged;

            lupa.PreviewMouseDown += Lupa_PreviewMouseDown;

            BackProduto.Click += (sender, e) => Close();
            DelProduto.Click  += DelProduto_Click;
            EditProduto.Click += (sender, e) => GridProdutos_PreviewMouseDoubleClick(null, null);
            AddProduto.Click  += AddProduto_Click;

            menuDel.Click  += DelProduto_Click;
            menuEdit.Click += (sender, e) => GridProdutos_PreviewMouseDoubleClick(null, null);
            menuAdd.Click  += AddProduto_Click;
        }
Ejemplo n.º 4
0
        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;
            }
        }
Ejemplo n.º 5
0
        public VendasRapida()
        {
            InitializeComponent();

            sqlProduct = new Sql.Product();
            gridProduct.DataContext = Items;

            Loaded += VendasRapida_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 += (sender, e) => e.Handled = new Regex("[^0-9]+").IsMatch(e.Text);

            gridProduct.PreviewKeyDown += GridProduct_PreviewKeyDown;

            confirm.Click += Confirm_Click;
        }
Ejemplo n.º 6
0
        public static void Select(ObservableCollection <View.Sale> sales, int index = 0)
        {
            sales.Clear();
            string[] files = Directory.GetFiles(DefaultPath(), "*.bin", SearchOption.TopDirectoryOnly);

            for (int i = 0; i < files.Length; i++)
            {
                string[] lines    = File.ReadAllLines(files[i]);
                string   fileName = Path.GetFileNameWithoutExtension(files[i]);
                fileName = fileName.Replace('+', ':');
                DateTime dateSale = Convert.ToDateTime(fileName);

                if (lines[0].StartsWith("BALCÃO") && (index == 0 || index == 2))
                {
                    string numTable = lines[1];

                    string  info      = "MESA: Nº" + numTable + "\n\n";
                    decimal totalSale = 0;
                    for (int j = 3; j < lines.Length; j++)
                    {
                        string[] requests = lines[j].Split('>');

                        int    id       = Convert.ToInt32(requests[0]);
                        string obs      = requests[1];
                        int    quantity = Convert.ToInt32(requests[2]);

                        var p = new Sql.Product().GetProduct(id);
                        info      += (p.Price * quantity).ToString("C2").PadRight(12, ' ') + quantity + "x " + p.Name + " " + obs + "\n";
                        totalSale += p.Price * quantity;
                    }

                    sales.Add(new View.Sale()
                    {
                        Type = 0, Value = "BALCÃO", File = numTable, Info = info, Date = dateSale, Total = totalSale
                    });
                }
                else if (lines[0].StartsWith("DELIVERY") && (index == 0 || index == 1))
                {
                    string name       = lines[1];
                    string street     = lines[2];
                    string number     = lines[3];
                    string district   = lines[4];
                    string complement = lines[5];
                    string telephone  = lines[6];
                    string reference  = lines[7];
                    string payment    = lines[8];
                    string discount   = lines[9];
                    string valuePay   = lines[10];
                    string change     = lines[11];

                    string info = name + "\n\n";
                    info += "ENDEREÇO: " + street + ", Nº" + number + ", " + district + ", " + complement + "\n";
                    info += "TELEFONE: " + telephone + "\n";
                    info += "REFERÊNCIA: " + reference + "\n";
                    info += "FORMA DE PAGAMENTO: " + payment + "\n";
                    info += "DESCONTO: R$" + discount + "\n";

                    if (payment == "À VISTA")
                    {
                        info += "VALOR PAGO: R$" + valuePay + "\n";
                        info += "TROCO: R$" + change + "\n";
                    }

                    info += "\n";

                    info += "PEDIDOS\n";
                    decimal totalSale = 0;
                    for (int j = 13; j < lines.Length; j++)
                    {
                        string[] requests = lines[j].Split('>');

                        int    id       = Convert.ToInt32(requests[0]);
                        string obs      = requests[1];
                        int    quantity = Convert.ToInt32(requests[2]);

                        var p = new Sql.Product().GetProduct(id);
                        info      += (p.Price * quantity).ToString("C2").PadRight(12, ' ') + quantity + "x " + p.Name + " " + obs + "\n";
                        totalSale += p.Price * quantity;
                    }

                    sales.Add(new View.Sale()
                    {
                        Type = 1, Value = "DELIVERY", File = name, Info = info, Date = dateSale, Total = totalSale - Convert.ToDecimal(discount)
                    });
                }
            }

            sales.Rearrange();
        }
Ejemplo n.º 7
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));
            }
        }