Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            HSSFWorkbook wb;
            HSSFSheet    sh;


            using (var fs = new FileStream(rTenFile, FileMode.Open, FileAccess.Read))
            {
                wb = new HSSFWorkbook(fs);
            }

            sh = (HSSFSheet)wb.GetSheet(cbo.SelectedValue.ToString());
            int        _DongCuoi = sh.LastRowNum;
            IRow       row;
            daSoNhatKy dSNK = new daSoNhatKy();

            dSNK.SNK.Thang       = byte.Parse(txtThang.Text.Trim());
            dSNK.SNK.Nam         = int.Parse(txtNam.Text.Trim());
            dSNK.SNK.NgayHeThong = DateTime.Now;
            pgb.Maximum          = _DongCuoi;
            for (int i = 1; i <= _DongCuoi; i++)
            {
                row = sh.GetRow(i);
                if (row == null)
                {
                    break;
                }
                dSNK.SNK.NGAY_HT = row.GetCell(0).StringCellValue;
                dSNK.SNK.SO_CT   = row.GetCell(1).StringCellValue;
                dSNK.SNK.NGAY_CT = row.GetCell(2).StringCellValue;
                dSNK.SNK.ND      = row.GetCell(3).StringCellValue;
                dSNK.SNK.TK_NO   = row.GetCell(4).StringCellValue;
                dSNK.SNK.TKE_NO  = row.GetCell(5).StringCellValue;
                dSNK.SNK.DTU_NO  = row.GetCell(6).StringCellValue;
                dSNK.SNK.SP_NO   = row.GetCell(7).StringCellValue;
                dSNK.SNK.TK_CO   = row.GetCell(8).StringCellValue;
                dSNK.SNK.TKE_CO  = row.GetCell(9).StringCellValue;
                dSNK.SNK.DTU_CO  = row.GetCell(10).StringCellValue;
                dSNK.SNK.SP_CO   = row.GetCell(11).StringCellValue;
                try
                {
                    dSNK.SNK.TIEN_NO = row.GetCell(12).NumericCellValue;
                }
                catch { dSNK.SNK.TIEN_NO = 0; }
                try
                {
                    dSNK.SNK.TIEN_CO = row.GetCell(13).NumericCellValue;
                }
                catch { dSNK.SNK.TIEN_CO = 0; }
                dSNK.SNK.MA_DVI  = row.GetCell(14).StringCellValue;
                dSNK.SNK.NOTE    = row.GetCell(15).StringCellValue;
                dSNK.SNK.MaDonVi = "";
                dSNK.SNK.MaNSD   = "";

                dSNK.Them();
                pgb.Value = i;
            }

            MessageBox.Show("Da xong");
        }
        private void DanhSachTongHop2()
        {
            if (slbThang.SelectedItem.Value == null || slbNam.SelectedItem.Value == null)
            {
                return;
            }
            daSoNhatKy dSNK = new daSoNhatKy();

            dSNK.SNK.Thang   = byte.Parse(slbThang.SelectedItem.Value);
            dSNK.SNK.Nam     = int.Parse(slbNam.SelectedItem.Value);
            dSNK.SNK.MaDonVi = txtMaDonVi.Text.Trim();

            bool _NoCo = false;

            if (chkNo.Checked)
            {
                _NoCo = true;
            }

            if (chkCo.Checked)
            {
                _NoCo = false;
            }

            stoSoNhatKyChung.DataSource = dSNK.TongHop2(_NoCo);
            stoSoNhatKyChung.DataBind();
        }
        private void DanhSachChiTiet()
        {
            daSoNhatKy dSNK = new daSoNhatKy();

            dSNK.SNK.Thang   = Thang;
            dSNK.SNK.Nam     = Nam;
            dSNK.SNK.MaDonVi = MaDonVi;
            dSNK.SNK.ND      = ND;
            dSNK.SNK.NGAY_HT = NgayHT;

            stoSoNhatKyChungCT.DataSource = dSNK.DanhSachChiTiet();
            stoSoNhatKyChungCT.DataBind();
        }
        private void DanhSachTongHop1()
        {
            if (slbThang.SelectedItem.Value == null || slbNam.SelectedItem.Value == null)
            {
                return;
            }
            daSoNhatKy dSNK = new daSoNhatKy();

            dSNK.SNK.Thang   = byte.Parse(slbThang.SelectedItem.Value);
            dSNK.SNK.Nam     = int.Parse(slbNam.SelectedItem.Value);
            dSNK.SNK.MaDonVi = txtMaDonVi.Text.Trim();

            stoSoNhatKyChung.DataSource = dSNK.TongHop1();
            stoSoNhatKyChung.DataBind();
        }