private void button3_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(textBox1.Text) == false && textBox1.ReadOnly == true && textBox1.Text != "SELECIONAR")
            {
                string resul = Convert.ToString(DALCadastro.ProcuraAUXCad("ExcluiCadAUXModelo", textBox1.Text));
                if (String.IsNullOrEmpty(resul) == false)
                {
                    MessageBox.Show("Descrição não pode ser excluída, porque existem produtos cadastrados que a utilizam");
                    textBox1.Text     = "";
                    textBox1.ReadOnly = true;
                    label3.Text       = "";
                }
                if (String.IsNullOrEmpty(resul) == true)
                {
                    string            message = "Você deseja excluír ==> " + textBox1.Text;
                    string            caption = "Exclusão";
                    MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                    DialogResult      result;

                    // Mostra a MessageBox.

                    result = MessageBox.Show(this, message, caption, buttons,
                                             MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

                    if (result == DialogResult.Yes)
                    {
                        DALCadastro.ExcluiCadAUX("ExcluiModelo", label3.Text);
                        dataGridView1.DataSource = DALCadastro.AUXCadListar("ListarCadModelo");
                    }
                }
            }
            else
            {
                MessageBox.Show("Selecione um registro para exclusão");
            }
        }
 private void AUXCadModelo_Load(object sender, EventArgs e)
 {
     dataGridView1.DataSource = DALCadastro.AUXCadListar("ListarCadModelo");
 }
 private void AUXCadFinalidade_Load(object sender, EventArgs e)
 {
     dataGridView1.DataSource = DALCadastro.AUXCadListar("Listar_Finalidade");
 }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            textBox2.Text = textBox2.Text.Replace(".", "");
            if (textBox1.ReadOnly == false && String.IsNullOrEmpty(textBox1.Text) == false &&
                textBox2.ReadOnly == false && String.IsNullOrEmpty(textBox2.Text) == false)
            {
                Int64 qtde;
                if (Int64.TryParse(textBox2.Text.Trim(), out qtde) == false)
                {
                    MessageBox.Show("Favor informar somente valores numéricos no campo \ncódigo NCM.");
                    textBox2.Text = "";
                    textBox2.Focus();
                    return;
                }

                if (dataGridView1.Rows.Count > 0)
                {
                    for (int i = 0; i < dataGridView1.Rows.Count; i++)
                    {
                        if (textBox2.Text == dataGridView1.Rows[i].Cells[0].Value.ToString())
                        {
                            MessageBox.Show("Código já cadastrado anteriormente.");
                            return;
                        }
                    }
                    string            message = "Você deseja cadastrar este Código NCM : \n" + textBox2.Text + " ?";
                    string            caption = "NCM";
                    MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                    DialogResult      result;

                    // Displays the MessageBox.
                    result = MessageBox.Show(this, message, caption, buttons,
                                             MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                    if (result == DialogResult.Yes)
                    {
                        DALCadastro.CriarCadNCM(textBox2.Text, textBox1.Text);
                        dataGridView1.DataSource = DALCadastro.AUXCadListar("ListarCadNCM");
                        MessageBox.Show("Código : " + textBox2.Text + "\n" + textBox1.Text + "\nincluído com sucesso.");
                        string cod = textBox2.Text;
                        textBox1.ReadOnly = true;
                        textBox1.Text     = "";
                        textBox2.ReadOnly = true;
                        textBox2.Text     = "";
                        if (dataGridView1.Rows.Count > 0)
                        {
                            for (int i = 0; i < dataGridView1.Rows.Count; i++)
                            {
                                if (dataGridView1.Rows[i].Cells[0].Value.ToString() == cod)
                                {
                                    dataGridView1.CurrentCell = dataGridView1.Rows[i].Cells[0];
                                    textBox2.Text             = dataGridView1.Rows[i].Cells[0].Value.ToString();
                                    textBox1.Text             = dataGridView1.Rows[i].Cells[1].Value.ToString();
                                    button4.Focus();
                                    return;
                                }
                            }
                        }
                    }
                }
                else
                {
                    string            message = "Você deseja cadastrar este Código NCM : \n" + textBox2.Text + " ?";
                    string            caption = "NCM";
                    MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                    DialogResult      result;

                    // Displays the MessageBox.
                    result = MessageBox.Show(this, message, caption, buttons,
                                             MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                    if (result == DialogResult.Yes)
                    {
                        DALCadastro.CriarCadNCM(textBox2.Text, textBox1.Text);
                        dataGridView1.DataSource = DALCadastro.AUXCadListar("ListarCadNCM");
                        MessageBox.Show("Código : " + textBox2.Text + "\n" + textBox1.Text + "\nincluído com sucesso.");
                        textBox1.ReadOnly = true;
                        textBox1.Text     = "";
                        textBox2.ReadOnly = true;
                        textBox2.Text     = "";
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void Config_Load(object sender, EventArgs e)
        {
            this.Text += "   Operador ==>  " + Global.Margem.Operador;
            if (Global.Margem.ServidorImpressao == "sim")
            {
                checkBox10.Checked = true;
            }
            dataGridView3.DataSource = DALCadastro.AUXCadListar("ListarCadEmpresa");

            DataTable cor10 = DALCadastro.CoresRetorna(Global.Margem.Operador.ToString());

            if (cor10.Rows.Count > 0)
            {
                panel1.BackColor   = System.Drawing.Color.FromArgb(Convert.ToInt32(cor10.Rows[0]["CorMenu"].ToString()));
                panel2.BackColor   = System.Drawing.Color.FromArgb(Convert.ToInt32(cor10.Rows[0]["Cor2"].ToString()));
                tabPage3.BackColor = System.Drawing.Color.FromArgb(Convert.ToInt32(cor10.Rows[0]["Cor3"].ToString()));
                tabPage1.BackColor = System.Drawing.Color.FromArgb(Convert.ToInt32(cor10.Rows[0]["Cor3"].ToString()));
                tabPage2.BackColor = System.Drawing.Color.FromArgb(Convert.ToInt32(cor10.Rows[0]["Cor3"].ToString()));
            }
            DataTable inicio = DALCadastro.TestaConfiVazia("1");

            if (inicio.Rows.Count > 0)
            {
                textBox9.Text  = inicio.Rows[0]["Campo1"].ToString();
                textBox10.Text = inicio.Rows[0]["Campo2"].ToString();
                textBox11.Text = inicio.Rows[0]["Campo3"].ToString();
            }
            inicio.Clear();
            inicio = DALCadastro.TestaConfiVazia("2");
            if (inicio.Rows.Count > 0)
            {
                string teste = inicio.Rows[0]["Campo1"].ToString();
                if (teste == "sim")
                {
                    checkBox3.Checked = true;
                }
                if (teste == "não")
                {
                    checkBox3.Checked = false;
                }
            }
            inicio.Clear();
            inicio = DALCadastro.TestaConfiVazia("3");
            if (inicio.Rows.Count > 0)
            {
                string teste = inicio.Rows[0]["Campo1"].ToString();
                if (teste == "sim")
                {
                    checkBox6.Checked = true;
                }
                if (teste == "não")
                {
                    checkBox6.Checked = false;
                }
            }
            inicio.Clear();
            inicio = DALCadastro.TestaConfiVazia("4");
            if (inicio.Rows.Count > 0)
            {
                string teste = inicio.Rows[0]["Campo1"].ToString();
                if (teste == "sim")
                {
                    checkBox4.Checked = true;
                }
                if (teste == "tv")
                {
                    checkBox4.Checked = false;
                    checkBox7.Checked = true;
                    checkBox7.Visible = true;
                }
                if (teste == "caixa")
                {
                    checkBox4.Checked = false;
                    checkBox9.Checked = true;
                    checkBox9.Visible = true;
                }
            }


            if (Global.Margem.ConfiguraçãoSistemaBancoDados == "local")
            {
                checkBox8.Checked = true;
            }
            if (Global.Margem.ConfiguraçãoSistemaBancoDados == "rede")
            {
                checkBox8.Checked = false;
                textBox12.Text    = Global.Margem.ConfiguraçãoSistemaBancoDadosIp;
                textBox13.Text    = Global.Margem.ConfiguraçãoSistemaBancoDadosPorta;
            }
            if (Global.Margem.Impressora == "generic")
            {
                checkBox11.Checked = true;
            }
            if (Global.Margem.Impressora == "mp4200th")
            {
                checkBox12.Checked = true;
            }
        }