Esempio n. 1
0
        private void XuLyBaoCao()
        {
            DataTable dtTemp, dtData = oBNS_GiaoVien.GetBaoCaoChatLuongCanBo((DateTime)dtpDenNgay.EditValue);
            DataView  dvTemp;
            DataRow   dr;

            for (int i = 0; i < dtBaoCao.Rows.Count; i++)
            {
                dr = dtBaoCao.Rows[i];
                if (dr["IDHinhThucHDLD"].ToString() == "BCSN")
                {
                    // Nếu là dr thuộc Biên chế sự nghiệp
                    if (dr["IDNS_LinhVucCongTac"].ToString() == "0")
                    {
                        count            = int.Parse(dtData.Compute("Count(NS_GiaoVienID)", "IDHinhThucHDLD <> 'BCSN'").ToString());
                        dr["TongSo"]     = dtData.Rows.Count - count;
                        dvTemp           = new DataView(dtData);
                        dvTemp.RowFilter = "IDHinhThucHDLD = 'BCSN'";
                        if (dvTemp.Count > 0)
                        {
                            dtTemp = dvTemp.ToTable();
                            SetItemValue(dtTemp, ref dr);
                        }
                    }
                    else
                    {
                        count = int.Parse(dtData.Compute("Count(NS_GiaoVienID)", "IDHinhThucHDLD = 'BCSN' And IDNS_LinhVucCongTac = " +
                                                         dr["IDNS_LinhVucCongTac"]).ToString());
                        if (count > 0)
                        {
                            dr["TongSo"] = count;
                        }
                        dvTemp           = new DataView(dtData);
                        dvTemp.RowFilter = "IDHinhThucHDLD = 'BCSN' And IDNS_LinhVucCongTac = " + dr["IDNS_LinhVucCongTac"];
                        if (dvTemp.Count > 0)
                        {
                            dtTemp = dvTemp.ToTable();
                            SetItemValue(dtTemp, ref dr);
                        }
                    }
                }
                else if (dr["IDHinhThucHDLD"].ToString() != "")
                {
                    // Nếu không phải là Biên chế sự nghiệp
                    if (dr["IDNS_LinhVucCongTac"].ToString() == "0")
                    {
                        count = int.Parse(dtData.Compute("Count(NS_GiaoVienID)", "IDHinhThucHDLD = '" + dr["IDHinhThucHDLD"] + "'").ToString());
                        if (count > 0)
                        {
                            dr["TongSo"] = count;
                        }
                        dvTemp           = new DataView(dtData);
                        dvTemp.RowFilter = "IDHinhThucHDLD = 'TLKP'";
                        if (dvTemp.Count > 0)
                        {
                            dtTemp = dvTemp.ToTable();
                            SetItemValue(dtTemp, ref dr);
                        }
                    }
                    else
                    {
                        count = int.Parse(dtData.Compute("Count(NS_GiaoVienID)", "IDHinhThucHDLD = '" + dr["IDHinhThucHDLD"] +
                                                         "' And IDNS_LinhVucCongTac = " + dr["IDNS_LinhVucCongTac"]).ToString());
                        if (count > 0)
                        {
                            dr["TongSo"] = count;
                        }
                        dvTemp           = new DataView(dtData);
                        dvTemp.RowFilter = "IDHinhThucHDLD = 'TLKP' And IDNS_LinhVucCongTac = " + dr["IDNS_LinhVucCongTac"];
                        if (dvTemp.Count > 0)
                        {
                            dtTemp = dvTemp.ToTable();
                            SetItemValue(dtTemp, ref dr);
                        }
                    }
                }
                else
                {
                    // Nếu là dòng tổng cuối cùng
                    string str;
                    for (int j = 4; j < dtBaoCao.Columns.Count; j++)
                    {
                        str     = dtBaoCao.Columns[j].ColumnName;
                        dr[str] = dtBaoCao.Compute("Sum(" + str + ")", "IDHinhThucHDLD <> '' And IDNS_LinhVucCongTac = 0");
                    }
                }
            }
        }
        private void XuLyTable()
        {
            DataTable dt = oBNS_GiaoVien.GetBaoCaoChatLuongCanBo((DateTime)dtpDenNgay.EditValue);

            if (dt.Rows.Count <= 0)
            {
                return;
            }
            int    TongSoBienChe = 0, DungLopBienChe = 0, PhucVuBienChe = 0;
            int    TongSoNgoaiBienChe = 0, DungLopNgoaiBienChe = 0, PhucVuNgoaiBienChe = 0;
            string ID = dt.Rows[0]["ID"].ToString();

            DataRow drNew = dtBaoCao.NewRow();

            drNew["ID"]             = int.Parse(ID);
            drNew["TenKhoi"]        = "Cao đẳng, TCCN";//dt.Rows[0]["TenKhoi"].ToString();
            drNew["DaiHanTapTrung"] = dt.Rows[0]["DaiHanTapTrung"].ToString();
            drNew["TaiChuc"]        = dt.Rows[0]["TaiChuc"].ToString();
            foreach (DataRow dr in dt.Rows)
            {
                if (ID != dr["ID"].ToString())
                {
                    if (DungLopBienChe > 0)
                    {
                        drNew["DungLopBienChe"] = DungLopBienChe;
                    }
                    if (PhucVuBienChe > 0)
                    {
                        drNew["PhucVuBienChe"] = PhucVuBienChe;
                    }
                    if (TongSoBienChe > 0)
                    {
                        drNew["TongSoBienChe"] = TongSoBienChe;
                    }
                    if (DungLopNgoaiBienChe > 0)
                    {
                        drNew["DungLopNgoaiBienChe"] = DungLopNgoaiBienChe;
                    }
                    if (PhucVuNgoaiBienChe > 0)
                    {
                        drNew["PhucVuNgoaiBienChe"] = PhucVuNgoaiBienChe;
                    }
                    if (TongSoNgoaiBienChe > 0)
                    {
                        drNew["TongSoNgoaiBienChe"] = TongSoNgoaiBienChe;
                    }
                    dtBaoCao.Rows.Add(drNew);

                    DungLopBienChe      = 0;
                    PhucVuBienChe       = 0;
                    TongSoBienChe       = 0;
                    DungLopNgoaiBienChe = 0;
                    PhucVuNgoaiBienChe  = 0;
                    TongSoNgoaiBienChe  = 0;
                    ID                      = dr["ID"].ToString();
                    drNew                   = dtBaoCao.NewRow();
                    drNew["ID"]             = int.Parse(ID);
                    drNew["TenKhoi"]        = "Cao đẳng, TCCN";//dr["TenKhoi"].ToString();
                    drNew["DaiHanTapTrung"] = dt.Rows[0]["DaiHanTapTrung"].ToString();
                    drNew["TaiChuc"]        = dt.Rows[0]["TaiChuc"].ToString();
                }
                if ("" + dr["IDHinhThucHDLD"] == "BCSN")
                {
                    if ("" + dr["IDNS_LinhVucCongTac"] == "1")
                    {
                        DungLopBienChe++;
                    }
                    else
                    {
                        PhucVuBienChe++;
                    }
                    TongSoBienChe++;
                }
                if ("" + dr["IDHinhThucHDLD"] == "TLKP")
                {
                    if ("" + dr["IDNS_LinhVucCongTac"] == "1")
                    {
                        DungLopNgoaiBienChe++;
                    }
                    else
                    {
                        PhucVuNgoaiBienChe++;
                    }
                    TongSoNgoaiBienChe++;
                }
            }
            if (DungLopBienChe > 0)
            {
                drNew["DungLopBienChe"] = DungLopBienChe;
            }
            if (PhucVuBienChe > 0)
            {
                drNew["PhucVuBienChe"] = PhucVuBienChe;
            }
            if (TongSoBienChe > 0)
            {
                drNew["TongSoBienChe"] = TongSoBienChe;
            }
            if (DungLopNgoaiBienChe > 0)
            {
                drNew["DungLopNgoaiBienChe"] = DungLopNgoaiBienChe;
            }
            if (PhucVuNgoaiBienChe > 0)
            {
                drNew["PhucVuNgoaiBienChe"] = PhucVuNgoaiBienChe;
            }
            if (TongSoNgoaiBienChe > 0)
            {
                drNew["TongSoNgoaiBienChe"] = TongSoNgoaiBienChe;
            }

            dtBaoCao.Rows.Add(drNew);
        }