public NfeVendaTxt(NfeVenda entidade) { this.entidade = entidade; cliente = entidade.Venda.Cliente; física = cliente as PessoaFísica; jurídica = cliente as PessoaJurídica; }
private void Salvar(Venda v) { int códigoNfe; if (!int.TryParse(txtNfe.Text, out códigoNfe)) { txtNfe.Focus(); return; } int códigoCFOP; if (!int.TryParse(txtCFOP.Text, out códigoCFOP)) { txtCFOP.Focus(); return; } int códigoFatura; if (!int.TryParse(txtNumeroFatura.Text, out códigoFatura)) { txtNumeroFatura.Focus(); return; } double aliquota; if (!double.TryParse(txtAliquota.Text, out aliquota)) { txtAliquota.Focus(); return; } NfeVenda nota = new NfeVenda(v, códigoNfe, códigoCFOP, códigoFatura, aliquota); NfeVendaTxt escritorTxt = new NfeVendaTxt(nota); FolderBrowserDialog janela = new FolderBrowserDialog(); DialogResult resultado = janela.ShowDialog(); if (resultado == DialogResult.OK) SalvarVenda(v, códigoNfe, códigoFatura, nota, escritorTxt, janela); }
private void SalvarVenda(Venda v, int códigoNfe, int códigoFatura, NfeVenda nota, NfeVendaTxt escritorTxt, FolderBrowserDialog janela) { string arquivo = Path.Combine(janela.SelectedPath, v.Código.ToString() + ".txt"); if (File.Exists(arquivo)) { DialogResult apagar = MessageBox.Show(this, "Sobrescrever ?", "Arquivo já existe", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (apagar == DialogResult.No) return; File.Delete(arquivo); } if (!TentaSalvarArquivo(escritorTxt, arquivo)) return; nota.Cadastrar(); if (AoSalvarNfe != null) AoSalvarNfe(null, null); Process.Start(janela.SelectedPath); últimaNFe.Valor = códigoNfe; últimaFatura.Valor = códigoFatura; últimaVendaExportada.Valor = v.Código; txtCódigoVenda.Text = ""; Carregar(); txtCódigoVenda.Focus(); }