Esempio n. 1
0
        public frmCharge(User user, Customer customer, Sale sale, decimal amount, decimal discount, decimal total)
        {
            InitializeComponent();

            this.User = user;
            this.Customer = customer;
            sale.Amount = amount;
            sale.Discount = discount;
            sale.Total = total;
            this.Sale = sale;

            this.salesService = new SalesService();
            this.productsService = new ProductsService();

            this.Load += (s, e) =>
            {
                txtTicket.Text = salesService.GetTicketNumber().ToString();
                txtDiscout.Text = this.Sale.Discount.ToString();
                txtTotal.Text = this.Sale.Total.ToString();

                cmbUser.DataSource = new List<User> { this.User };
                cmbUser.DisplayMember = "Username";
                cmbUser.ValueMember = "Id";

                cmbCustomer.DataSource = new List<Customer> { this.Customer };
                cmbCustomer.DisplayMember = "FullName";
                cmbCustomer.ValueMember = "Id";

                txtCash.Focus();
            };

            btnCharge.Click += (s, e) =>
            {
                var currentSale = this.Sale;

                salesService.Create(currentSale, this.User, this.Customer);

                //
                //PrintTicket
                //
                PrintTicket(this.Sale);

                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            };

            txtCash.KeyDown += (s, e) =>
            {
                if (e.KeyCode == Keys.Enter)
                {
                    var currentSale = this.Sale;

                    salesService.Create(currentSale, this.User, this.Customer);

                    //
                    //PrintTicket
                    //
                    PrintTicket(this.Sale);

                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    this.Close();
                }
            };

            btnCancel.Click += (s, e) =>
            {
                this.DialogResult = System.Windows.Forms.DialogResult.No;
            };
        }
Esempio n. 2
0
        public frmSales(User user)
        {
            InitializeComponent();
            
            this.User = user;

            customersService = new CustomersService();
            productsService = new ProductsService();
            salesService = new SalesService();

            this.Load += (s, e) =>
            {
                this.WindowState = FormWindowState.Maximized;
                StartNewSale();
            };

            this.KeyDown += (s, e) =>
            {

            };
            
            txtBarcode.KeyDown += (s, e) =>
            {
                switch (e.KeyCode)
                {
                    case Keys.Enter:
                        AddItemToList();
                        break;
                    case Keys.F4:
                        listView1.Focus();
                        break;
                    case Keys.F6:
                        Charge();
                        break;
                }
            };

            listView1.KeyDown += (s, e) =>
            {
                if (e.KeyCode == Keys.Delete)
                    RemoveItemFromList();

                if (e.KeyCode == Keys.F4)
                {
                    txtBarcode.Text = "";
                    txtBarcode.Focus();
                }

                if (e.KeyCode == Keys.F6)
                    Charge();
            };

            listView1.SelectedIndexChanged += (s, e) =>
            {
                btnRemoveItem.Enabled = true;
            };

            btnAddItem.Click += (s, e) =>
            {
                AddItemToList();
            };

            btnRemoveItem.Click += (s, e) =>
            {
                RemoveItemFromList();
            };

            btnResetSale.Click += (s, e) =>
            {
                ResetSale();
            };

            btnCharge.Click += (s, e) =>
            {
                Charge();
            };
        }