public void Update(Model.Nota oNo) { if (oNo.Disciplina != "") { dalNota.Update(oNo); } }
public void Delete(Model.Nota oNo) { if (oNo.Codigo > 0) { dalNota.Delete(oNo); } }
public TelaDados() { InitializeComponent(); Id = Nota.Id; PedidoModalClientes.Id = 0; _mNota = new Model.Nota().FindById(Id).FirstOrDefault <Model.Nota>(); if (_mNota == null) { Alert.Message("Ação não permitida", "Referência de Pedido não identificada", Alert.AlertType.warning); return; } _mPedido = new Model.Pedido().FindById(_mNota.id_pedido).FirstOrDefault <Model.Pedido>(); if (_mPedido == null) { Alert.Message("Ação não permitida", "Referência de Pedido não identificada", Alert.AlertType.warning); return; } IdNatureza = _mPedido.id_natureza; DisableCampos(); Eventos(); }
private SqlKata.Query getListXml(string dataInicial, string dataFinal) { var query = new Model.Nota().Query(); query .LeftJoin("pedido", "pedido.id", "nota.id_pedido") .LeftJoin("pessoa", "pessoa.id", "pedido.cliente") .LeftJoin("usuarios as colaborador", "colaborador.id_user", "pedido.colaborador") .LeftJoin("usuarios as usuario", "usuario.id_user", "pedido.id_usuario") .Select("pedido.id", "pedido.tipo", "pedido.emissao", "pedido.total", "pessoa.nome", "colaborador.nome as colaborador", "usuario.nome as usuario", "pedido.criado", "pedido.excluir", "pedido.status", "nota.nr_nota as nfe", "nota.serie", "nota.status as statusnfe", "nota.tipo as tiponfe", "nota.id as idnota", "nota.criado as criadonota", "nota.CHAVEDEACESSO as chavedeacesso"); query.Where("nota.criado", ">=", Validation.ConvertDateToSql(dataInicial, true)).Where("nota.criado", "<=", Validation.ConvertDateToSql(dataFinal + " 23:59", true)); query.Where("pedido.excluir", 0); query.Where("nota.tipo", "CFe"); query.Where( q => q.Where("nota.status", "<>", "Pendente").Where("nota.status", "<>", "Falha") ); query.OrderByDesc("nota.id"); return(query); }
public void Insert(Model.Nota oNo) { if (oNo.Disciplina == "") { throw new Exception("Campo Obrigatório!"); } dalNota.Insert(oNo); }
private void Eventos() { KeyDown += KeyDowns; KeyPreview = true; Load += (s, e) => { DataTableStart(); }; btnHelp.Click += (s, e) => Support.OpenLinkBrowser(Program.URL_BASE + "/ajuda"); btnAdicionar.Click += (s, e) => { DocumentosReferenciadosAdd f = new DocumentosReferenciadosAdd(); f.TopMost = true; if (f.ShowDialog() == DialogResult.OK) { DataTableStart(); } }; btnRemover.Click += (s, e) => { var result = AlertOptions.Message("Atenção!", "Você está prestes a deletar uma chave de acesso, continuar?", AlertBig.AlertType.warning, AlertBig.AlertBtn.YesNo); if (result) { if (GridLista.SelectedRows.Count > 0) { _mNota = _mNota.FindById(Validation.ConvertToInt32(GridLista.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault <Model.Nota>(); _mNota.Excluir = 1; _mNota.Save(_mNota, false); DataTableStart(); } } }; using (var b = WorkerBackground) { b.DoWork += async(s, e) => { dataTable = await _cNota.GetDataTableDoc(idPedido); }; b.RunWorkerCompleted += async(s, e) => { await _cNota.SetTableDoc(GridLista, idPedido); }; } }
public void Eventos() { Load += (s, e) => { if (idNota > 0) { _nota = new Model.Nota().FindById(idNota).FirstOrDefault <Model.Nota>(); inicio.Text = _nota.nr_Nota.ToString(); final.Text = _nota.assinatura_qrcode.ToString(); serie.Text = _nota.Serie.ToString(); justificativa.Text = _nota.correcao.ToString(); } inicio.Select(); }; btnSalvar.Click += (s, e) => { if (justificativa.Text.Length < 15) { Alert.Message("Ação não permitida", "Justificativa deve conter 15 caracteres", Alert.AlertType.warning); return; } _nota.Id = idNota; _nota.Tipo = "Inutiliza"; _nota.Status = "Transmitindo..."; _nota.nr_Nota = inicio.Text; _nota.assinatura_qrcode = final.Text; _nota.Serie = serie.Text; _nota.correcao = justificativa.Text; _nota.correcao = Validation.CleanStringForFiscal(Validation.OneSpaceString(_nota.correcao)); _nota.Save(_nota, true); DialogResult = DialogResult.OK; Close(); }; btnCancelar.Click += (s, e) => { DialogResult = DialogResult.Cancel; Close(); }; justificativa.TextChanged += (s, e) => { caracteres.Text = justificativa.Text.Length.ToString(); }; }
public TelaFinal() { InitializeComponent(); _mNota = new Model.Nota().FindById(Nota.Id).FirstOrDefault <Model.Nota>(); if (_mNota == null) { Alert.Message("Ação não permitida", "Referência de Pedido não identificada", Alert.AlertType.warning); return; } Id = _mNota.id_pedido; Eventos(); }
public OpcoesNfeRapida() { InitializeComponent(); if (idNota == 0) { var checkNota = new Model.Nota().FindByIdPedidoUltReg(idPedido, "", "NFe").FirstOrDefault <Model.Nota>(); if (checkNota != null) { idNota = checkNota.Id; } } Eventos(); }
public string GetSeqCCe(int idPedido, int idNota = 0) { var query = new Model.Nota().Query(); query.SelectRaw("MAX(serie) as serie") .Where("excluir", 0) //.Where("id", idNota) .Where("id_pedido", idPedido) .Where("tipo", "CCe"); foreach (var item in query.Get()) { return(item.SERIE == null ? "1" : (string)(Validation.ConvertToInt32(item.SERIE) + 1).ToString()); } return("1"); }
public TelaProdutos() { InitializeComponent(); Id = Nota.Id; _mNota = _mNota.FindById(Id).FirstOrDefault <Model.Nota>(); if (_mNota == null) { Alert.Message("Ação não permitida", "Referência de Pedido não identificada", Alert.AlertType.warning); return; } _mPedido = _mPedido.FindById(_mNota.id_pedido).FirstOrDefault <Model.Pedido>(); DisableCampos(); Eventos(); }
public void Delete(Model.Nota oNota) { SqlConnection con = new SqlConnection(Banco.stringDeConexao); string sql = "DELETE Nota WHERE Codigo = @Codigo"; SqlCommand cmd = new SqlCommand(sql, con); cmd.Parameters.AddWithValue("@Codigo", oNota.Codigo); con.Open(); try { cmd.ExecuteNonQuery(); } finally { con.Close(); } }
public TelaPagamento() { InitializeComponent(); _mNota = new Model.Nota().FindById(Nota.Id).FirstOrDefault <Model.Nota>(); if (_mNota == null) { Alert.Message("Ação não permitida", "Referência de Pedido não identificada", Alert.AlertType.warning); return; } IdPedido = _mNota.id_pedido; DisableCampos(); Eventos(); TelaReceber.Visible = false; }
private void Edit(bool create = false) { if (create) { var _nota = new Model.Nota().Query().Where("status", "Transmitindo...").Where("tipo", "Inutiliza").Where("excluir", 0).FirstOrDefault <Model.Nota>(); if (_nota != null) { Alert.Message("Ação não permitida", "Existe um registro pendente para transmissão!", Alert.AlertType.warning); return; } InutilizarNotasAdd.idNota = 0; InutilizarNotasAdd f = new InutilizarNotasAdd(); if (f.ShowDialog() == DialogResult.OK) { Filter(); if (p1 == 0) { p1 = 1; WorkerBackground.RunWorkerAsync(); } } return; } if (GridLista.SelectedRows.Count > 0) { InutilizarNotasAdd.idNota = Convert.ToInt32(GridLista.SelectedRows[0].Cells["ID"].Value); InutilizarNotasAdd f = new InutilizarNotasAdd(); if (f.ShowDialog() == DialogResult.OK) { Filter(); if (p1 == 0) { p1 = 1; WorkerBackground.RunWorkerAsync(); } } } }
public IEnumerable <dynamic> GetDataTableInutilizar(string status, string dataInicial, string dataFinal) { var notas = new Model.Nota(); var data = notas.Query() .Select("nota.id as id", "nota.criado as criado", "nota.nr_nota as inicio", "nota.assinatura_qrcode as final", "nota.serie as serie", "nota.status as status") .Where("nota.excluir", 0) .Where("nota.tipo", "Inutiliza"); //.Where("nota.criado", ">=", Validation.ConvertDateToSql(dataInicial, true)) //.Where("nota.criado", "<=", Validation.ConvertDateToSql(dataFinal + " 23:59", true)); if (!string.IsNullOrEmpty(status) && status != "Todos") { data.Where("nota.status", status == "Transmitidos" ? "Transmitindo..." : "Autorizada"); } return(data.Get()); }
public void Insert(Model.Nota oNota) { SqlConnection con = new SqlConnection(Banco.stringDeConexao); string sql = "INSERT INTO Nota (Disciplina,Aluno,Nota1,Total1,Nota2,Total2,Situacao) VALUES (@Disciplina,@Aluno,@Nota1,@Total1,@Nota2,@Total2,@Situacao)"; SqlCommand cmd = new SqlCommand(sql, con); //cmd.Parameters.AddWithValue("@Codigo",oNota.Codigo); cmd.Parameters.AddWithValue("@Disciplina", oNota.Disciplina); cmd.Parameters.AddWithValue("@Aluno", oNota.Aluno); cmd.Parameters.AddWithValue("@Nota1", oNota.Nota1); cmd.Parameters.AddWithValue("@Total1", oNota.Total1); cmd.Parameters.AddWithValue("@Nota2", oNota.Nota2); cmd.Parameters.AddWithValue("@Total2", oNota.Total2); cmd.Parameters.AddWithValue("@Situacao", oNota.Situacao); con.Open(); try { cmd.ExecuteNonQuery(); } finally { con.Close(); } }
public void Update(Model.Nota oNota) { SqlConnection con = new SqlConnection(Banco.stringDeConexao); string sql = "UPDATE Nota SET Disciplina=@Disciplina,Aluno=@Aluno,Nota1=@Nota1,Total1=@Total1,Nota2=@Nota2,Total2=@Total2,Situacao=@Situacao WHERE Codigo = @Codigo"; SqlCommand cmd = new SqlCommand(sql, con); cmd.Parameters.AddWithValue("@Codigo", oNota.Codigo); cmd.Parameters.AddWithValue("@Disciplina", oNota.Disciplina); cmd.Parameters.AddWithValue("@Aluno", oNota.Aluno); cmd.Parameters.AddWithValue("@Nota1", oNota.Nota1); cmd.Parameters.AddWithValue("@Total1", oNota.Total1); cmd.Parameters.AddWithValue("@Nota2", oNota.Nota2); cmd.Parameters.AddWithValue("@Total2", oNota.Total2); cmd.Parameters.AddWithValue("@Situacao", oNota.Situacao); con.Open(); try { cmd.ExecuteNonQuery(); } finally { con.Close(); } }
private void Eventos() { KeyDown += KeyDowns; KeyPreview = true; Load += (s, e) => { DataTableStart(); }; //GridLista.DoubleClick += (s, e) => MessageBox.Show(""); btnHelp.Click += (s, e) => Support.OpenLinkBrowser(Configs.LinkAjuda); btnAdicionar.Click += (s, e) => { Model.Nota _notaCCe = new Model.Nota(); //_notaCCe = _notaCCe.Query().Where("status", "Transmitindo...").Where("id", idNota).Where("excluir", 0).FirstOrDefault<Model.Nota>(); _notaCCe = _notaCCe.Query().Where("status", "Transmitindo...").Where("id_pedido", idPedido).Where("excluir", 0).FirstOrDefault <Model.Nota>(); if (_notaCCe != null) { Alert.Message("Ação não permitida", "Existe outra CCe transmitindo", Alert.AlertType.warning); return; } CartaCorrecaoAdd f = new CartaCorrecaoAdd(); f.TopMost = true; if (f.ShowDialog() == DialogResult.OK) { p1 = 1; WorkerBackground2.RunWorkerAsync(); } }; btnRetransmitir.Click += (s, e) => { //validação de registro com status Transmitindo... p1 = 1; WorkerBackground2.RunWorkerAsync(); }; imprimir.Click += (s, e) => { imprimir.Text = "Imprimindo..."; p1 = 2; WorkerBackground2.RunWorkerAsync(); }; btnRemover.Click += (s, e) => { Model.Nota _notaCCe = new Model.Nota(); _notaCCe = _notaCCe.Query().Where("id", Convert.ToInt32(GridLista.SelectedRows[0].Cells["ID"].Value)).Where("excluir", 0).First <Model.Nota>(); if (_notaCCe.Status != "Transmitindo...") { Alert.Message("Ação não permitida", "Exclusão não realizada", Alert.AlertType.warning); return; } var result = AlertOptions.Message("Atenção!", "Você está prestes a deletar uma carta de correção, continuar?", AlertBig.AlertType.warning, AlertBig.AlertBtn.YesNo); if (result) { _notaCCe.Excluir = 1; _notaCCe.Save(_notaCCe); DataTableStart(); } }; GridLista.CellFormatting += (s, e) => { }; using (var b = WorkerBackground) { b.DoWork += async(s, e) => { dataTable = await _cNota.GetDataTable(idPedido, idNota); }; b.RunWorkerCompleted += async(s, e) => { await _cNota.SetTable(GridLista, idPedido, idNota); }; } using (var b = WorkerBackground2) { b.DoWork += async(s, e) => { switch (p1) { case 1: _msg = new Controller.Fiscal().EmitirCCe(idPedido, idNota); break; case 2: var msg = new Controller.Fiscal().ImprimirCCe(idPedido, idNota); if (!msg.Contains(".pdf")) { _msg = msg; } break; } }; b.RunWorkerCompleted += async(s, e) => { switch (p1) { case 1: if (_msg.Contains("AUTORIZADA")) { //Alert.Message("Tudo certo!", "Carta de correção autorizada", Alert.AlertType.success);//AlertOptions.Message("Tudo certo!", "Carta de correção autorizada", AlertBig.AlertType.success, AlertBig.AlertBtn.OK); //MessageBox.Show("Carta de correção autorizada"); retorno.Text = "Carta de correção autorizada"; } else { //Alert.Message("Opss", _msg, Alert.AlertType.error); //AlertOptions.Message("Opss", _msg, AlertBig.AlertType.error, AlertBig.AlertBtn.OK); //MessageBox.Show(_msg); retorno.Text = _msg; } break; case 2: imprimir.Text = "Imprimir"; break; } DataTableStart(); p1 = 0; }; } }
public void Eventos() { Load += (s, e) => { var nota = new Model.Nota().FindById(idNota).FirstOrDefault <Model.Nota>(); if (nota == null) { return; } nsefaz.Text = (!String.IsNullOrEmpty(nota.nr_Nota)) ? nota.nr_Nota : ""; serie.Text = (!String.IsNullOrEmpty(nota.Serie)) ? nota.Serie : ""; status.Text = (!String.IsNullOrEmpty(nota.Status)) ? nota.Status : ""; chavedeacesso.Text = (!String.IsNullOrEmpty(nota.ChaveDeAcesso)) ? nota.ChaveDeAcesso : ""; Emitir.Visible = false; }; btnDetalhes.Click += (s, e) => { //Nota.disableCampos = true; Nota.Id = idNota; Nota nota = new Nota(); nota.TopMost = true; nota.ShowDialog(); }; Emitir.Click += (s, e) => { //var checkNota = _modelNota.FindByIdPedido(idPedido).WhereNotNull("status").Where("nota.tipo", "NFe").FirstOrDefault(); //var checkNota = _modelNota.FindByIdPedidoUltReg(idPedido, "", "NFe").FirstOrDefault<Model.Nota>(); var checkNota = new Model.Nota().FindById(idNota).FirstOrDefault <Model.Nota>(); if (checkNota == null) { Model.Nota _modelNotaNova = new Model.Nota(); _modelNotaNova.Id = 0; _modelNotaNova.Tipo = "NFe"; _modelNotaNova.Status = "Pendente"; _modelNotaNova.id_pedido = idPedido; _modelNotaNova.Save(_modelNotaNova, false); checkNota = new Model.Nota().FindByIdPedidoUltReg(idPedido, "", "NFe").FirstOrDefault <Model.Nota>(); } if (checkNota.Status == "Cancelada") { if (Home.pedidoPage == "Notas") { Alert.Message("Atenção!", "Não é possível emitir uma nota Autorizada/Cancelada.", Alert.AlertType.warning); return; } var result = AlertOptions.Message("Atenção!", "Existem registro(s) de nota(s) cancelada(s) a partir desta venda. Deseja gerar um nova nota?", AlertBig.AlertType.warning, AlertBig.AlertBtn.YesNo); if (result) { Model.Nota _modelNotaNova = new Model.Nota(); _modelNotaNova.Id = 0; _modelNotaNova.Tipo = "NFe"; _modelNotaNova.Status = "Pendente"; _modelNotaNova.id_pedido = idPedido; _modelNotaNova.Save(_modelNotaNova, false); checkNota = new Model.Nota().FindByIdPedidoUltReg(idPedido, "", "NFe").FirstOrDefault <Model.Nota>(); } } if (checkNota.Status != "Pendente") { Alert.Message("Atenção!", "Não é possível emitir uma nota Autorizada/Cancelada.", Alert.AlertType.warning); return; } _modelNota = checkNota; retorno.Text = "Emitindo NF-e .......................................... (1/2)"; if (p1 == 0) { p1 = 1; WorkerBackground.RunWorkerAsync(); } else { Alert.Message("Ação não permitida", "Aguarde processo finalizar", Alert.AlertType.warning); } }; CartaCorrecao.Click += (s, e) => { //var checkNota = new Model.Nota().FindByIdPedidoUltReg(idPedido, "", "NFe").FirstOrDefault<Model.Nota>(); var checkNota = new Model.Nota().FindById(idNota).FirstOrDefault <Model.Nota>(); if (checkNota == null || checkNota?.Status != "Autorizada") { Alert.Message("Ação não permitida!", "Não é possível emitir uma Carta de Correção.", Alert.AlertType.warning); return; } _modelNota = checkNota; CartaCorrecao cce = new CartaCorrecao(); cce.TopMost = true; cce.Show(); Application.OpenForms["OpcoesNfeRapida"].Close(); }; Cancelar.Click += (s, e) => { //var checkNota = new Model.Nota().FindByIdPedidoUltReg(idPedido, "", "NFe").FirstOrDefault<Model.Nota>(); var checkNota = new Model.Nota().FindById(idNota).FirstOrDefault <Model.Nota>(); if (checkNota == null || checkNota?.Status != "Autorizada") { Alert.Message("Ação não permitida!", "Não é possível cancelar uma nota Pendente/Cancelada.", Alert.AlertType.warning); return; } _modelNota = checkNota; CartaCorrecaoAdd.tela = "Cancelar"; CartaCorrecaoAdd f = new CartaCorrecaoAdd(); f.TopMost = true; if (f.ShowDialog() == DialogResult.OK) { CartaCorrecaoAdd.tela = ""; justificativa = CartaCorrecaoAdd.justificativa; retorno.Text = "Cancelando NF-e .......................................... (1/2)"; p1 = 4; WorkerBackground.RunWorkerAsync(); } }; EnviarEmail.Click += (s, e) => { //var checkNota = new Model.Nota().FindByIdPedidoUltReg(idPedido, "", "NFe").FirstOrDefault<Model.Nota>(); var checkNota = new Model.Nota().FindById(idNota).FirstOrDefault <Model.Nota>(); if (checkNota == null || checkNota?.Status == "Pendente") { Alert.Message("Ação não permitida!", "Não é possível enviar uma nota Pendente.", Alert.AlertType.warning); return; } _modelNota = checkNota; CartaCorrecaoAdd.tela = "Email"; CartaCorrecaoAdd.idNota = idNota; CartaCorrecaoAdd f = new CartaCorrecaoAdd(); f.TopMost = true; if (f.ShowDialog() == DialogResult.OK) { CartaCorrecaoAdd.tela = ""; justificativa = CartaCorrecaoAdd.justificativa; retorno.Text = "Enviando NF-e .......................................... (1/2)"; p1 = 5; WorkerBackground.RunWorkerAsync(); } }; Imprimir.Click += (s, e) => { var checkNota = new Model.Nota().FindByIdPedidoUltReg(idPedido, "", "NFe").FirstOrDefault <Model.Nota>(); if (checkNota == null || checkNota?.Status == "Pendente") { Alert.Message("Opps!", "Emita a nota para imprimir.", Alert.AlertType.warning); return; } _modelNota = checkNota; retorno.Text = "Imprimindo NF-e .......................................... (1/2)"; if (p1 == 0) { p1 = 2; WorkerBackground.RunWorkerAsync(); } else { Alert.Message("Ação não permitida", "Aguarde processo finalizar", Alert.AlertType.warning); } }; using (var b = WorkerBackground) { b.DoWork += async(s, e) => { switch (p1) { case 1: //_modelNota = _modelNota.FindByIdPedido(idPedido).FirstOrDefault<Model.Nota>(); //if (_modelNota == null) //{ // _modelNota.Id = 0; // _modelNota.id_pedido = idPedido; // _modelNota.Save(_modelNota); //} _msg = new Controller.Fiscal().Emitir(idPedido, "NFe", _modelNota.Id); break; case 2: if (IniFile.Read("NFe", "APP") != "Uninfe") { var msg = new Controller.Fiscal().Imprimir(idPedido, "NFe", _modelNota.Id); if (!msg.Contains(".pdf")) { _msg = msg; } } else { EmissorImprimirDanfe(); } break; case 3: //_msg = new Controller.Fiscal().EmitirCCe(idPedido, "Nota gerada com informacoes incorretas, por gentileza verificar as corretas"); break; case 4: if (justificativa.Length <= 15) { break; } _msg = new Controller.Fiscal().Cancelar(idPedido, "NFe", justificativa, _modelNota.Id); break; case 5: _msg = new Controller.Fiscal().EnviarEmail(idPedido, justificativa, "NFe", _modelNota.Id); break; } }; b.RunWorkerCompleted += async(s, e) => { p1 = 0; if (!String.IsNullOrEmpty(_msg)) { retorno.Text = _msg; } }; } FormClosing += (s, e) => { OpcoesNfeRapida.idPedido = 0; OpcoesNfeRapida.idNota = 0; }; }
public void Eventos() { Load += (s, e) => { if (idNota == 0) { return; } var nota = new Model.Nota().FindById(idNota).FirstOrDefault <Model.Nota>(); if (nota == null) { return; } var pedido = new Model.Pedido().FindById(nota.id_pedido).FirstOrDefault <Model.Pedido>(); if (pedido == null) { return; } var pessoaContato = new Model.PessoaContato().FindByIdUser(pedido.Cliente).Get(); if (pessoaContato == null) { return; } foreach (var item in pessoaContato) { if (String.IsNullOrEmpty(correcao.Text)) { correcao.Text = item.EMAIL + ";"; } else { correcao.Text = correcao.Text + item.EMAIL + ";"; } } correcao.Text = correcao.Text.ToLower(); }; btnSalvar.Click += (s, e) => { if (CartaCorrecaoAdd.tela == "Cancelar") { if (correcao.Text.Length < 15) { Alert.Message("Ação não permitida", "Justificativa deve conter 15 caracteres", Alert.AlertType.warning); return; } CartaCorrecaoAdd.justificativa = correcao.Text; DialogResult = DialogResult.OK; Close(); return; } if (CartaCorrecaoAdd.tela == "Email") { CartaCorrecaoAdd.justificativa = correcao.Text; DialogResult = DialogResult.OK; Close(); return; } if (correcao.Text.Length < 15) { Alert.Message("Ação não permitida", "Correção deve conter 15 caracteres", Alert.AlertType.warning); return; } _modelNota.Id = 0; _modelNota.Tipo = "CCe"; _modelNota.Status = "Transmitindo..."; _modelNota.id_pedido = CartaCorrecao.idPedido; _modelNota.correcao = correcao.Text; _modelNota.correcao = Validation.CleanStringForFiscal(Validation.OneSpaceString(_modelNota.correcao)); _modelNota.Save(_modelNota, false); DialogResult = DialogResult.OK; Close(); }; btnCancelar.Click += (s, e) => { DialogResult = DialogResult.Cancel; Close(); }; correcao.TextChanged += (s, e) => { caracteres.Text = correcao.Text.Length.ToString(); }; }
private void Eventos() { KeyDown += KeyDowns; KeyPreview = true; Load += (s, e) => { if (_mPedido.Cliente == 0) { TelaDados.telaDados = false; } Resolution.SetScreenMaximized(this); if (Id > 0) { _mNota = _mNota.FindById(Id).FirstOrDefault <Model.Nota>(); _mPedido = _mPedido.FindById(_mNota.id_pedido).FirstOrDefault <Model.Pedido>(); } else { if (OpcoesNfeRapida.idPedido > 0) { _mNota.Id = 0; _mNota.id_pedido = OpcoesNfeRapida.idPedido; _mNota.Tipo = "NFe"; _mNota.Status = "Pendente"; _mNota.Save(_mNota, false); Id = _mNota.GetLastId(); } else { _mPedido.Id = 0; _mPedido.Tipo = "NFe"; _mPedido.Save(_mPedido); _mNota.Id = 0; _mNota.id_pedido = _mPedido.GetLastId(); _mNota.Tipo = "NFe"; _mNota.Status = "Pendente"; _mNota.Save(_mNota, false); Id = _mNota.GetLastId(); } } OpenForm.ShowInPanel <TelasNota.TelaDados>(panelTelas); }; FormClosing += (s, e) => { OpcoesNfeRapida.idPedido = 0; _mNota = new Model.Nota().FindById(Id).FirstOrDefault <Model.Nota>(); if (_mNota == null) { Close(); } if (_mPedido != null) { if (_mNota.id_pedido > 0) { _mPedido = _mPedido.FindById(_mNota.id_pedido).FirstOrDefault <Model.Pedido>(); } } if (_mNota.Status == "Pendente") { if (!TelaDados.telaDados) { var result = AlertOptions.Message("Atenção!", "Você está prestes a excluir! Deseja continuar?", AlertBig.AlertType.warning, AlertBig.AlertBtn.YesNo); if (result) { //if (Id > 0) //{ // _mPedido.Excluir = 1; // if (_mPedido.Save(_mPedido)) // { // _mNota.Excluir = 1; // _mNota.Save(_mNota, false); // } // TelaDados.telaDados = true; // Close(); //} if (_mPedido != null) { if (_mPedido.Tipo == "NFe") { _mPedido.Excluir = 1; _mPedido.Save(_mPedido); } } if (_mNota != null) { _mNota.Excluir = 1; _mNota.id_pedido = 0; _mNota.Save(_mNota, false); } } } } }; }
private void Eventos() { Back.Click += (s, e) => Close(); Emitir.Click += (s, e) => { //_mNota = new Model.Nota().FindByIdPedido(Id).FirstOrDefault<Model.Nota>(); if (_mNota.Status != "Pendente") { Alert.Message("Atenção!", "Não é possível emitir uma nota Autorizada/Cancelada.", Alert.AlertType.warning); return; } retorno.Text = "Emitindo NF-e .......................................... (1/2)"; Emitir.Enabled = false; WorkerBackground.RunWorkerAsync(); }; Imprimir.Click += (s, e) => { retorno.Text = new Controller.Fiscal().Imprimir(Id, "NFe", _mNota.Id); }; EnviarEmail.Click += (s, e) => { var checkNota = _mNota.FindByIdPedidoUltReg(Id, "", "NFe").FirstOrDefault <Model.Nota>(); if (checkNota.Status != "Autorizada") { Alert.Message("Ação não permitida!", "Não é possível enviar uma nota Pendente.", Alert.AlertType.warning); return; } _mNota = checkNota; CartaCorrecaoAdd.tela = "Email"; CartaCorrecaoAdd f = new CartaCorrecaoAdd(); f.TopMost = true; if (f.ShowDialog() == DialogResult.OK) { CartaCorrecaoAdd.tela = ""; justificativa = CartaCorrecaoAdd.justificativa; retorno.Text = "Enviando NF-e .......................................... (1/2)"; p1 = 5; WorkerBackground.RunWorkerAsync(); } }; using (var b = WorkerBackground) { b.DoWork += async(s, e) => { if (p1 == 5) { _msg = new Controller.Fiscal().EnviarEmail(Id, justificativa, "NFe", _mNota.Id); } else { _msg = new Controller.Fiscal().Emitir(Id, "NFe", _mNota.Id, false); } }; b.RunWorkerCompleted += async(s, e) => { p1 = 0; retorno.Text = _msg; Emitir.Enabled = true; }; } }
private void Eventos() { KeyDown += KeyDowns; KeyPreview = true; Load += (s, e) => { Filter(); dataInicial.Text = Validation.DateNowToSql(); dataFinal.Text = Validation.DateNowToSql(); }; btnAdicionar.Click += (s, e) => Edit(true); btnEditar.Click += (s, e) => Edit(); GridLista.DoubleClick += (s, e) => Edit(); btnExit.Click += (s, e) => Close(); dataInicial.ValueChanged += (s, e) => Filter(); dataFinal.ValueChanged += (s, e) => Filter(); status.SelectedValueChanged += (s, e) => Filter(); btnHelp.Click += (s, e) => Support.OpenLinkBrowser(Configs.LinkAjuda); btnRetransmitir.Click += (s, e) => { if (p1 == 0) { p1 = 1; WorkerBackground.RunWorkerAsync(); } }; btnRemover.Click += (s, e) => { Model.Nota _nota = new Model.Nota(); _nota = _nota.Query().Where("status", "Transmitindo...").Where("excluir", 0).First <Model.Nota>(); if (_nota != null) { Alert.Message("Ação não permitida", "Exclusão não realizada", Alert.AlertType.warning); return; } var result = AlertOptions.Message("Atenção!", "Você está prestes a deletar, deseja continuar?", AlertBig.AlertType.warning, AlertBig.AlertBtn.YesNo); if (result) { _nota.Excluir = 1; _nota.Save(_nota); Filter(); } }; WorkerBackground.RunWorkerAsync(); //imprimir.Click += async (s, e) => await RenderizarAsync(); using (var b = WorkerBackground) { b.DoWork += async(s, e) => { _msg = new Controller.Fiscal().EmitirInutiliza(); }; b.RunWorkerCompleted += async(s, e) => { p1 = 0; if (String.IsNullOrEmpty(_msg)) { return; } else if (_msg.Contains("Inutilização de número homologado")) { Alert.Message("Tudo certo!", "Inutilização de número homologado", Alert.AlertType.success);//AlertOptions.Message("Tudo certo!", "Carta de correção autorizada", AlertBig.AlertType.success, AlertBig.AlertBtn.OK); } else { Alert.Message("Opss", _msg, Alert.AlertType.error);//AlertOptions.Message("Opss", _msg, AlertBig.AlertType.error, AlertBig.AlertBtn.OK); } Filter(); }; } }