private void txtDescontoPer_KeyUp(object sender, KeyEventArgs e) { try { switch (e.KeyCode) { case Keys.Escape: this.Close(); break; case Keys.Enter: if (txtDescontoPer.Text == String.Empty) { throw new Exception("Informe o valor de desconto ou ESC para sair."); } valorDesconto = decimal.Parse(txtDescontoPer.Text); string autoriza = "não"; if (valorDesconto > 20) { verificacaoUsuario frm = new verificacaoUsuario(); frm.ShowDialog(); if (frm.permissao != "Gerente") { throw new Exception("Você não tem permissão para realizar essa rotina procure o administrador do sistema!"); frm = null; autoriza = "Sim"; } else { //TotalDescontoReais = valorDesconto * valorTotal / 100; TotalDescontoReais = Math.Round(((valorTotal * valorDesconto) / 100), 2); this.Close(); } } else { TotalDescontoReais = Math.Round(((valorTotal * valorDesconto) / 100), 2); this.Close(); } break; } } catch (Exception) { throw; } }
private void button1_Click(object sender, EventArgs e) { bool ok = true; try { verificacaoUsuario frmVerifi = new verificacaoUsuario(); frmVerifi.ShowDialog(); if (frmVerifi.permissao == "Cancelar") { ok = false; } if (frmVerifi.permissao != "Gerente") { MessageBox.Show("Você não tem permissão para realizar essa rotina procure o administrador do sistema!"); ok = false; throw new Exception(); } Int32 id = Int32.Parse(gridVendas.CurrentRow.Cells[0].Value.ToString()); if (id <= 0) { MessageBox.Show("Falha ao imprimir cupom !"); ok = false; return; } //CConfiguracao configuracao = new CConfiguracao(); VendasBLL OjbVend = new VendasBLL(); objVen.codigo = id; objVen.retorna_xml(); String xml = objVen.xml; xml = "SAT.ImprimirExtratoVenda(\"" + xml + "\");"; string codigoDeRetorno = this.retornoSAT("codigoDeRetorno"); string numeroSessao = this.retornoSAT("numeroSessao"); System.IO.File.WriteAllText("C:\\Rede_Sistema\\ENT.txt", xml); } catch (Exception err) { ok = false; } }
private void button1_Click(object sender, EventArgs e) { bool ok = true; try { verificacaoUsuario frmVerifi = new verificacaoUsuario(); frmVerifi.ShowDialog(); if (frmVerifi.permissao == "Cancelar") { ok = false; } if (frmVerifi.permissao != "Gerente") { MessageBox.Show("Você não tem permissão para realizar essa rotina procure o administrador do sistema!"); ok = false; throw new Exception(); } Int32 id = Int32.Parse(gridVendas.CurrentRow.Cells[0].Value.ToString()); if (id <= 0) { MessageBox.Show(""); ok = false; return; } codigo_compra = gridVendas.CurrentRow.Cells[0].Value.ToString(); String[] xdata = gridVendas.CurrentRow.Cells[2].Value.ToString().Split(' '); String data = xdata[0]; String hora = xdata[1]; //CConfiguracao configuracao = new CConfiguracao(); VendasBLL OjbVend = new VendasBLL(); objVen.codigo = id; objVen.retorna_xml(); //obj String xml = objVen.xml; // if (xml.Length > 0) { if (hora.Trim().Length > 0) { try { DateTime horavenda = DateTime.Parse(hora); DateTime datavenda = DateTime.Parse(data); horavenda = horavenda.AddMinutes(31); if (DateTime.Now.Date == datavenda.Date) { if (horavenda.TimeOfDay > DateTime.Now.TimeOfDay) { string xmlpuro = xml; xml = "SAT.CancelarCFe(\"" + xmlpuro + "\");"; System.IO.File.WriteAllText(parametroSat("caminhocupomtxt"), xml); int sleep = 3000; int.TryParse(parametroSat("sleep"), out sleep); System.Threading.Thread.Sleep(sleep); string retorno = retornoSAT("codigoDeRetorno"); if (retorno.Contains("7000")) { //excluirsat(ven_id); xml = "SAT.ImprimirExtratoCancelamento(\"" + xmlpuro + "\");"; System.IO.File.WriteAllText(@"C:\Rede_Sistema\ENT.txt", xml); //return ok; } else { ok = false; } } else { MessageBox.Show("Notas fiscais não podem ser canceladas após 30 minutos de sua emissão !"); ok = false; } } else { ok = false; } } catch { ok = false; } } } //ok = false; //return ok; } catch (Exception err) { ok = false; } if (ok) { objVen.limpar(); objVen.codigo = Int32.Parse(codigo_compra); objVen.ven_status = "Cancelado"; //txtCodigo.Text = frmCancelaCupom.Codigo; objVen.cancelarVenda(global.codUsuario); DataTable tab = null; tab = objVen.localizarCupom(global.codUsuario); gridVendas.DataSource = tab; // stiloGrid(); gridVendas.ClearSelection(); } }