示例#1
0
        public void finaliza_venda()
        {
            if (MessageBox.Show("Deseja realmente finalizar esta venda ?", "Confirmar", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
            {
                try{
                    if (Int32.Parse(dg_venda.Rows[0].Cells[0].Value.ToString()) > 0)
                    {
                        Zenfox_Software_OO.Cadastros.Entidade_Vendas vendas = new Zenfox_Software_OO.Cadastros.Entidade_Vendas();
                        vendas.produtos = new List <Zenfox_Software_OO.Cadastros.Entidade_Vendas_Produtos>();


                        foreach (DataGridViewRow row in dg_venda.Rows)
                        {
                            try {
                                vendas.valor_total += Double.Parse(row.Cells[3].Value.ToString());
                                Zenfox_Software_OO.Cadastros.Entidade_Vendas_Produtos produtos = new Zenfox_Software_OO.Cadastros.Entidade_Vendas_Produtos();

                                produtos.produto    = Int32.Parse(row.Cells[0].Value.ToString());
                                produtos.quantidade = Int32.Parse(row.Cells[2].Value.ToString());

                                vendas.produtos.Add(produtos);
                            }
                            catch
                            {
                                vendas.valor_total += 0;
                            }
                        }

                        Zenfox_Software_OO.Cadastros.Vendas vcmd = new Zenfox_Software_OO.Cadastros.Vendas();
                        Int32 id = vcmd.cadastra(vendas);

                        Caixa_Fechamento cmd = new Caixa_Fechamento(id);
                        cmd.ShowDialog();

                        if (cmd.vendido)
                        {
                            limpa_venda(true);
                        }
                    }
                    else
                    {
                        MessageBox.Show("É necessario ter pelo menos 1 item para finalizar a venda !");
                    }
                }
                catch (Exception ee)
                {
                    MessageBox.Show("É necessario ter pelo menos 1 item para finalizar a venda !");
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Int32 id = Int32.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString());

            Zenfox_Software_OO.Cadastros.Vendas          cmd  = new Zenfox_Software_OO.Cadastros.Vendas();
            Zenfox_Software_OO.Cadastros.Entidade_Vendas item = cmd.seleciona(new Zenfox_Software_OO.Cadastros.Entidade_Vendas()
            {
                id = id
            });

            String xml = "SAT.ImprimirExtratoVenda(\"" + item.xml + "\");";

            System.IO.File.WriteAllText("C:/Rede_Sistema/ENT.txt", xml.Replace("\\\"", "'"));

            File.Delete("C:/Rede_Sistema/sai.txt");
        }
示例#3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Int32 id = Int32.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString());

            Zenfox_Software_OO.Cadastros.Vendas          cmd  = new Zenfox_Software_OO.Cadastros.Vendas();
            Zenfox_Software_OO.Cadastros.Entidade_Vendas item = cmd.seleciona(new Zenfox_Software_OO.Cadastros.Entidade_Vendas()
            {
                id = id
            });

            String xml = "SAT.CancelarCFe(\"" + item.xml + "\");";



            System.IO.File.WriteAllText("C:/Rede_Sistema/ENT.txt", xml.Replace("\\\"", "'"));


            #region verificando se arquivo existe
            Boolean arquivo_existe = false;

            Thread.Sleep(1000);
            if (File.Exists("C:/Rede_Sistema/sai.txt"))
            {
                arquivo_existe = true;
            }

            if (!arquivo_existe)
            {
                Thread.Sleep(1000);
            }
            if (File.Exists("C:/Rede_Sistema/sai.txt") && arquivo_existe == false)
            {
                arquivo_existe = true;
            }

            if (!arquivo_existe)
            {
                Thread.Sleep(2000);
            }
            if (File.Exists("C:/Rede_Sistema/sai.txt") && arquivo_existe == false)
            {
                arquivo_existe = true;
            }

            if (!arquivo_existe)
            {
                Thread.Sleep(2000);
            }
            if (File.Exists("C:/Rede_Sistema/sai.txt") && arquivo_existe == false)
            {
                arquivo_existe = true;
            }

            if (!arquivo_existe)
            {
                Thread.Sleep(3000);
            }
            if (File.Exists("C:/Rede_Sistema/sai.txt") && arquivo_existe == false)
            {
                arquivo_existe = true;
            }

            if (!arquivo_existe)
            {
                Thread.Sleep(3000);
            }
            if (File.Exists("C:/Rede_Sistema/sai.txt") && arquivo_existe == false)
            {
                arquivo_existe = true;
            }

            if (!arquivo_existe)
            {
                Thread.Sleep(5000);
            }
            if (File.Exists("C:/Rede_Sistema/sai.txt") && arquivo_existe == false)
            {
                arquivo_existe = true;
            }

            if (!arquivo_existe)
            {
                Thread.Sleep(5000);
            }
            if (File.Exists("C:/Rede_Sistema/sai.txt") && arquivo_existe == false)
            {
                arquivo_existe = true;
            }

            if (!arquivo_existe)
            {
                Thread.Sleep(10000);
            }
            if (File.Exists("C:/Rede_Sistema/sai.txt") && arquivo_existe == false)
            {
                arquivo_existe = true;
            }

            if (!arquivo_existe)
            {
                Thread.Sleep(10000);
            }
            if (File.Exists("C:/Rede_Sistema/sai.txt") && arquivo_existe == false)
            {
                arquivo_existe = true;
            }

            #endregion

            string[] lines = File.ReadAllLines("C:/Rede_Sistema/sai.txt");
            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i].Contains("codigoDeRetorno="))
                {
                    xml = lines[i].Substring(4);
                }
            }

            if (xml.Contains("7000"))
            {
                //excluirsat(ven_id);
                xml = "SAT.ImprimirExtratoCancelamento(\"" + item.xml + "\");";
                System.IO.File.WriteAllText(@"C:\Rede_Sistema\ENT.txt", xml);
                //return ok;
            }
            else
            {
                MessageBox.Show("Não foi possivel cancelas esse cupom fiscal, verifique se ele esta dentro do período de cancelamento !");
            }

            File.Delete("C:/Rede_Sistema/sai.txt");
        }