示例#1
0
        private void refresh()
        {
            List <int> w_selMonth = new List <int>();

            w_selMonth.Add(choose_month.SelectedRanges.Start.Month);
            DataTable w_dt = w_model.GetReportPerMonth(choose_month.SelectedRanges.Start.Year, w_selMonth);

            dataGridView1.DataSource = null;
            dataGridView1.DataSource = w_dt;

            foreach (DataGridViewColumn col in dataGridView1.Columns)
            {
                col.HeaderText = w_dt.Columns[col.HeaderText].Caption;
            }
            dataGridView1.Columns[0].Visible = false;
        }
        // when changing is appeared, call this function to refresh form.
        private void refresh()
        {
            int        w_sel_year = date_control.SelectedRanges.Start.Year;
            int        w_termNum  = -1;
            List <int> w_quartes  = new List <int>();

            if (treeView1.Nodes[0].Nodes[0].IsSelected)
            {
                w_quartes.Add(1);
                w_quartes.Add(2);
                w_quartes.Add(3);
                w_termNum = 1;
            }
            if (treeView1.Nodes[0].Nodes[1].IsSelected)
            {
                w_quartes.Add(4);
                w_quartes.Add(5);
                w_quartes.Add(6);
                w_termNum = 2;
            }
            if (treeView1.Nodes[0].Nodes[2].IsSelected)
            {
                w_quartes.Add(7);
                w_quartes.Add(8);
                w_quartes.Add(9);
                w_termNum = 3;
            }
            if (treeView1.Nodes[0].Nodes[3].IsSelected)
            {
                w_quartes.Add(10);
                w_quartes.Add(11);
                w_quartes.Add(12);
                w_termNum = 4;
            }

            if (w_quartes.Count == 0)
            {
                w_quartes.Add(date_control.SelectedRanges.Start.Month);
            }

            DataTable w_dt = new DataTable();

            w_dt = m_modelReport.GetReportPerMonth(w_sel_year, w_quartes);
            DataColumn w_col = w_dt.Columns.Add("Total", typeof(Int32));


            foreach (DataRow w_row in w_dt.Rows)
            {
                int total = 0;
                for (int i = 2; i <= w_dt.Columns.Count - 2; i++)
                {
                    total += (int)w_row[i];
                }
                w_row[w_dt.Columns.Count - 1] = total;
            }
            NewTab w_tab = new NewTab();

            w_tab.m_tab_text = w_sel_year.ToString() + "-" + w_termNum.ToString();
            tab_amount.TabPages.Add(w_tab.create_page(w_dt));
            tab_amount.SelectedTabPage.Refresh();
        }