コード例 #1
0
        //view all parcels in branch(not assigned, each route, pending delivery)

        public void ViewParcelInBranch()
        {
            branchId = staff.BranchId;
            list = RouteController.GetRoutesForBranch(branchId);


            if (comboBox1.SelectedIndex == 0)
            {
                DataTable dt = ParcelController.GetAllInBranchParcels(branchId, branchId);
                DataTable dt1 = new DataTable();

                dt1 = dt.DefaultView.ToTable(
                    true, "tracking_number", "pieces", "weight", "date_created", "sender_name",
                    "sender_phone", "receiver_name", "receiver_phone", "receiver_address",
                    "receiver_location", "receiver_postcode");

                dataGridView1.DataSource = dt1;
                
                changeStatus.Enabled = false;
            }
            else if (comboBox1.SelectedIndex == 1)
            {
                DataTable dt = ParcelController.GetAllInBranchParcels(branchId, null);
                DataTable dt1 = new DataTable();

                dt1 = dt.DefaultView.ToTable(
                    true, "tracking_number", "pieces", "weight", "date_created", "sender_name",
                    "sender_phone", "receiver_name", "receiver_phone", "receiver_address",
                    "receiver_location", "receiver_postcode");

                dataGridView1.DataSource = dt1;
                
                changeStatus.Enabled = true;
            }
            else
            {
                changeStatus.Enabled = false;
            }
            int j = 2;
            for (int i = 0; i < list.Count; i++)
            {
                
                if (comboBox1.SelectedIndex == j)
                {

                    changeStatus.Enabled = true;
                    DataTable dt = ParcelController.GetAllInBranchParcels(branchId, list[i].Id);
                    DataTable dt1 = new DataTable();

                    dt1 = dt.DefaultView.ToTable(
                        true, "tracking_number", "pieces", "weight", "date_created", "sender_name",
                        "sender_phone", "receiver_name", "receiver_phone", "receiver_address",
                        "receiver_location", "receiver_postcode");

                    dataGridView1.DataSource = dt1;
                    

                }
                j++;
            }
        }