コード例 #1
0
ファイル: frmOutput.cs プロジェクト: tayduivn/mdebv
        private void load_grid()
        {
            string mmyy = m.mmyy(s_ngay);
            string sql  = "";

            dataGrid1.DataSource = null;
            dataGrid2.DataSource = null;
            if (m.bMmyy(mmyy))
            {
                string xxx = user + mmyy;
                sql  = "select b.tenkp,sum(1) as tongso,sum(case when a.done is null then 1 else 0 end) as chua,";
                sql += "sum(case when a.done='?' then 1 else 0 end) as dichvu,sum(case when a.done is not null then 1 else 0 end) as xong ";
                sql += " from " + xxx + ".tiepdon a," + user + ".btdkp_bv b where a.makp=b.makp and a.noitiepdon in (0,1,5) and b.loai=1";
                sql += " and to_char(a.ngay,'dd/mm/yyyy')='" + s_ngay + "'";
                //if (makp.SelectedIndex != -1) sql += " and a.makp='" + makp.SelectedValue.ToString() + "'";
                //if (madoituong.SelectedIndex != -1) sql += " and a.madoituong=" + int.Parse(madoituong.SelectedValue.ToString());
                sql += " group by b.tenkp order by b.tenkp";
                dt   = m.get_data(sql).Tables[0];
                dt1  = dt.Clone();
                dt2  = dt.Clone();
                int     i_countrow = dt.Rows.Count;
                DataRow row;
                for (int i = 0; i < i_countrow; i++)
                {
                    if (i <= (i_countrow / 2))
                    {
                        row           = dt1.NewRow();
                        row["tenkp"]  = dt.Rows[i]["tenkp"].ToString();
                        row["tongso"] = int.Parse(dt.Rows[i]["tongso"].ToString());
                        row["chua"]   = int.Parse(dt.Rows[i]["chua"].ToString());
                        row["xong"]   = int.Parse(dt.Rows[i]["xong"].ToString());
                        dt1.Rows.Add(row);
                    }
                    else
                    {
                        row           = dt2.NewRow();
                        row["tenkp"]  = dt.Rows[i]["tenkp"].ToString();
                        row["tongso"] = int.Parse(dt.Rows[i]["tongso"].ToString());
                        row["chua"]   = int.Parse(dt.Rows[i]["chua"].ToString());
                        row["xong"]   = int.Parse(dt.Rows[i]["xong"].ToString());
                        dt2.Rows.Add(row);
                    }
                }
                dataGrid1.DataSource = dt1;
                dataGrid2.DataSource = dt2;
            }
        }