示例#1
0
        public static bool importarTXT(string caminho)
        {
            try
            {
                StreamReader objSR = new StreamReader(@caminho, true);
                while (!objSR.EndOfStream)
                {
                    string linha = objSR.ReadLine();
                    if ((linha != "Cabeçalho: Formas de Pagamento") && (linha != ""))
                    {
                        String[]          vetor             = linha.Split(';');
                        clsFormaPagamento objFormaPagamento = new clsFormaPagamento();
                        objFormaPagamento.IntCodigo = Convert.ToInt16(vetor[0].ToString());
                        objFormaPagamento.StrNome   = vetor[1].ToString();

                        //verificar se ID ja existe no BD
                        DataTable dtApoio = recuperarCodigo(objFormaPagamento.IntCodigo);
                        if (dtApoio.Rows.Count == 0)
                        {
                            objFormaPagamento.Salvar();
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                //throw new Exception (ex.Message);
                throw ex;
            }
        }
示例#2
0
        public static List <clsFormaPagamento> listaFormasPagamento()
        {
            List <clsFormaPagamento> objLista = new List <clsFormaPagamento>();
            DataTable dtApoio = recuperarTodos();

            foreach (DataRow linha in dtApoio.Rows)
            {
                clsFormaPagamento objFormaPagamento = new clsFormaPagamento();
                objFormaPagamento.IntCodigo = Convert.ToInt16(linha["CODIGO"].ToString());
                objFormaPagamento.StrNome   = linha["NOME"].ToString();

                objLista.Add(objFormaPagamento);
            }
            return(objLista);
        }