Exemplo n.º 1
0
        private void Bill_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'OrderCoffeDataSet1.HoaDon' table. You can move, or remove it, as needed.
            this.HoaDonTableAdapter.Fill(this.OrderCoffeDataSet1.HoaDon, OrdersBus.GetIdOrder());
            Orders od = OrdersBus.getOrderById(OrdersBus.GetIdOrder());

            Microsoft.Reporting.WinForms.ReportParameter[] rp = new Microsoft.Reporting.WinForms.ReportParameter[]
            {
                new Microsoft.Reporting.WinForms.ReportParameter("DateExport", DateTime.Now.ToString()),
                new Microsoft.Reporting.WinForms.ReportParameter("PriceSales", od.TotalPrice.ToString()),
                new Microsoft.Reporting.WinForms.ReportParameter("Sales", od.Sales.ToString() + " %"),
            };
            this.reportViewer1.LocalReport.SetParameters(rp);
            this.reportViewer1.RefreshReport();
        }
        private void Button1_Click(object sender, EventArgs e)
        {
            if (listOrder == null || listOrder.Count == 0)
            {
                MessageBox.Show("Vui Lòng Chọn Sản Phẩm", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            try
            {
                int    total  = GetTotalPriceOrder();
                Orders orders = new Orders();
                orders.Date       = DateTime.Now;
                orders.TotalPrice = total;
                orders.Sales      = int.Parse(cbSales.SelectedItem.ToString());
                OrdersBus.CreateOrder(orders);
                int idOrder = OrdersBus.GetIdOrder();
                foreach (OrderDetail item in listOrder)
                {
                    OrderDetail detail = item;
                    detail.IdOrder = idOrder;
                    OrderDetailBus.AddOrderDetail(detail);
                }

                MessageBox.Show("Đã Xuất", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //  PrintOrder print = new PrintOrder();
                Bill print = new Bill();
                print.Show();
            }
            catch (Exception)
            {
                MessageBox.Show("Thất Bại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                listOrder.Clear();
                LoadDataListViewOrder();
                lbtongtien.Text = "0";
                cbSales.Text    = "0";
            }
        }
 public void loadData()
 {
     try
     {
         List <OrderDetail> list = OrderDetailBus.GetAllOrderDetailByIdOrder(OrdersBus.GetIdOrder());
         listViewBill.Items.Clear();
         foreach (var item in list)
         {
             Products product = ProductsBus.GetProductsById(item.IdProducts);
             var      row     = new string[] { product.Name, string.Format("{0:#,##0}", product.Price), item.Quanity.ToString(), string.Format("{0:#,##0}", item.TotalPrice) };
             var      lvi     = new ListViewItem(row);
             lvi.Tag = item;
             listViewBill.Items.Add(lvi);
         }
         Orders orders = OrdersBus.getOrderById(OrdersBus.GetIdOrder());
         lbSales.Text = orders.Sales.ToString() + "  %";
         lbTotal.Text = string.Format("{0:#,##0}", orders.TotalPrice) + " VNĐ";
         lbdate.Text  = orders.Date.ToString();
     }
     catch (Exception)
     {
     }
 }