예제 #1
0
        private void button10_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(textBox14.Text) == false && String.IsNullOrEmpty(textBox15.Text) == false)
            {
                //string teste = "";
                if (checkBox10.Checked == true)
                {
                    //teste = "sim";
                    using (StreamWriter writer = new StreamWriter("SI.txt"))
                    {
                        writer.Write("sim");
                        Global.Margem.ServidorImpressao = "sim";
                        MessageBox.Show("Servidor de Impressão Ativado.\nEsta mudança requer reinicialização.");
                        Application.Exit();
                    }
                }
                if (checkBox10.Checked == false)
                {
                    //teste = "não";
                    using (StreamWriter writer = new StreamWriter("SI.txt"))
                    {
                        writer.Write("não");
                        Global.Margem.ServidorImpressao = "não";
                        MessageBox.Show("Servidor de Impressão Desativado.\nEsta mudança requer reinicialização.");
                        Application.Exit();
                    }
                }
                //Configura tipo de impressora
                if (checkBox11.Checked == true)
                {
                    using (StreamWriter writer = new StreamWriter("Impressora.txt"))
                    {
                        writer.Write("generic");
                        Global.Margem.Impressora = "generic";
                        MessageBox.Show("Driver Generic Text Only Ativado.\nEsta mudança requer reinicialização.");
                        Application.Exit();
                    }
                }
                if (checkBox12.Checked == true)
                {
                    using (StreamWriter writer = new StreamWriter("Impressora.txt"))
                    {
                        writer.Write("mp4200th");
                        Global.Margem.Impressora = "mp4200th";
                        MessageBox.Show("Driver para Impressora MP4200 TH Ativado.\nEsta mudança requer reinicialização.");
                        Application.Exit();
                    }
                }

                //Insere Texto do Cupom
                string Empresa = textBox14.Text;
                string Cnpj    = textBox15.Text;
                string Ie      = "";
                if (String.IsNullOrEmpty(textBox18.Text) == true)
                {
                    Ie = "vazio";
                }
                if (String.IsNullOrEmpty(textBox18.Text) == false)
                {
                    Ie = textBox18.Text;
                }
                string texto1 = "";
                if (String.IsNullOrEmpty(textBox17.Text) == true)
                {
                    texto1 = "vazio";
                }
                if (String.IsNullOrEmpty(textBox17.Text) == false)
                {
                    texto1 = textBox17.Text;
                }
                string texto2 = "";
                if (String.IsNullOrEmpty(textBox16.Text) == true)
                {
                    texto2 = "vazio";
                }
                if (String.IsNullOrEmpty(textBox16.Text) == false)
                {
                    texto2 = textBox16.Text;
                }
                DataTable testa = DALCadastro.ExisteTextoCupom();
                if (testa.Rows.Count <= 0)
                {
                    DALCadastro.CriaTextoCupom(Empresa, Cnpj, Ie, texto1, texto2);
                }
                if (testa.Rows.Count > 0)
                {
                    DALCadastro.InsereTextoCupom(Empresa, Cnpj, Ie, texto1, texto2);
                }
                MessageBox.Show("Dados inseridos com sucesso\n" + "Empresa : " + Empresa + "\n" +
                                "CNPJ : " + Cnpj + "\n" + "IE : " + Ie + "\n" + "Texto Adicional1 : " + texto1 + "\n" +
                                "Texto Adicional2 : " + texto2);
            }
            else
            {
                MessageBox.Show("Campo obrigatório não preenchido");
            }
        }