Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string nome = Global.Margem.OperadorTemp;

            string senha       = Global.Margem.SenhaCadastroUsuarioTemp;
            string admistrador = "";

            if (checkBox1.Checked == true)
            {
                admistrador = "sim";
            }
            if (checkBox1.Checked == false)
            {
                admistrador = "não";
            }
            //cad usuarios
            string cadUsr = "";

            if (checkBox8.Checked == true)
            {
                //normal
                cadUsr = "******";
            }
            if (checkBox7.Checked == true)
            {
                //total
                cadUsr = "******";
            }
            if (checkBox8.Checked == false && checkBox7.Checked == false)
            {
                cadUsr = "******";
            }
            //cad produtos
            string cadPro = "";

            if (checkBox2.Checked == true)
            {
                //normal
                cadPro = "sim";
            }
            if (checkBox5.Checked == true)
            {
                //total
                cadPro = "adm";
            }
            if (checkBox2.Checked == false && checkBox5.Checked == false)
            {
                cadPro = "não";
            }
            //cad participantes
            string cadPart = "";

            if (checkBox10.Checked == true)
            {
                //normal
                cadPart = "sim";
            }
            if (checkBox11.Checked == true)
            {
                //total
                cadPart = "adm";
            }
            if (checkBox10.Checked == false && checkBox11.Checked == false)
            {
                cadPart = "não";
            }
            //caixa
            string caixa = "";

            if (checkBox14.Checked == true)
            {
                //normal
                caixa = "sim";
            }
            if (checkBox15.Checked == true)
            {
                //total
                caixa = "adm";
            }
            if (checkBox14.Checked == false && checkBox15.Checked == false)
            {
                caixa = "não";
            }
            //logs
            string log = "";

            if (checkBox18.Checked == true)
            {
                //normal
                log = "sim";
            }
            if (checkBox19.Checked == true)
            {
                //total
                log = "adm";
            }
            if (checkBox18.Checked == false && checkBox19.Checked == false)
            {
                log = "não";
            }
            //fluxo de caixa
            string fluxoCaixa1 = "";

            if (checkBox22.Checked == true)
            {
                //normal
                fluxoCaixa1 = "sim";
            }
            if (checkBox23.Checked == true)
            {
                //total
                fluxoCaixa1 = "adm";
            }
            if (checkBox22.Checked == false && checkBox23.Checked == false)
            {
                fluxoCaixa1 = "não";
            }
            //contas a pagar
            string contas = "";

            if (checkBox26.Checked == true)
            {
                //normal
                contas = "sim";
            }
            if (checkBox27.Checked == true)
            {
                //total
                contas = "adm";
            }
            if (checkBox26.Checked == false && checkBox27.Checked == false)
            {
                contas = "não";
            }
            //contas a receber
            string contasRec = "";

            if (checkBox30.Checked == true)
            {
                //normal
                contasRec = "sim";
            }
            if (checkBox31.Checked == true)
            {
                //total
                contasRec = "adm";
            }
            if (checkBox30.Checked == false && checkBox31.Checked == false)
            {
                contasRec = "não";
            }
            //conf sistema
            string conf = "";

            if (checkBox34.Checked == true)
            {
                //normal
                conf = "sim";
            }
            if (checkBox35.Checked == true)
            {
                //total
                conf = "adm";
            }
            if (checkBox34.Checked == false && checkBox35.Checked == false)
            {
                conf = "não";
            }
            if (checkBox8.Checked == true && checkBox2.Checked == true && checkBox10.Checked == true && checkBox14.Checked == true &&
                checkBox18.Checked == true && checkBox22.Checked == true && checkBox26.Checked == true && checkBox30.Checked == true &&
                checkBox34.Checked == true)
            {
                checkBox1.Checked = false;
                admistrador       = "não";
            }
            if (Global.Margem.editaUsrSist == "novo")
            {
                //cod para inserir
                DALCadastro.InsereUsrSistema(nome, senha, admistrador, cadUsr, cadPro, cadPart, caixa, log, fluxoCaixa1, contas, contasRec, conf);
                this.Close();
            }
            if (Global.Margem.editaUsrSist == "edita")
            {
                DALCadastro.InsereUsrSistemaEdita(Convert.ToInt32(Global.Margem.intCadUsr), admistrador, cadUsr, cadPro, cadPart,
                                                  caixa, log, fluxoCaixa1, contas, contasRec, conf);
                if (Global.Margem.OperadorTemp == Global.Margem.Operador)
                {
                    string id7 = Global.Margem.intCadUsr;
                    Global.Margem.Administrador         = Convert.ToString(DALCadastro.carregaPermissao("CarregaADM", Convert.ToInt32(id7)));
                    Global.Margem.CadastroUsuarios      = Convert.ToString(DALCadastro.carregaPermissao("CarregaUm", Convert.ToInt32(id7)));
                    Global.Margem.CadastroProdutos      = Convert.ToString(DALCadastro.carregaPermissao("CarregaDois", Convert.ToInt32(id7)));
                    Global.Margem.CadastroParticipantes = Convert.ToString(DALCadastro.carregaPermissao("CarregaTres", Convert.ToInt32(id7)));
                    Global.Margem.CaixaTerminalVendas   = Convert.ToString(DALCadastro.carregaPermissao("CarregaQuatro", Convert.ToInt32(id7)));
                    Global.Margem.Logs                = Convert.ToString(DALCadastro.carregaPermissao("CarregaCinco", Convert.ToInt32(id7)));
                    Global.Margem.FluxoDeCaixa        = Convert.ToString(DALCadastro.carregaPermissao("CarregaSeis", Convert.ToInt32(id7)));
                    Global.Margem.ContasPagar         = Convert.ToString(DALCadastro.carregaPermissao("CarregaSete", Convert.ToInt32(id7)));
                    Global.Margem.ContasReceber       = Convert.ToString(DALCadastro.carregaPermissao("CarregaOito", Convert.ToInt32(id7)));
                    Global.Margem.ConfiguraçãoSistema = Convert.ToString(DALCadastro.carregaPermissao("CarregaNove", Convert.ToInt32(id7)));
                    MessageBox.Show("Novas permissões já estão em vigor para usuário atual");
                    Global.Margem.intCadUsr = "";
                }

                //código para atualizar permissões
                this.Close();
            }
        }