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()); }
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(); }; } }
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; }; } }