コード例 #1
0
        private void LoadListViewInvoice()
        {
            InvoiceBLL invoiceBLL = new InvoiceBLL();
            DataTable  dataTable  = null;

            if (clickSearch)
            {
                string status = "";
                int    code   = -1;
                if (!txtMadon.Text.Equals(""))
                {
                    code = int.Parse(txtMadon.Text);
                }
                string namecus = txtNameCus.Text;
                if (comboBoxStatus.SelectedItem.Equals("Đang giao hàng"))
                {
                    status = "InComming";
                }
                else if (comboBoxStatus.SelectedItem.Equals("Đã Thanh toán"))
                {
                    status = "Done";
                }
                else if (comboBoxStatus.SelectedItem.Equals("Hủy"))
                {
                    status = "Cancel";
                }

                dataTable = invoiceBLL.Search(status, code, namecus);
            }
            else
            {
                dataTable = invoiceBLL.GetAllInvoice();
            }

            listViewInvoice.Clear();
            listViewInvoice.View          = View.Details;
            listViewInvoice.FullRowSelect = true;

            listViewInvoice.Columns.Add("#", 20);
            listViewInvoice.Columns.Add("Tên khách hàng", 100);
            listViewInvoice.Columns.Add("Số lượng", 20);
            listViewInvoice.Columns.Add("Tổng tiền", 70);
            listViewInvoice.Columns.Add("Ngày tạo", 70);
            listViewInvoice.Columns.Add("Mã bưu điện", 60);
            listViewInvoice.Columns.Add("Status", 60);
            listViewInvoice.Columns.Add("Ghi Chú", 200);
            listViewInvoice.Columns.Add("Địa chỉ giao hàng", 200);

            loadkhaibaoviewdetail();

            ListViewItem lvitem;

            foreach (DataRow row in dataTable.Rows)
            {
                lvitem      = new ListViewItem();
                lvitem.Text = row.Field <int>("Id").ToString();
                string cusname = row.Field <string>("FirstName") + " " + row.Field <string>("LastName");
                lvitem.SubItems.Add(cusname);
                lvitem.SubItems.Add(row.Field <string>("amount"));
                lvitem.SubItems.Add(int.Parse(row.Field <string>("TotalMoney")).ToString("0,0"));
                lvitem.SubItems.Add(row.Field <DateTime>("CreateDay").ToString());
                lvitem.SubItems.Add(row.Field <string>("Postcode"));
                lvitem.SubItems.Add(row.Field <string>("status"));
                lvitem.SubItems.Add(row.Field <string>("Ordernote"));
                lvitem.SubItems.Add(row.Field <string>("CustomerAddress"));

                listViewInvoice.Items.Add(lvitem);
            }
        }