Exemplo n.º 1
0
        public ReportCR(String ReportName, Report_Data Dados, DataSet Ds, int Valor1 = 0)
        {
            InitializeComponent();
            this.Size = new System.Drawing.Size(Properties.Settings.Default.Form_Report_width, Properties.Settings.Default.Form_Report_height);

            crConnectionInfo.ServerName   = Properties.Settings.Default.ServerName;
            crConnectionInfo.DatabaseName = "TributacaoTeste";
            crConnectionInfo.UserID       = gtiCore.Ul;
            crConnectionInfo.Password     = gtiCore.Up;

            ShowReport(ReportName, Dados, Ds, Valor1);
        }
Exemplo n.º 2
0
        public ReportCR(String ReportName, Report_Data Dados, DataSet Ds, int Valor1 = 0)
        {
            InitializeComponent();
            Size = new System.Drawing.Size(gtiCore.Form_Report.Width, gtiCore.Form_Report.Height);

            crConnectionInfo.ServerName   = gtiCore.ServerName;
            crConnectionInfo.DatabaseName = "TributacaoTeste";
            crConnectionInfo.UserID       = gtiCore.Ul;
            crConnectionInfo.Password     = gtiCore.Up;

            ShowReport(ReportName, Dados, Ds, Valor1);
        }
Exemplo n.º 3
0
        private void ImprimirButton_Click(object sender, EventArgs e)
        {
            if (Nome.Text == "")
            {
                MessageBox.Show("Carregue os dados de um contribuinte para poder imprimir a certidão.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Tributario_bll tributario_Class = new Tributario_bll(_connection);
            int            _userId = gtiCore.UserId;
            int            _ano_certidao = DateTime.Now.Year, _numero_certidao = 0, _codigo = Convert.ToInt32(Codigo.Text), _ano_isencao = DateTime.Now.Year;
            decimal        _percisencao = 0, SomaArea = 0;
            DateTime?      _data_processo_isencao = null;
            Report_Data    _dados = null;
            string         _nomeReport = "", _controle = "", _numero_processo = "";

            if (_tipo_certidao == TipoCertidao.Endereco)
            {
                _nomeReport      = "CertidaoEndereco";
                _numero_certidao = tributario_Class.Retorna_Codigo_Certidao(modelCore.TipoCertidao.Endereco);
                _controle        = _numero_certidao.ToString("00000") + _ano_certidao.ToString("0000") + "/" + _codigo.ToString() + "-EA";
                Certidao_endereco cert = new Certidao_endereco {
                    Codigo      = Convert.ToInt32(_codigo),
                    Ano         = _ano_certidao,
                    Numero      = _numero_certidao,
                    Data        = DateTime.Now,
                    Inscricao   = Inscricao.Text,
                    Nomecidadao = Nome.Text,
                    Logradouro  = Endereco.Text,
                    descbairro  = Bairro.Text,
                    Li_quadras  = Quadra.Text,
                    Li_lotes    = Lote.Text
                };
                Exception ex = tributario_Class.Insert_Certidao_Endereco(cert);
                if (ex != null)
                {
                    throw ex;
                }
            }
            else
            {
                if (_tipo_certidao == TipoCertidao.Isencao)
                {
                    Imovel_bll imovel_Class = new Imovel_bll(_connection);
                    bool       bImune       = imovel_Class.Verifica_Imunidade(_codigo);
                    _numero_certidao = tributario_Class.Retorna_Codigo_Certidao(modelCore.TipoCertidao.Isencao);
                    _controle        = _numero_certidao.ToString("00000") + _ano_certidao.ToString("0000") + "/" + _codigo.ToString() + "-CI";

                    if (bImune)
                    {
                        _percisencao = 100;
                        _nomeReport  = "CertidaoImunidade";
                    }
                    else
                    {
                        bool bIsentoProcesso = false;
                        List <IsencaoStruct> ListaIsencao = null;
                        ListaIsencao = imovel_Class.Lista_Imovel_Isencao(_codigo, DateTime.Now.Year);
                        if (ListaIsencao.Count > 0)
                        {
                            bIsentoProcesso = true;
                        }
                        if (bIsentoProcesso)
                        {
                            _nomeReport            = "CertidaoIsencaoProcesso";
                            _percisencao           = (decimal)ListaIsencao[0].Percisencao;
                            _numero_processo       = ListaIsencao[0].Numprocesso;
                            _data_processo_isencao = Convert.ToDateTime(ListaIsencao[0].dataprocesso);
                        }
                        else
                        {
                            SomaArea = imovel_Class.Soma_Area(_codigo);
                            if (SomaArea < 65)
                            {
                                //Se tiver área < 65m² mas tiver mais de 1 imóvel, perde a isenção.
                                int nQtdeImovel = imovel_Class.Qtde_Imovel_Cidadao(_codigo);
                                if (nQtdeImovel > 1)
                                {
                                    MessageBox.Show("Este imóvel não esta isento da cobrança de IPTU no ano atual.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                                _nomeReport = "CertidaoIsencao65";
                            }
                        }
                    }

                    Certidao_isencao cert = new Certidao_isencao {
                        Codigo       = _codigo,
                        Ano          = _ano_certidao,
                        Numero       = _numero_certidao,
                        Data         = DateTime.Now,
                        Inscricao    = Inscricao.Text,
                        Nomecidadao  = Nome.Text,
                        Logradouro   = Endereco.Text,
                        Descbairro   = Bairro.Text,
                        Li_quadras   = Quadra.Text,
                        Li_lotes     = Lote.Text,
                        Area         = SomaArea,
                        Percisencao  = _percisencao,
                        Numprocesso  = _numero_processo,
                        Dataprocesso = _data_processo_isencao
                    };
                    Exception ex = tributario_Class.Insert_Certidao_Isencao(cert);
                    if (ex != null)
                    {
                        throw ex;
                    }
                }
                else
                {
                    if (_tipo_certidao == TipoCertidao.ValorVenal)
                    {
                        _nomeReport      = "CertidaoValorVenal";
                        _numero_certidao = tributario_Class.Retorna_Codigo_Certidao(modelCore.TipoCertidao.ValorVenal);
                        _controle        = _numero_certidao.ToString("00000") + _ano_certidao.ToString("0000") + "/" + _codigo.ToString() + "-VV";
                        Certidao_valor_venal cert = new Certidao_valor_venal {
                            Codigo      = Convert.ToInt32(_codigo),
                            Ano         = _ano_certidao,
                            Numero      = _numero_certidao,
                            Data        = DateTime.Now,
                            Inscricao   = Inscricao.Text,
                            Nomecidadao = Nome.Text,
                            Logradouro  = Endereco.Text,
                            Descbairro  = Bairro.Text,
                            Li_quadras  = Quadra.Text,
                            Li_lotes    = Lote.Text
                        };
                        Exception ex = tributario_Class.Insert_Certidao_ValorVenal(cert);
                        if (ex != null)
                        {
                            throw ex;
                        }
                    }
                    else
                    {
                        if (_tipo_certidao == TipoCertidao.Debito)
                        {
                            //***Verifica débito
                            Certidao_debito_detalhe dadosCertidao = tributario_Class.Certidao_Debito(_codigo);
                            if (dadosCertidao.Tipo_Retorno == RetornoCertidaoDebito.Negativa)
                            {
                                sTipoCertidao = "NEGATIVA";
                                sNao          = "não ";
                                nRet          = 3;
                                sSufixo       = "CN";
                                if (_tipo_cadastro == TipoCadastro.Imovel)
                                {
                                    _nomeReport = "CertidaoDebitoImovel";
                                }
                                else
                                {
                                    if (_tipo_cadastro == TipoCadastro.Empresa)
                                    {
                                        _nomeReport = "CertidaoDebitoEmpresa";
                                    }
                                }
                            }
                            else
                            {
                                if (dadosCertidao.Tipo_Retorno == RetornoCertidaoDebito.Positiva)
                                {
                                    sTipoCertidao = "POSITIVA";
                                    nRet          = 4;
                                    sSufixo       = "CP";
                                    if (_tipo_cadastro == TipoCadastro.Imovel)
                                    {
                                        _nomeReport = "CertidaoDebitoImovel";
                                    }
                                    else
                                    {
                                        if (_tipo_cadastro == TipoCadastro.Empresa)
                                        {
                                            _nomeReport = "CertidaoDebitoEmpresa";
                                        }
                                    }
                                }
                                else
                                {
                                    if (dadosCertidao.Tipo_Retorno == RetornoCertidaoDebito.NegativaPositiva)
                                    {
                                        sTipoCertidao = "POSITIVA COM EFEITO NEGATIVA";
                                        nRet          = 5;
                                        sSufixo       = "PN";
                                        if (_tipo_cadastro == TipoCadastro.Imovel)
                                        {
                                            _nomeReport = "CertidaoDebitoImovelPN";
                                        }
                                        else
                                        {
                                            if (_tipo_cadastro == TipoCadastro.Empresa)
                                            {
                                                _nomeReport = "CertidaoDebitoEmpresaPN";
                                            }
                                        }
                                    }
                                }
                            }
                            sTributo = dadosCertidao.Descricao_Lancamentos;

                            _numero_certidao = tributario_Class.Retorna_Codigo_Certidao(modelCore.TipoCertidao.Debito);
                            _controle        = _numero_certidao.ToString("00000") + _ano_certidao.ToString("0000") + "/" + _codigo.ToString() + "-" + sSufixo;
                            Certidao_debito cert = new Certidao_debito {
                                Codigo       = Convert.ToInt32(_codigo),
                                Ano          = (short)_ano_certidao,
                                Ret          = nRet,
                                Numero       = _numero_certidao,
                                Datagravada  = DateTime.Now,
                                Inscricao    = Inscricao.Text,
                                Nome         = Nome.Text,
                                Logradouro   = Endereco.Text,
                                Bairro       = Bairro.Text,
                                Cidade       = Cidade.Text,
                                Processo     = Processo.Text,
                                Dataprocesso = _data_processo,
                                Atendente    = gtiCore.LastUser,
                                Cpf          = sCPF,
                                Cnpj         = sCNPJ,
                                Atividade    = Atividade.Text,
                                Lancamento   = dadosCertidao.Descricao_Lancamentos
                            };
                            Exception ex = tributario_Class.Insert_Certidao_Debito(cert);
                            if (ex != null)
                            {
                                throw ex;
                            }
                        }
                    }
                }

                if (_numero_certidao > 0)
                {
                    _dados = new Report_Data()
                    {
                        Codigo                = Convert.ToInt32(Codigo.Text),
                        Inscricao             = Inscricao.Text,
                        Nome                  = Nome.Text,
                        Cpf_cnpj              = Doc.Text,
                        Endereco              = Endereco.Text,
                        Nome_bairro           = Bairro.Text,
                        Quadra_original       = Quadra.Text,
                        Lote_original         = Lote.Text,
                        Nome_cidade           = Cidade.Text,
                        Cep                   = Cep.Text,
                        Numero_Certidao       = _numero_certidao.ToString("000000") + "/" + _ano_certidao.ToString(),
                        Controle              = _controle,
                        Assinatura_Hide       = Assinatura.Checked,
                        Processo              = Processo.Text,
                        Data_Processo         = _data_processo,
                        UserId                = _userId,
                        Perc_Isencao          = _percisencao,
                        Data_Processo_Isencao = _data_processo_isencao,
                        Processo_Isencao      = _numero_processo,
                        AnoIsencao            = _ano_isencao,
                        Area                  = SomaArea,
                        Nao                   = sNao,
                        TipoCertidao          = sTipoCertidao,
                        Tributos              = sTributo,
                        Atividade             = sAtividade
                    };
                    //ReportCR fRpt = new ReportCR(_nomeReport, _dados,null);
                    //fRpt.ShowDialog();
                    ClearFields();
                }
            }
        }
Exemplo n.º 4
0
        private void ShowReport(String _nome, Report_Data _dados, DataSet Ds, int Valor1)
        {
            crViewer.ToolPanelView = CrystalDecisions.Windows.Forms.ToolPanelViewType.None;
            string _usuario = Properties.Settings.Default.LastUser;

            switch (_nome)
            {
            case "CertidaoEndereco":
                Text = "Certidão de Endereço";
                CertidaoEndereco rpt_endereco = new CertidaoEndereco();
                rpt_endereco.SetDatabaseLogon(gtiCore.Ul, gtiCore.Up, Properties.Settings.Default.ServerName, Properties.Settings.Default.DataBaseReal);
                rpt_endereco.SetParameterValue("NUMCERTIDAO", _dados.Numero_Certidao);
                rpt_endereco.SetParameterValue("DATAEMISSAO", DateTime.Now);
                rpt_endereco.SetParameterValue("CONTROLE", _dados.Controle);
                rpt_endereco.SetParameterValue("BAIRRO", _dados.Nome_bairro);
                rpt_endereco.SetParameterValue("ENDERECO", _dados.Endereco);
                rpt_endereco.SetParameterValue("CADASTRO", _dados.Codigo);
                rpt_endereco.SetParameterValue("INSCRICAO", _dados.Inscricao);
                rpt_endereco.SetParameterValue("NOME", _dados.Nome);
                rpt_endereco.SetParameterValue("PROCESSO", _dados.Processo);
                rpt_endereco.SetParameterValue("DATAPROCESSO", _dados.Data_Processo);
                rpt_endereco.SetParameterValue("QUADRA", _dados.Quadra_original);
                rpt_endereco.SetParameterValue("LOTE", _dados.Lote_original);
                rpt_endereco.SetParameterValue("DOCUMENTO", _dados.Cpf_cnpj ?? "");
                rpt_endereco.RecordSelectionFormula = "{Assinatura.Usuario}='" + _usuario + "'";
                crViewer.ReportSource = rpt_endereco;
                break;

            case "CertidaoImunidade":
                Text = "Certidão de Isenção";
                CertidaoImunidade rpt_imunidade = new CertidaoImunidade();
                rpt_imunidade.SetDatabaseLogon(gtiCore.Ul, gtiCore.Up, Properties.Settings.Default.ServerName, Properties.Settings.Default.DataBaseReal);
                rpt_imunidade.SetParameterValue("NUMCERTIDAO", _dados.Numero_Certidao);
                rpt_imunidade.SetParameterValue("DATAEMISSAO", DateTime.Now);
                rpt_imunidade.SetParameterValue("CONTROLE", _dados.Controle);
                rpt_imunidade.SetParameterValue("BAIRRO", _dados.Nome_bairro);
                rpt_imunidade.SetParameterValue("ENDERECO", _dados.Endereco);
                rpt_imunidade.SetParameterValue("CADASTRO", _dados.Codigo);
                rpt_imunidade.SetParameterValue("INSCRICAO", _dados.Inscricao);
                rpt_imunidade.SetParameterValue("NOME", _dados.Nome);
                rpt_imunidade.SetParameterValue("PROCESSO", _dados.Processo);
                rpt_imunidade.SetParameterValue("DATAPROCESSO", _dados.Data_Processo);
                rpt_imunidade.SetParameterValue("ANO", _dados.AnoIsencao);
                rpt_imunidade.SetParameterValue("AREA", _dados.Area);
                rpt_imunidade.SetParameterValue("PERC", _dados.Perc_Isencao);
                rpt_imunidade.SetParameterValue("DOC", _dados.Cpf_cnpj ?? "");
                rpt_imunidade.RecordSelectionFormula = "{Assinatura.Usuario}='" + _usuario + "'";
                crViewer.ReportSource = rpt_imunidade;
                break;

            case "CertidaoIsencaoProcesso":
                Text = "Certidão de Isenção";
                CertidaoIsencaoProcesso rpt_isencao = new CertidaoIsencaoProcesso();
                rpt_isencao.SetDatabaseLogon(gtiCore.Ul, gtiCore.Up, Properties.Settings.Default.ServerName, Properties.Settings.Default.DataBaseReal);
                rpt_isencao.SetParameterValue("NUMCERTIDAO", _dados.Numero_Certidao);
                rpt_isencao.SetParameterValue("DATAEMISSAO", DateTime.Now);
                rpt_isencao.SetParameterValue("CONTROLE", _dados.Controle);
                rpt_isencao.SetParameterValue("BAIRRO", _dados.Nome_bairro);
                rpt_isencao.SetParameterValue("ENDERECO", _dados.Endereco);
                rpt_isencao.SetParameterValue("CADASTRO", _dados.Codigo);
                rpt_isencao.SetParameterValue("INSCRICAO", _dados.Inscricao);
                rpt_isencao.SetParameterValue("NOME", _dados.Nome);
                rpt_isencao.SetParameterValue("NUMPROCESSO", _dados.Processo);
                rpt_isencao.SetParameterValue("DATAPROCESSO", _dados.Data_Processo);
                rpt_isencao.SetParameterValue("NUMPROCESSOISENCAO", _dados.Processo_Isencao);
                rpt_isencao.SetParameterValue("DATAPROCESSOISENCAO", _dados.Data_Processo_Isencao);
                rpt_isencao.SetParameterValue("ANO", _dados.AnoIsencao);
                rpt_isencao.SetParameterValue("AREA", _dados.Area);
                rpt_isencao.SetParameterValue("PERC", _dados.Perc_Isencao);
                rpt_isencao.SetParameterValue("DOC", _dados.Cpf_cnpj ?? "");
                rpt_isencao.RecordSelectionFormula = "{Assinatura.Usuario}='" + _usuario + "'";
                crViewer.ReportSource = rpt_isencao;
                break;

            case "CertidaoIsencao65":
                Text = "Certidão de Isenção";
                CertidaoIsencao65 rpt_isencao65 = new CertidaoIsencao65();
                rpt_isencao65.SetDatabaseLogon(gtiCore.Ul, gtiCore.Up, Properties.Settings.Default.ServerName, Properties.Settings.Default.DataBaseReal);
                rpt_isencao65.SetParameterValue("NUMCERTIDAO", _dados.Numero_Certidao);
                rpt_isencao65.SetParameterValue("DATAEMISSAO", DateTime.Now);
                rpt_isencao65.SetParameterValue("CONTROLE", _dados.Controle);
                rpt_isencao65.SetParameterValue("BAIRRO", _dados.Nome_bairro);
                rpt_isencao65.SetParameterValue("ENDERECO", _dados.Endereco);
                rpt_isencao65.SetParameterValue("CADASTRO", _dados.Codigo);
                rpt_isencao65.SetParameterValue("INSCRICAO", _dados.Inscricao);
                rpt_isencao65.SetParameterValue("NOME", _dados.Nome);
                rpt_isencao65.SetParameterValue("NUMPROCESSO", _dados.Processo);
                rpt_isencao65.SetParameterValue("DATAPROCESSO", _dados.Data_Processo);
                rpt_isencao65.SetParameterValue("ANO", _dados.AnoIsencao);
                rpt_isencao65.SetParameterValue("AREA", _dados.Area);
                rpt_isencao65.SetParameterValue("PERC", _dados.Perc_Isencao);
                rpt_isencao65.SetParameterValue("DOC", _dados.Cpf_cnpj ?? "");
                rpt_isencao65.RecordSelectionFormula = "{Assinatura.Usuario}='" + _usuario + "'";
                crViewer.ReportSource = rpt_isencao65;
                break;

            case "CertidaoValorVenal":
                Text = "Certidão de Valor Venal";
                CertidaoValorVenal rpt_vvenal       = new CertidaoValorVenal();
                Tributario_bll     tributario_Class = new Tributario_bll(_connection);
                SpCalculo          RegCalculo       = tributario_Class.Calculo_IPTU(Convert.ToInt32(_dados.Codigo), DateTime.Now.Year);
                rpt_vvenal.SetDatabaseLogon(gtiCore.Ul, gtiCore.Up, Properties.Settings.Default.ServerName, Properties.Settings.Default.DataBaseReal);
                rpt_vvenal.SetParameterValue("NUMCERTIDAO", _dados.Numero_Certidao);
                rpt_vvenal.SetParameterValue("DATAEMISSAO", DateTime.Now);
                rpt_vvenal.SetParameterValue("CONTROLE", _dados.Controle);
                rpt_vvenal.SetParameterValue("BAIRRO", _dados.Nome_bairro);
                rpt_vvenal.SetParameterValue("ENDERECO", _dados.Endereco);
                rpt_vvenal.SetParameterValue("CADASTRO", _dados.Codigo);
                rpt_vvenal.SetParameterValue("INSCRICAO", _dados.Inscricao);
                rpt_vvenal.SetParameterValue("NOME", _dados.Nome);
                rpt_vvenal.SetParameterValue("PROCESSO", _dados.Processo);
                rpt_vvenal.SetParameterValue("DATAPROCESSO", _dados.Data_Processo);
                rpt_vvenal.SetParameterValue("QUADRA", _dados.Quadra_original);
                rpt_vvenal.SetParameterValue("LOTE", _dados.Lote_original);
                rpt_vvenal.SetParameterValue("DOCUMENTO", _dados.Cpf_cnpj ?? "");
                rpt_vvenal.SetParameterValue("VVT", RegCalculo.Vvt);
                rpt_vvenal.SetParameterValue("VVP", RegCalculo.Vvp);
                rpt_vvenal.SetParameterValue("VVI", RegCalculo.Vvi);
                rpt_vvenal.RecordSelectionFormula = "{Assinatura.Usuario}='" + _usuario + "'";
                crViewer.ReportSource             = rpt_vvenal;
                break;

            case "CertidaoDebitoImovel":
                Text = "Certidão de Débito";
                CertidaoDebitoImovel rpt_cdebitoimovel = new CertidaoDebitoImovel();
                rpt_cdebitoimovel.SetDatabaseLogon(gtiCore.Ul, gtiCore.Up, Properties.Settings.Default.ServerName, Properties.Settings.Default.DataBaseReal);
                rpt_cdebitoimovel.SetParameterValue("NUMCERTIDAO", _dados.Numero_Certidao);
                rpt_cdebitoimovel.SetParameterValue("DATAEMISSAO", DateTime.Now);
                rpt_cdebitoimovel.SetParameterValue("CONTROLE", _dados.Controle);
                rpt_cdebitoimovel.SetParameterValue("BAIRRO", _dados.Nome_bairro);
                rpt_cdebitoimovel.SetParameterValue("ENDERECO", _dados.Endereco);
                rpt_cdebitoimovel.SetParameterValue("CADASTRO", _dados.Codigo);
                rpt_cdebitoimovel.SetParameterValue("INSCRICAO", _dados.Inscricao);
                rpt_cdebitoimovel.SetParameterValue("NOME", _dados.Nome);
                rpt_cdebitoimovel.SetParameterValue("TIPOCERTIDAO", _dados.TipoCertidao);
                rpt_cdebitoimovel.SetParameterValue("TRIBUTO", _dados.Tributos);
                rpt_cdebitoimovel.SetParameterValue("NAO", _dados.Nao);
                rpt_cdebitoimovel.SetParameterValue("ATIVIDADE", _dados.Atividade);
                rpt_cdebitoimovel.SetParameterValue("CIDADE", _dados.Nome_cidade);
                rpt_cdebitoimovel.SetParameterValue("PROCESSO", _dados.Processo);
                rpt_cdebitoimovel.SetParameterValue("DATAPROCESSO", _dados.Data_Processo);
                rpt_cdebitoimovel.SetParameterValue("DOCUMENTO", _dados.Cpf_cnpj ?? "");
                rpt_cdebitoimovel.RecordSelectionFormula = "{Assinatura.Usuario}='" + _usuario + "'";
                crViewer.ReportSource = rpt_cdebitoimovel;
                break;

            case "CertidaoDebitoEmpresa":
                Text = "Certidão de Débito";
                CertidaoDebitoEmpresa rpt_cdebitoempresa = new CertidaoDebitoEmpresa();
                rpt_cdebitoempresa.SetDatabaseLogon(gtiCore.Ul, gtiCore.Up, Properties.Settings.Default.ServerName, Properties.Settings.Default.DataBaseReal);
                rpt_cdebitoempresa.SetParameterValue("NUMCERTIDAO", _dados.Numero_Certidao);
                rpt_cdebitoempresa.SetParameterValue("DATAEMISSAO", DateTime.Now);
                rpt_cdebitoempresa.SetParameterValue("CONTROLE", _dados.Controle);
                rpt_cdebitoempresa.SetParameterValue("BAIRRO", _dados.Nome_bairro);
                rpt_cdebitoempresa.SetParameterValue("ENDERECO", _dados.Endereco);
                rpt_cdebitoempresa.SetParameterValue("CADASTRO", _dados.Codigo);
                rpt_cdebitoempresa.SetParameterValue("INSCRICAO", _dados.Inscricao);
                rpt_cdebitoempresa.SetParameterValue("NOME", _dados.Nome);
                rpt_cdebitoempresa.SetParameterValue("TIPOCERTIDAO", _dados.TipoCertidao);
                rpt_cdebitoempresa.SetParameterValue("TRIBUTO", _dados.Tributos);
                rpt_cdebitoempresa.SetParameterValue("NAO", _dados.Nao);
                rpt_cdebitoempresa.SetParameterValue("ATIVIDADE", _dados.Atividade);
                rpt_cdebitoempresa.SetParameterValue("CIDADE", _dados.Nome_cidade);
                rpt_cdebitoempresa.SetParameterValue("PROCESSO", _dados.Processo);
                rpt_cdebitoempresa.SetParameterValue("DATAPROCESSO", _dados.Data_Processo);
                rpt_cdebitoempresa.SetParameterValue("DOCUMENTO", _dados.Cpf_cnpj ?? "");
                rpt_cdebitoempresa.RecordSelectionFormula = "{Assinatura.Usuario}='" + _usuario + "'";
                crViewer.ReportSource = rpt_cdebitoempresa;
                break;

            case "CertidaoDebitoImovelPN":
                Text = "Certidão de Débito";
                CertidaoDebitoImovelPN rpt_cdebitoimovelpn = new CertidaoDebitoImovelPN();
                rpt_cdebitoimovelpn.SetDatabaseLogon(gtiCore.Ul, gtiCore.Up, Properties.Settings.Default.ServerName, Properties.Settings.Default.DataBaseReal);
                rpt_cdebitoimovelpn.SetParameterValue("NUMCERTIDAO", _dados.Numero_Certidao);
                rpt_cdebitoimovelpn.SetParameterValue("DATAEMISSAO", DateTime.Now);
                rpt_cdebitoimovelpn.SetParameterValue("CONTROLE", _dados.Controle);
                rpt_cdebitoimovelpn.SetParameterValue("BAIRRO", _dados.Nome_bairro);
                rpt_cdebitoimovelpn.SetParameterValue("ENDERECO", _dados.Endereco);
                rpt_cdebitoimovelpn.SetParameterValue("CADASTRO", _dados.Codigo);
                rpt_cdebitoimovelpn.SetParameterValue("INSCRICAO", _dados.Inscricao);
                rpt_cdebitoimovelpn.SetParameterValue("NOME", _dados.Nome);
                rpt_cdebitoimovelpn.SetParameterValue("TIPOCERTIDAO", _dados.TipoCertidao);
                rpt_cdebitoimovelpn.SetParameterValue("TRIBUTO", _dados.Tributos);
                rpt_cdebitoimovelpn.SetParameterValue("NAO", _dados.Nao);
                rpt_cdebitoimovelpn.SetParameterValue("ATIVIDADE", _dados.Atividade);
                rpt_cdebitoimovelpn.SetParameterValue("CIDADE", _dados.Nome_cidade);
                rpt_cdebitoimovelpn.SetParameterValue("PROCESSO", _dados.Processo);
                rpt_cdebitoimovelpn.SetParameterValue("DATAPROCESSO", _dados.Data_Processo);
                rpt_cdebitoimovelpn.SetParameterValue("DOCUMENTO", _dados.Cpf_cnpj ?? "");
                rpt_cdebitoimovelpn.RecordSelectionFormula = "{Assinatura.Usuario}='" + _usuario + "'";
                crViewer.ReportSource = rpt_cdebitoimovelpn;
                break;

            case "CertidaoDebitoEmpresapn":
                Text = "Certidão de Débito";
                CertidaoDebitoEmpresaPN rpt_cdebitoempresapn = new CertidaoDebitoEmpresaPN();
                rpt_cdebitoempresapn.SetDatabaseLogon(gtiCore.Ul, gtiCore.Up, Properties.Settings.Default.ServerName, Properties.Settings.Default.DataBaseReal);
                rpt_cdebitoempresapn.SetParameterValue("NUMCERTIDAO", _dados.Numero_Certidao);
                rpt_cdebitoempresapn.SetParameterValue("DATAEMISSAO", DateTime.Now);
                rpt_cdebitoempresapn.SetParameterValue("CONTROLE", _dados.Controle);
                rpt_cdebitoempresapn.SetParameterValue("BAIRRO", _dados.Nome_bairro);
                rpt_cdebitoempresapn.SetParameterValue("ENDERECO", _dados.Endereco);
                rpt_cdebitoempresapn.SetParameterValue("CADASTRO", _dados.Codigo);
                rpt_cdebitoempresapn.SetParameterValue("INSCRICAO", _dados.Inscricao);
                rpt_cdebitoempresapn.SetParameterValue("NOME", _dados.Nome);
                rpt_cdebitoempresapn.SetParameterValue("TIPOCERTIDAO", _dados.TipoCertidao);
                rpt_cdebitoempresapn.SetParameterValue("TRIBUTO", _dados.Tributos);
                rpt_cdebitoempresapn.SetParameterValue("NAO", _dados.Nao);
                rpt_cdebitoempresapn.SetParameterValue("ATIVIDADE", _dados.Atividade);
                rpt_cdebitoempresapn.SetParameterValue("CIDADE", _dados.Nome_cidade);
                rpt_cdebitoempresapn.SetParameterValue("PROCESSO", _dados.Processo);
                rpt_cdebitoempresapn.SetParameterValue("DATAPROCESSO", _dados.Data_Processo);
                rpt_cdebitoempresapn.SetParameterValue("DOCUMENTO", _dados.Cpf_cnpj ?? "");
                rpt_cdebitoempresapn.RecordSelectionFormula = "{Assinatura.Usuario}='" + _usuario + "'";
                crViewer.ReportSource = rpt_cdebitoempresapn;
                break;

            case "Carta_Cobranca_Envelope":
                Carta_Cobranca_Envelope rpt_carta_cobranca_envelope = new Carta_Cobranca_Envelope();
                CrTables = rpt_carta_cobranca_envelope.Database.Tables;
                foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
                {
                    crtableLogoninfo = CrTable.LogOnInfo;
                    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                    CrTable.ApplyLogOnInfo(crtableLogoninfo);
                }
                rpt_carta_cobranca_envelope.RecordSelectionFormula = "{Carta_Cobranca.Remessa}=" + Valor1;
                crViewer.ReportSource = rpt_carta_cobranca_envelope;
                break;

            case "Comunicado_Isencao":
                ComunicadoIsencao rpt_comunicado_Isencao = new GTI_Desktop.Report.ComunicadoIsencao();
                CrTables = rpt_comunicado_Isencao.Database.Tables;
                foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
                {
                    crtableLogoninfo = CrTable.LogOnInfo;
                    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                    CrTable.ApplyLogOnInfo(crtableLogoninfo);
                }
                rpt_comunicado_Isencao.RecordSelectionFormula = "{Comunicado_isencao.Remessa}=" + Valor1;
                crViewer.ReportSource = rpt_comunicado_Isencao;
                break;

            default:
                break;
            }
        }//End showReport
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Request["seedkey"] != null)
            {
                seedkey = this.Request["seedkey"].ToInt();
            }
            if (this.Request["from"] != null)
            {
                FromDate = DateTime.ParseExact(this.Request["from"], "d/M/yyyy", CultureInfo.InvariantCulture);
            }
            if (this.Request["to"] != null)
            {
                ToDate = DateTime.ParseExact(this.Request["to"], "d/M/yyyy", CultureInfo.InvariantCulture);
            }
            int memberID = HttpContext.Current.Session["MemberID"].ToInt();

            if (memberID != 0)
            {
                string NameSeed = "";
                TNLibrary.Book.Member_Info minfo = new TNLibrary.Book.Member_Info(memberID);

                MemoryStream ms       = new MemoryStream();
                Document     document = new Document(iTextSharp.text.PageSize.A4.Rotate(), 66, 36, 54, 54);
                PdfWriter    writer   = PdfWriter.GetInstance(document, ms);
                BaseFont     bfTimes  = BaseFont.CreateFont("c:\\windows\\fonts\\times.ttf", BaseFont.IDENTITY_H, false);

                Font fontHeader = new Font(bfTimes, 12, Font.BOLD);
                Font fontNormal = new Font(bfTimes, 11);
                Font fontozel   = new Font(bfTimes, 12, Font.NORMAL);
                writer.PageEvent = new PDFFooter();


                document.Open();
                if (seedkey.ToInt() == 0)
                {
                    NameSeed = "_Tatca";
                    DataTable sTable = Report_Data.SeedProcessListReport(memberID, FromDate, ToDate);
                    if (sTable != null)
                    {
                        for (int j = 0; j < sTable.Rows.Count; j++)
                        {
                            seedkey = sTable.Rows[j]["SeedsKey"].ToInt();
                            Seed_Info sinfo  = new Seed_Info(seedkey.ToInt());
                            Paragraph header = new Paragraph(@"SỔ NHẬT KÝ SẢN XUẤT", new Font(bfTimes, 40, Font.BOLD));
                            header.Alignment    = Element.ALIGN_CENTER;
                            header.SpacingAfter = 20;
                            document.Add(header);
                            Paragraph header1 = new Paragraph(@"Năm............", new Font(bfTimes, 20, Font.NORMAL));
                            header1.Alignment    = Element.ALIGN_CENTER;
                            header1.SpacingAfter = 170;
                            document.Add(header1);
                            document.Add(new Paragraph(@"NÔNG HỘ: " + minfo.Name, new Font(bfTimes, 20, Font.BOLD)));
                            document.Add(new Paragraph(@"MÃ SỐ: " + minfo.MemID, new Font(bfTimes, 20, Font.BOLD)));
                            document.NewPage();
                            Paragraph Text1 = new Paragraph(@"PHẦN SẢN XUẤT", new Font(bfTimes, 30, Font.BOLD));
                            Text1.Alignment = Element.ALIGN_CENTER;
                            document.Add(Text1);
                            Paragraph Text2 = new Paragraph(@"Cây trồng: " + sinfo.SeedsName, new Font(bfTimes, 25, Font.NORMAL));
                            Text2.Alignment = Element.ALIGN_CENTER;
                            document.Add(Text2);
                            Paragraph Text3 = new Paragraph(@"Từ " + this.Request["from"] + " đến " + this.Request["to"], new Font(bfTimes, 25, Font.NORMAL));
                            Text3.Alignment = Element.ALIGN_CENTER;
                            document.Add(Text3);
                            document.NewPage();
                            #region [ Quản lý giống ]
                            if (1 == 1)
                            {
                                Paragraph para = new Paragraph(@"QUẢN LÝ GIỐNG", new Font(bfTimes, 30, Font.BOLD));
                                para.Alignment    = Element.ALIGN_CENTER;
                                para.SpacingAfter = 20;
                                document.Add(para);

                                PdfPTable mainTable = new PdfPTable(6);
                                mainTable.WidthPercentage = 100;

                                mainTable.SetWidths(new int[] { 15, 20, 15, 15, 15, 20 });
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên Giống", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nhà sản xuất/Phân phối (Nguồn gốc giống)", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày trồng", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Mã số lô", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Diện tích", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng lượng giống", fontHeader), 1));
                                DataTable nTable = Report_Data.SeedProcessReport(memberID, seedkey.ToInt(), FromDate, ToDate);
                                if (nTable != null)
                                {
                                    for (int i = 0; i < nTable.Rows.Count; i++)
                                    {
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["CompanyName"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Parcel"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Area"].ToString() + " " + nTable.Rows[i]["UnitArea"].ToString(), fontozel), 1));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["UnitQuantity"].ToString(), fontozel), 1));
                                    }
                                }

                                document.Add(mainTable);
                            }
                            #endregion
                            #region [ Quản lý ủ phân hữu cơ ]
                            if (1 == 1)
                            {
                                Paragraph para = new Paragraph(@"QUẢN LÝ Ủ PHÂN HỮU CƠ", new Font(bfTimes, 30, Font.BOLD));
                                para.Alignment    = Element.ALIGN_CENTER;
                                para.SpacingAfter = 20;
                                document.Add(para);

                                PdfPTable mainTable = new PdfPTable(5);
                                mainTable.WidthPercentage = 100;

                                mainTable.SetWidths(new int[] { 15, 10, 45, 15, 15 });
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Loại phân", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Khối lượng", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Phương pháp ủ", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Thời gian ủ", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Người thực hiện", fontHeader), 1));
                                DataTable nTable = Report_Data.CompostingOrganicReport(memberID, seedkey.ToInt(), FromDate, ToDate);
                                if (nTable != null)
                                {
                                    for (int i = 0; i < nTable.Rows.Count; i++)
                                    {
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Method"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["CompostingDates"].ToString() + " ngày", fontozel), 1));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Member_Name"].ToString(), fontozel), 0));
                                    }
                                }

                                document.Add(mainTable);
                                document.NewPage();
                            }
                            #endregion
                            #region [ Quản lý Mua phân/hóa chất ]
                            if (1 == 1)
                            {
                                Paragraph para = new Paragraph(@"QUẢN LÝ MUA PHÂN BÓN, HÓA CHẤT", new Font(bfTimes, 30, Font.BOLD));
                                para.Alignment    = Element.ALIGN_CENTER;
                                para.SpacingAfter = 20;
                                document.Add(para);

                                PdfPTable mainTable = new PdfPTable(6);
                                mainTable.WidthPercentage = 100;

                                mainTable.SetWidths(new int[] { 10, 15, 25, 25, 15, 10 });
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày mua", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên thương mại", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Thành phần/ Hoạt chất", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nhà sản xuất/ Phân phối", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nhà cung cấp", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng", fontHeader), 1));
                                DataTable nTable = Report_Data.FertilizerPesticideBuyReport(memberID, seedkey.ToInt(), FromDate, ToDate);
                                if (nTable != null)
                                {
                                    for (int i = 0; i < nTable.Rows.Count; i++)
                                    {
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Common"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Company"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Address"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1));
                                    }
                                }
                                document.Add(mainTable);
                                document.NewPage();
                            }
                            #endregion
                            #region [ Quản lý Sử dụng phân/hóa chất ]
                            if (1 == 1)
                            {
                                Paragraph para = new Paragraph(@"QUẢN LÝ SỬ DỤNG PHÂN BÓN, HÓA CHẤT", new Font(bfTimes, 30, Font.BOLD));
                                para.Alignment    = Element.ALIGN_CENTER;
                                para.SpacingAfter = 20;
                                document.Add(para);

                                PdfPTable mainTable = new PdfPTable(9);
                                mainTable.WidthPercentage = 100;

                                mainTable.SetWidths(new int[] { 9, 11, 14, 15, 10, 15, 10, 10, 6 });
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Cộng việc", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Lý do áp dụng/ Mật độ", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Phương pháp", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Thiết bị sử dụng", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nguyên vật liệu (tên phân bón/ thuốc BVTV/ hóa chất)", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Liều lượng (Nồng độ)", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng lượng/ lít nước", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("TGCL", fontHeader), 1));
                                DataTable nTable = Report_Data.FertilizerPesticideUseReport(memberID, seedkey.ToInt(), FromDate, ToDate);
                                if (nTable != null)
                                {
                                    for (int i = 0; i < nTable.Rows.Count; i++)
                                    {
                                        string TGCL = "";
                                        if (nTable.Rows[i]["TGCL"].ToString() == "")
                                        {
                                            TGCL = "";
                                        }
                                        else
                                        {
                                            TGCL = nTable.Rows[i]["TGCL"].ToString() + " ngày";
                                        }
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Parcel"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Area"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Solution"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["EquipmentName"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Dose"].ToString(), fontozel), 1));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Dosage"].ToString(), fontozel), 1));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(TGCL, fontozel), 0));
                                    }
                                }
                                document.Add(mainTable);
                                document.NewPage();
                            }
                            #endregion
                            #region [ KIỂM TRA, BẢO TRÌ, VỆ SINH THIẾT BỊ DỤNG CỤ ]
                            if (1 == 1)
                            {
                                Paragraph para = new Paragraph(@"KIỂM TRA, BẢO TRÌ, VỆ SINH THIẾT BỊ DỤNG CỤ", new Font(bfTimes, 30, Font.BOLD));
                                para.Alignment    = Element.ALIGN_CENTER;
                                para.SpacingAfter = 20;
                                document.Add(para);

                                PdfPTable mainTable = new PdfPTable(5);
                                mainTable.WidthPercentage = 100;

                                mainTable.SetWidths(new int[] { 15, 15, 15, 40, 15 });
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày thực hiện", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Thiết bị, dụng cụ", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Hoạt động", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Mô tả phương pháp thực hiện", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Người thực hiện", fontHeader), 1));
                                DataTable nTable = Report_Data.CheckEquipmentReport(memberID, seedkey.ToInt(), FromDate, ToDate);
                                if (nTable != null)
                                {
                                    for (int i = 0; i < nTable.Rows.Count; i++)
                                    {
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Action"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Info"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["MemberName"].ToString(), fontozel), 0));
                                    }
                                }
                                document.Add(mainTable);
                                document.NewPage();
                            }
                            #endregion
                            #region [ QUẢN LÝ THU HOẠCH, XUẤT BÁN ]
                            if (1 == 1)
                            {
                                Paragraph para = new Paragraph(@"QUẢN LÝ THU HOẠCH, XUẤT BÁN", new Font(bfTimes, 30, Font.BOLD));
                                para.Alignment    = Element.ALIGN_CENTER;
                                para.SpacingAfter = 20;
                                document.Add(para);

                                PdfPTable mainTable = new PdfPTable(6);
                                mainTable.WidthPercentage = 100;

                                mainTable.SetWidths(new int[] { 15, 20, 15, 20, 15, 15 });
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày thu hoạch/ Xuất bán", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Mã số truy vết", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng thu hoạch", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Người thu hoạch", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng bán (Kg)", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nơi thu mua", fontHeader), 1));
                                DataTable nTable = Report_Data.HarvestedForSaleReport(memberID, seedkey.ToInt(), FromDate, ToDate);
                                if (nTable != null)
                                {
                                    for (int i = 0; i < nTable.Rows.Count; i++)
                                    {
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Code"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["QuantityHarvested"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["MemberName"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["QuantitySale"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["WhereToBuy"].ToString(), fontozel), 0));
                                    }
                                }
                                document.Add(mainTable);
                                document.NewPage();
                            }
                            #endregion
                            #region [ KIỂM KÊ TỒN KHO ]
                            if (1 == 1)
                            {
                                Paragraph para = new Paragraph(@"KIỂM KÊ TỒN KHO", new Font(bfTimes, 30, Font.BOLD));
                                para.Alignment    = Element.ALIGN_CENTER;
                                para.SpacingAfter = 20;
                                document.Add(para);

                                PdfPTable mainTable = new PdfPTable(4);
                                mainTable.WidthPercentage = 100;

                                mainTable.SetWidths(new int[] { 15, 25, 25, 25 });
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày kiểm kê", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("phân bón/ Hóa chất", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng", fontHeader), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Hạn dùng", fontHeader), 1));
                                DataTable nTable = Report_Data.InventoryReport(memberID, seedkey.ToInt(), FromDate, ToDate);
                                if (nTable != null)
                                {
                                    for (int i = 0; i < nTable.Rows.Count; i++)
                                    {
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1));
                                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["ExpireDate"]), fontozel), 1));
                                    }
                                }
                                document.Add(mainTable);
                                document.NewPage();
                            }
                            #endregion
                        }
                    }
                }
                else
                {
                    Seed_Info sinfo = new Seed_Info(seedkey.ToInt());
                    NameSeed = "_" + sinfo.SeedsName;
                    Paragraph header = new Paragraph(@"SỔ NHẬT KÝ SẢN XUẤT", new Font(bfTimes, 40, Font.BOLD));
                    header.Alignment    = Element.ALIGN_CENTER;
                    header.SpacingAfter = 20;
                    document.Add(header);
                    Paragraph header1 = new Paragraph(@"Năm............", new Font(bfTimes, 20, Font.NORMAL));
                    header1.Alignment    = Element.ALIGN_CENTER;
                    header1.SpacingAfter = 170;
                    document.Add(header1);
                    document.Add(new Paragraph(@"NÔNG HỘ: " + minfo.Name, new Font(bfTimes, 20, Font.BOLD)));
                    document.Add(new Paragraph(@"MÃ SỐ: " + minfo.MemID, new Font(bfTimes, 20, Font.BOLD)));
                    document.NewPage();
                    Paragraph Text1 = new Paragraph(@"PHẦN SẢN XUẤT", new Font(bfTimes, 30, Font.BOLD));
                    Text1.Alignment = Element.ALIGN_CENTER;
                    document.Add(Text1);
                    Paragraph Text2 = new Paragraph(@"Cây trồng: " + sinfo.SeedsName, new Font(bfTimes, 25, Font.NORMAL));
                    Text2.Alignment = Element.ALIGN_CENTER;
                    document.Add(Text2);
                    Paragraph Text3 = new Paragraph(@"Từ " + this.Request["from"] + " đến " + this.Request["to"], new Font(bfTimes, 25, Font.NORMAL));
                    Text3.Alignment = Element.ALIGN_CENTER;
                    document.Add(Text3);
                    document.NewPage();
                    #region [ Quản lý giống ]
                    if (1 == 1)
                    {
                        Paragraph para = new Paragraph(@"QUẢN LÝ GIỐNG", new Font(bfTimes, 30, Font.BOLD));
                        para.Alignment    = Element.ALIGN_CENTER;
                        para.SpacingAfter = 20;
                        document.Add(para);

                        PdfPTable mainTable = new PdfPTable(6);
                        mainTable.WidthPercentage = 100;

                        mainTable.SetWidths(new int[] { 15, 20, 15, 15, 15, 20 });
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên Giống", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nhà sản xuất/Phân phối (Nguồn gốc giống)", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày trồng", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Mã số lô", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Diện tích", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng lượng giống", fontHeader), 1));
                        DataTable nTable = Report_Data.SeedProcessReport(memberID, seedkey.ToInt(), FromDate, ToDate);
                        if (nTable != null)
                        {
                            for (int i = 0; i < nTable.Rows.Count; i++)
                            {
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["CompanyName"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Parcel"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Area"].ToString() + " " + nTable.Rows[i]["UnitArea"].ToString(), fontozel), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["UnitQuantity"].ToString(), fontozel), 1));
                            }
                        }

                        document.Add(mainTable);
                    }
                    #endregion
                    #region [ Quản lý ủ phân hữu cơ ]
                    if (1 == 1)
                    {
                        Paragraph para = new Paragraph(@"QUẢN LÝ Ủ PHÂN HỮU CƠ", new Font(bfTimes, 30, Font.BOLD));
                        para.Alignment    = Element.ALIGN_CENTER;
                        para.SpacingAfter = 20;
                        document.Add(para);

                        PdfPTable mainTable = new PdfPTable(5);
                        mainTable.WidthPercentage = 100;

                        mainTable.SetWidths(new int[] { 15, 10, 45, 15, 15 });
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Loại phân", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Khối lượng", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Phương pháp ủ", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Thời gian ủ", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Người thực hiện", fontHeader), 1));
                        DataTable nTable = Report_Data.CompostingOrganicReport(memberID, seedkey.ToInt(), FromDate, ToDate);
                        if (nTable != null)
                        {
                            for (int i = 0; i < nTable.Rows.Count; i++)
                            {
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Method"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["CompostingDates"].ToString() + " ngày", fontozel), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Member_Name"].ToString(), fontozel), 0));
                            }
                        }

                        document.Add(mainTable);
                        document.NewPage();
                    }
                    #endregion
                    #region [ Quản lý Mua phân/hóa chất ]
                    if (1 == 1)
                    {
                        Paragraph para = new Paragraph(@"QUẢN LÝ MUA PHÂN BÓN, HÓA CHẤT", new Font(bfTimes, 30, Font.BOLD));
                        para.Alignment    = Element.ALIGN_CENTER;
                        para.SpacingAfter = 20;
                        document.Add(para);

                        PdfPTable mainTable = new PdfPTable(6);
                        mainTable.WidthPercentage = 100;

                        mainTable.SetWidths(new int[] { 10, 15, 25, 25, 15, 10 });
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày mua", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên thương mại", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Thành phần/ Hoạt chất", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nhà sản xuất/ Phân phối", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nhà cung cấp", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng", fontHeader), 1));
                        DataTable nTable = Report_Data.FertilizerPesticideBuyReport(memberID, seedkey.ToInt(), FromDate, ToDate);
                        if (nTable != null)
                        {
                            for (int i = 0; i < nTable.Rows.Count; i++)
                            {
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Common"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Company"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Address"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1));
                            }
                        }
                        document.Add(mainTable);
                        document.NewPage();
                    }
                    #endregion
                    #region [ Quản lý Sử dụng phân/hóa chất ]
                    if (1 == 1)
                    {
                        Paragraph para = new Paragraph(@"QUẢN LÝ SỬ DỤNG PHÂN BÓN, HÓA CHẤT", new Font(bfTimes, 30, Font.BOLD));
                        para.Alignment    = Element.ALIGN_CENTER;
                        para.SpacingAfter = 20;
                        document.Add(para);

                        PdfPTable mainTable = new PdfPTable(9);
                        mainTable.WidthPercentage = 100;

                        mainTable.SetWidths(new int[] { 9, 11, 14, 15, 10, 15, 10, 10, 6 });
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Cộng việc", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Lý do áp dụng/ Mật độ", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Phương pháp", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Thiết bị sử dụng", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nguyên vật liệu (tên phân bón/ thuốc BVTV/ hóa chất)", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Liều lượng (Nồng độ)", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng lượng/ lít nước", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("TGCL", fontHeader), 1));
                        DataTable nTable = Report_Data.FertilizerPesticideUseReport(memberID, seedkey.ToInt(), FromDate, ToDate);
                        if (nTable != null)
                        {
                            for (int i = 0; i < nTable.Rows.Count; i++)
                            {
                                string TGCL = "";
                                if (nTable.Rows[i]["TGCL"].ToString() == "")
                                {
                                    TGCL = "";
                                }
                                else
                                {
                                    TGCL = nTable.Rows[i]["TGCL"].ToString() + " ngày";
                                }
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Parcel"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Area"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Solution"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["EquipmentName"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Dose"].ToString(), fontozel), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Dosage"].ToString(), fontozel), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(TGCL, fontozel), 0));
                            }
                        }
                        document.Add(mainTable);
                        document.NewPage();
                    }
                    #endregion
                    #region [ KIỂM TRA, BẢO TRÌ, VỆ SINH THIẾT BỊ DỤNG CỤ ]
                    if (1 == 1)
                    {
                        Paragraph para = new Paragraph(@"KIỂM TRA, BẢO TRÌ, VỆ SINH THIẾT BỊ DỤNG CỤ", new Font(bfTimes, 30, Font.BOLD));
                        para.Alignment    = Element.ALIGN_CENTER;
                        para.SpacingAfter = 20;
                        document.Add(para);

                        PdfPTable mainTable = new PdfPTable(5);
                        mainTable.WidthPercentage = 100;

                        mainTable.SetWidths(new int[] { 15, 15, 15, 40, 15 });
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày thực hiện", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Thiết bị, dụng cụ", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Hoạt động", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Mô tả phương pháp thực hiện", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Người thực hiện", fontHeader), 1));
                        DataTable nTable = Report_Data.CheckEquipmentReport(memberID, seedkey.ToInt(), FromDate, ToDate);
                        if (nTable != null)
                        {
                            for (int i = 0; i < nTable.Rows.Count; i++)
                            {
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Action"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Info"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["MemberName"].ToString(), fontozel), 0));
                            }
                        }
                        document.Add(mainTable);
                        document.NewPage();
                    }
                    #endregion
                    #region [ QUẢN LÝ THU HOẠCH, XUẤT BÁN ]
                    if (1 == 1)
                    {
                        Paragraph para = new Paragraph(@"QUẢN LÝ THU HOẠCH, XUẤT BÁN", new Font(bfTimes, 30, Font.BOLD));
                        para.Alignment    = Element.ALIGN_CENTER;
                        para.SpacingAfter = 20;
                        document.Add(para);

                        PdfPTable mainTable = new PdfPTable(6);
                        mainTable.WidthPercentage = 100;

                        mainTable.SetWidths(new int[] { 15, 20, 15, 20, 15, 15 });
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày thu hoạch/ Xuất bán", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Mã số truy vết", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng thu hoạch", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Người thu hoạch", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng bán (Kg)", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nơi thu mua", fontHeader), 1));
                        DataTable nTable = Report_Data.HarvestedForSaleReport(memberID, seedkey.ToInt(), FromDate, ToDate);
                        if (nTable != null)
                        {
                            for (int i = 0; i < nTable.Rows.Count; i++)
                            {
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Code"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["QuantityHarvested"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["MemberName"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["QuantitySale"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["WhereToBuy"].ToString(), fontozel), 0));
                            }
                        }
                        document.Add(mainTable);
                        document.NewPage();
                    }
                    #endregion
                    #region [ KIỂM KÊ TỒN KHO ]
                    if (1 == 1)
                    {
                        Paragraph para = new Paragraph(@"KIỂM KÊ TỒN KHO", new Font(bfTimes, 30, Font.BOLD));
                        para.Alignment    = Element.ALIGN_CENTER;
                        para.SpacingAfter = 20;
                        document.Add(para);

                        PdfPTable mainTable = new PdfPTable(4);
                        mainTable.WidthPercentage = 100;

                        mainTable.SetWidths(new int[] { 15, 25, 25, 25 });
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày kiểm kê", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("phân bón/ Hóa chất", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng", fontHeader), 1));
                        mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Hạn dùng", fontHeader), 1));
                        DataTable nTable = Report_Data.InventoryReport(memberID, seedkey.ToInt(), FromDate, ToDate);
                        if (nTable != null)
                        {
                            for (int i = 0; i < nTable.Rows.Count; i++)
                            {
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["ExpireDate"]), fontozel), 1));
                            }
                        }
                        document.Add(mainTable);
                        document.NewPage();
                    }
                    #endregion
                }
                document.Close();
                writer.Close();
                Response.ContentType = "application/pdf;";
                Response.AddHeader("Content-Disposition", "attachment; filename=SoNhatKySanXuat_" + TNLibrary.Book.Utils.RemoveUnicode(minfo.Name.Replace(" ", "")) + TNLibrary.Book.Utils.RemoveUnicode(NameSeed.Replace(" ", "")) + "_" + DateTime.Now.ToString("dd.MM.yyyy_HH.mm") + ".pdf");
                byte[] pdf = ms.ToArray();
                Response.OutputStream.Write(pdf, 0, pdf.Length);
            }
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Request["seedkey"] != null)
            {
                seedkey = this.Request["seedkey"].ToInt();
            }
            if (this.Request["from"] != null)
            {
                FromDate = DateTime.ParseExact(this.Request["from"], "d/M/yyyy", CultureInfo.InvariantCulture);
            }
            if (this.Request["to"] != null)
            {
                ToDate = DateTime.ParseExact(this.Request["to"], "d/M/yyyy", CultureInfo.InvariantCulture);
            }
            int memberID = HttpContext.Current.Session["MemberID"].ToInt();

            if (memberID != 0)
            {
                string NameSeed = "";
                TNLibrary.Book.Member_Info minfo = new TNLibrary.Book.Member_Info(memberID);
                MemoryStream ms       = new MemoryStream();
                Document     document = new Document(iTextSharp.text.PageSize.A4.Rotate(), 66, 36, 54, 54);
                PdfWriter    writer   = PdfWriter.GetInstance(document, ms);
                BaseFont     bfTimes  = BaseFont.CreateFont("c:\\windows\\fonts\\times.ttf", BaseFont.IDENTITY_H, false);

                Font fontHeader = new Font(bfTimes, 12, Font.BOLD);
                Font fontNormal = new Font(bfTimes, 11);
                Font fontozel   = new Font(bfTimes, 12, Font.NORMAL);
                writer.PageEvent = new PDFFooter();

                document.Open();

                if (seedkey.ToInt() == 0)
                {
                    Paragraph header = new Paragraph(@"BÁO CÁO CHI PHÍ TỔNG HỢP", new Font(bfTimes, 40, Font.BOLD));
                    header.Alignment    = Element.ALIGN_CENTER;
                    header.SpacingAfter = 20;
                    document.Add(header);
                    Paragraph Text3 = new Paragraph(@"Từ " + this.Request["from"] + " đến " + this.Request["to"], new Font(bfTimes, 25, Font.NORMAL));
                    Text3.Alignment    = Element.ALIGN_CENTER;
                    Text3.SpacingAfter = 150;
                    document.Add(Text3);
                }
                else
                {
                    Paragraph header = new Paragraph(@"BÁO CÁO CHI PHÍ", new Font(bfTimes, 40, Font.BOLD));
                    header.Alignment    = Element.ALIGN_CENTER;
                    header.SpacingAfter = 20;
                    document.Add(header);
                    Paragraph Text3 = new Paragraph(@"Từ " + this.Request["from"] + " đến " + this.Request["to"], new Font(bfTimes, 25, Font.NORMAL));
                    Text3.Alignment    = Element.ALIGN_CENTER;
                    Text3.SpacingAfter = 20;
                    document.Add(Text3);
                    Seed_Info sinfo      = new Seed_Info(seedkey.ToInt());
                    Paragraph headerseed = new Paragraph(sinfo.SeedsName, new Font(bfTimes, 40, Font.BOLD));
                    headerseed.Alignment    = Element.ALIGN_CENTER;
                    headerseed.SpacingAfter = 90;
                    document.Add(headerseed);
                }
                document.Add(new Paragraph(@"NÔNG HỘ: " + minfo.Name, new Font(bfTimes, 20, Font.BOLD)));
                document.Add(new Paragraph(@"MÃ SỐ: " + minfo.MemID, new Font(bfTimes, 20, Font.BOLD)));
                document.NewPage();

                if (seedkey.ToInt() == 0)
                {
                    NameSeed = "_Tatca";
                    if (1 == 1)
                    {
                        DataTable mTable   = Report_Data.SumMoneyReport(memberID, seedkey, FromDate, ToDate);
                        Paragraph headerTH = new Paragraph(@"Bảng tổng hợp thu chi", new Font(bfTimes, 30, Font.BOLD));
                        headerTH.Alignment    = Element.ALIGN_CENTER;
                        headerTH.SpacingAfter = 20;
                        document.Add(headerTH);
                        PdfPTable THTable = new PdfPTable(2);
                        THTable.WidthPercentage = 100;
                        THTable.SetWidths(new int[] { 50, 50 });
                        THTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi", fontHeader), 1));
                        THTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng thu", fontHeader), 1));
                        THTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Compute("Sum(TotalBuy)", "").ToString() == "" ? "0" : mTable.Compute("Sum(TotalBuy)", "")), fontHeader), 1));
                        THTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Compute("Sum(TotalSale)", "").ToString() == "" ? "0" : mTable.Compute("Sum(TotalSale)", "")), fontHeader), 1));
                        document.Add(THTable);
                        document.Add(new Paragraph("Ghi chú: Tổng chi = Tổng chi giống + Tổng chi phân bón + Tổng chi Thuốc(hóa chất) ", new Font(bfTimes, 15, Font.NORMAL)));
                        document.Add(new Paragraph("Tổng thu = Tổng thu hoạch xuất bán ", new Font(bfTimes, 15, Font.NORMAL)));
                        document.NewPage();
                        Paragraph headerTP = new Paragraph(@"Thống kê theo thành phần", new Font(bfTimes, 30, Font.BOLD));
                        headerTP.Alignment    = Element.ALIGN_CENTER;
                        headerTP.SpacingAfter = 20;
                        document.Add(headerTP);

                        document.Add(new Paragraph("1. Thống kê theo giống ", new Font(bfTimes, 13, Font.BOLD)));
                        PdfPTable SeedTable = new PdfPTable(2);
                        SeedTable.SpacingBefore   = 10;
                        SeedTable.WidthPercentage = 100;
                        SeedTable.SetWidths(new int[] { 50, 50 });
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên giống", fontHeader), 1));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi", fontHeader), 1));
                        double TotalSeedProcess = 0;
                        for (int i = 0; i < mTable.Rows.Count; i++)
                        {
                            if (mTable.Rows[i]["Type"].ToString() == "Mua giống")
                            {
                                SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(mTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]), fontozel), 2));
                                TotalSeedProcess += String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]).ToDouble();
                            }
                        }
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi giống : ", fontHeader), 2));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalSeedProcess), fontozel), 2));
                        document.Add(SeedTable);
                        SeedTable.DeleteBodyRows();
                        document.Add(new Paragraph("2. Thống kê theo phần bón ", new Font(bfTimes, 13, Font.BOLD)));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên phân bón", fontHeader), 1));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi", fontHeader), 1));
                        double TotalFertilizers = 0;
                        for (int i = 0; i < mTable.Rows.Count; i++)
                        {
                            if (mTable.Rows[i]["Type"].ToString() == "Mua phân bón")
                            {
                                SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(mTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]), fontozel), 2));
                                TotalFertilizers += String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]).ToDouble();
                            }
                        }
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi phân bón : ", fontHeader), 2));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalFertilizers), fontozel), 2));
                        document.Add(SeedTable);
                        SeedTable.DeleteBodyRows();
                        document.Add(new Paragraph("3. Thống kê theo Thuốc(hóa chất) ", new Font(bfTimes, 13, Font.BOLD)));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên thuốc", fontHeader), 1));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi", fontHeader), 1));
                        double TotalPesticides = 0;
                        for (int i = 0; i < mTable.Rows.Count; i++)
                        {
                            if (mTable.Rows[i]["Type"].ToString() == "Mua thuốc BVTV")
                            {
                                SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(mTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]), fontozel), 2));
                                TotalPesticides += String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]).ToDouble();
                            }
                        }
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi Thuốc(hóa chất) : ", fontHeader), 2));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalPesticides), fontozel), 2));
                        document.Add(SeedTable);
                        SeedTable.DeleteBodyRows();
                        document.Add(new Paragraph("4. Thống kê theo thu hoạch xuất bán ", new Font(bfTimes, 13, Font.BOLD)));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên giống", fontHeader), 1));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng thu", fontHeader), 1));
                        double TotalHarvestedForSale = 0;
                        for (int i = 0; i < mTable.Rows.Count; i++)
                        {
                            if (mTable.Rows[i]["Type"].ToString() == "Thu hoạch xuất bán")
                            {
                                SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(mTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Rows[i]["TotalSale"]), fontozel), 2));
                                TotalHarvestedForSale += String.Format("{0:#,0}", mTable.Rows[i]["TotalSale"]).ToDouble();
                            }
                        }
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng thu hoạch xuất bán : ", fontHeader), 2));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalHarvestedForSale), fontozel), 2));
                        document.Add(SeedTable);
                        SeedTable.DeleteBodyRows();
                        document.NewPage();
                        DataTable nTable = Report_Data.MoneyReport(memberID, seedkey, FromDate, ToDate);
                        if (nTable != null)
                        {
                            Paragraph headerDate = new Paragraph(@"Bảng tổng hợp thu chi theo ngày", new Font(bfTimes, 30, Font.BOLD));
                            headerDate.Alignment    = Element.ALIGN_CENTER;
                            headerDate.SpacingAfter = 20;
                            document.Add(headerDate);
                            PdfPTable mainTable = new PdfPTable(8);
                            mainTable.WidthPercentage = 100;
                            mainTable.SetWidths(new int[] { 5, 10, 20, 20, 10, 10, 10, 15 });
                            double TotalSale = 0, TotalBuy = 0;
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("STT", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Loại thu chi", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên Hàng", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng Chi", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng Thu", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Cung Cấp", fontHeader), 1));

                            for (int i = 0; i < nTable.Rows.Count; i++)
                            {
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase((i + 1).ToString(), fontozel), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Type"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", nTable.Rows[i]["TotalBuy"]), fontozel), 2));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", nTable.Rows[i]["TotalSale"]), fontozel), 2));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Address"].ToString(), fontozel), 0));
                                TotalSale += nTable.Rows[i]["TotalSale"].ToDouble();
                                TotalBuy  += nTable.Rows[i]["TotalBuy"].ToDouble();
                            }
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalBuy), fontHeader), 2));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalSale), fontHeader), 2));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1));
                            document.Add(mainTable);
                        }
                    }
                }
                else
                {
                    Seed_Info sinfo = new Seed_Info(seedkey.ToInt());
                    NameSeed = "_" + sinfo.SeedsName;
                    if (1 == 1)
                    {
                        DataTable mTable   = Report_Data.SumMoneyReport(memberID, seedkey, FromDate, ToDate);
                        Paragraph headerTH = new Paragraph(@"Bảng tổng hợp thu chi", new Font(bfTimes, 30, Font.BOLD));
                        headerTH.Alignment    = Element.ALIGN_CENTER;
                        headerTH.SpacingAfter = 20;
                        document.Add(headerTH);
                        PdfPTable THTable = new PdfPTable(2);
                        THTable.WidthPercentage = 100;
                        THTable.SetWidths(new int[] { 50, 50 });
                        THTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi", fontHeader), 1));
                        THTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng thu", fontHeader), 1));
                        THTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Compute("Sum(TotalBuy)", "").ToString() == "" ? "0" : mTable.Compute("Sum(TotalBuy)", "")), fontHeader), 1));
                        THTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Compute("Sum(TotalSale)", "").ToString() == "" ? "0" : mTable.Compute("Sum(TotalSale)", "")), fontHeader), 1));
                        document.Add(THTable);
                        document.Add(new Paragraph("Ghi chú: Tổng chi = Tổng chi giống + Tổng chi phân bón + Tổng chi Thuốc(hóa chất) ", new Font(bfTimes, 15, Font.NORMAL)));
                        document.Add(new Paragraph("Tổng thu = Tổng thu hoạch xuất bán ", new Font(bfTimes, 15, Font.NORMAL)));
                        document.NewPage();
                        document.Add(new Paragraph("Thống kê theo thành phần ", new Font(bfTimes, 15, Font.BOLD)));
                        document.Add(new Paragraph("1. Thống kê theo giống ", new Font(bfTimes, 13, Font.BOLD)));
                        PdfPTable SeedTable = new PdfPTable(2);
                        SeedTable.SpacingBefore   = 10;
                        SeedTable.WidthPercentage = 100;
                        SeedTable.SetWidths(new int[] { 50, 50 });
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên giống", fontHeader), 1));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi", fontHeader), 1));
                        double TotalSeedProcess = 0;
                        for (int i = 0; i < mTable.Rows.Count; i++)
                        {
                            if (mTable.Rows[i]["Type"].ToString() == "Mua giống")
                            {
                                SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(mTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]), fontozel), 2));
                                TotalSeedProcess += String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]).ToDouble();
                            }
                        }
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi giống : ", fontHeader), 2));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalSeedProcess), fontozel), 2));
                        document.Add(SeedTable);
                        SeedTable.DeleteBodyRows();
                        document.Add(new Paragraph("2. Thống kê theo phần bón ", new Font(bfTimes, 13, Font.BOLD)));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên phân bón", fontHeader), 1));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi", fontHeader), 1));
                        double TotalFertilizers = 0;
                        for (int i = 0; i < mTable.Rows.Count; i++)
                        {
                            if (mTable.Rows[i]["Type"].ToString() == "Mua phân bón")
                            {
                                SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(mTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]), fontozel), 2));
                                TotalFertilizers += String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]).ToDouble();
                            }
                        }
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi phân bón : ", fontHeader), 2));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalFertilizers), fontozel), 2));
                        document.Add(SeedTable);
                        SeedTable.DeleteBodyRows();
                        document.Add(new Paragraph("3. Thống kê theo Thuốc(hóa chất) ", new Font(bfTimes, 13, Font.BOLD)));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên thuốc", fontHeader), 1));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi", fontHeader), 1));
                        double TotalPesticides = 0;
                        for (int i = 0; i < mTable.Rows.Count; i++)
                        {
                            if (mTable.Rows[i]["Type"].ToString() == "Mua thuốc BVTV")
                            {
                                SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(mTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]), fontozel), 2));
                                TotalPesticides += String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]).ToDouble();
                            }
                        }
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi Thuốc(hóa chất) : ", fontHeader), 2));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalPesticides), fontozel), 2));
                        document.Add(SeedTable);
                        SeedTable.DeleteBodyRows();
                        document.Add(new Paragraph("4. Thống kê theo thu hoạch xuất bán ", new Font(bfTimes, 13, Font.BOLD)));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên giống", fontHeader), 1));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng thu", fontHeader), 1));
                        double TotalHarvestedForSale = 0;
                        for (int i = 0; i < mTable.Rows.Count; i++)
                        {
                            if (mTable.Rows[i]["Type"].ToString() == "Thu hoạch xuất bán")
                            {
                                SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(mTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Rows[i]["TotalSale"]), fontozel), 2));
                                TotalHarvestedForSale += String.Format("{0:#,0}", mTable.Rows[i]["TotalSale"]).ToDouble();
                            }
                        }
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng thu hoạch xuất bán : ", fontHeader), 2));
                        SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalHarvestedForSale), fontozel), 2));
                        document.Add(SeedTable);
                        SeedTable.DeleteBodyRows();
                        document.NewPage();
                        DataTable nTable = Report_Data.MoneyReport(memberID, seedkey, FromDate, ToDate);
                        if (nTable != null)
                        {
                            Paragraph headerDate = new Paragraph(@"Bảng tổng hợp thu chi theo ngày", new Font(bfTimes, 30, Font.BOLD));
                            headerDate.Alignment    = Element.ALIGN_CENTER;
                            headerDate.SpacingAfter = 20;
                            document.Add(headerDate);
                            PdfPTable mainTable = new PdfPTable(8);
                            mainTable.WidthPercentage = 100;
                            mainTable.SetWidths(new int[] { 5, 10, 20, 20, 10, 10, 10, 15 });
                            double TotalSale = 0, TotalBuy = 0;
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("STT", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Loại thu chi", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên Hàng", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng Chi", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng Thu", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Cung Cấp", fontHeader), 1));

                            for (int i = 0; i < nTable.Rows.Count; i++)
                            {
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase((i + 1).ToString(), fontozel), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Type"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", nTable.Rows[i]["TotalBuy"]), fontozel), 2));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", nTable.Rows[i]["TotalSale"]), fontozel), 2));
                                mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Address"].ToString(), fontozel), 0));
                                TotalSale += nTable.Rows[i]["TotalSale"].ToDouble();
                                TotalBuy  += nTable.Rows[i]["TotalBuy"].ToDouble();
                            }
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng", fontHeader), 1));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalBuy), fontHeader), 2));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalSale), fontHeader), 2));
                            mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1));
                            document.Add(mainTable);
                        }
                    }
                }

                document.Close();
                writer.Close();
                Response.ContentType = "application/pdf;";
                Response.AddHeader("Content-Disposition", "attachment; filename=BaoCaoChiPhi_" + TNLibrary.Book.Utils.RemoveUnicode(minfo.Name.Replace(" ", "")) + TNLibrary.Book.Utils.RemoveUnicode(NameSeed.Replace(" ", "")) + "_" + DateTime.Now.ToString("dd.MM.yyyy_HH.mm") + ".pdf");
                byte[] pdf = ms.ToArray();
                Response.OutputStream.Write(pdf, 0, pdf.Length);
            }
        }