Пример #1
0
        private void ComboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            cbMonth.Text = "";
            lvHistoryAdmin.Items.Clear();
            lvHistoryDetail.Items.Clear();

            int           year = int.Parse(cbYear.SelectedItem.ToString());
            List <Orders> list = OrdersBus.getAllOrdersByYear(year);

            if (list.Count == 0)
            {
                lbTotalOrder.Text = "0";
                lbTotalPrice.Text = "0" + " VND";
                return;
            }
            foreach (var item in list)
            {
                var row = new string[] { item.Id.ToString(), item.Date.ToString(), string.Format("{0:#,##0}", item.TotalPrice), item.Sales.ToString() };
                var lvi = new ListViewItem(row);
                lvi.Tag = item;
                lvHistoryAdmin.Items.Add(lvi);
            }

            lbTotalOrder.Text = OrdersBus.GetTotalOrderYear(year).ToString();
            lbTotalPrice.Text = string.Format("{0:#,##0}", OrdersBus.GetTotalPriceOrderYear(year)) + " VND";
        }
Пример #2
0
        private void Button1_Click(object sender, EventArgs e)
        {
            cbMonth.Text = "";
            cbYear.Text  = "";
            lvHistoryAdmin.Items.Clear();
            lvHistoryDetail.Items.Clear();
            if (dtkStart.Value.Date.CompareTo(dtkEnd.Value.Date) == 1)
            {
                lbTotalOrder.Text = "0";
                lbTotalPrice.Text = "0" + " VND";
                return;
            }
            List <Orders> list = OrdersBus.getAllOrdersByDateToDate(dtkStart.Value.Date, dtkEnd.Value.Date);

            if (list.Count == 0)
            {
                lbTotalOrder.Text = "0";
                lbTotalPrice.Text = "0" + " VND";
                return;
            }
            foreach (var item in list)
            {
                var row = new string[] { item.Id.ToString(), item.Date.ToString(), string.Format("{0:#,##0.00}", item.TotalPrice), item.Sales.ToString() };
                var lvi = new ListViewItem(row);
                lvi.Tag = item;
                lvHistoryAdmin.Items.Add(lvi);
            }

            lbTotalOrder.Text = OrdersBus.GetTotalOrder(dtkStart.Value.Date, dtkEnd.Value.Date).ToString();
            lbTotalPrice.Text = string.Format("{0:#,##0.00}", OrdersBus.GetTotalPriceOrder(dtkStart.Value.Date, dtkEnd.Value.Date)) + " VND";
        }
 public void LoadListViewHistoryOrder()
 {
     lvHistoryOrder.Items.Clear();
     foreach (var item in OrdersBus.getAllOrdersToDay(DateTime.Today))
     {
         var row = new string[] { item.Id.ToString(), item.Date.ToString(), string.Format("{0:#,##0}", item.TotalPrice), item.Sales.ToString() };
         var lvi = new ListViewItem(row);
         lvi.Tag = item;
         lvHistoryOrder.Items.Add(lvi);
     }
 }
Пример #4
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)
     {
     }
 }