Example #1
0
        public FrmCadastroLogin(ModelLogin modelLogin)
        {
            InitializeComponent();
            if (controllerTema.CarregarEnderecoImagem() != null)
            {
                pictureBox1.BackgroundImage = Image.FromFile(controllerTema.CarregarEnderecoImagem());
            }
            loginsCadastrados         = controllerLogin.VerificarLoginsCadastrados();
            lblLoginsCadastrados.Text = "Cadastrados: " + loginsCadastrados.ToString();
            loginsContratados         = controllerLogin.VerificarLoginsContratados();
            lblLoginsContratados.Text = "Contratados: " + loginsContratados.ToString();

            if (!string.IsNullOrWhiteSpace(modelLogin.Codigo))
            {
                btnCadastrar.Text = "Editar";
                Text = "Editar Login";
                lblCadastrar.Text = "Editar";
                pnlLogin.Enabled  = false;
                Codigo            = modelLogin.Codigo;
                txtID.Text        = modelLogin.ID;
                txtSenha.Text     = modelLogin.Senha;
                txtID.Enabled     = false;
                if (modelLogin.Nivel == "Administrador")
                {
                    rbAdministrador.Checked = true;
                }
                if (modelLogin.Nivel == "Vendedor")
                {
                    rbVendedor.Checked = true;
                }
                if (modelLogin.Nivel == "Estoquista")
                {
                    rbEstoquista.Checked = true;
                }
                if (modelLogin.Nivel == "Supervisor")
                {
                    rbSupervisor.Checked = true;
                }
            }
            if (modelLogin.Consultar == true)
            {
                Text = "Consultar Login";
                lblCadastrar.Text         = "Consultar";
                btnCadastrar.Visible      = false;
                btnCancelar.Text          = "Fechar";
                txtConfirmarSenha.Visible = false;
                lblConfirmarSenha.Visible = false;
                pnlLogin.Enabled          = false;
                txtID.Text    = modelLogin.ID;
                txtSenha.Text = modelLogin.Senha;
                if (modelLogin.Nivel == "Administrador")
                {
                    rbAdministrador.Checked = true;
                }
                if (modelLogin.Nivel == "Vendedor")
                {
                    rbVendedor.Checked = true;
                }
                if (modelLogin.Nivel == "Estoquista")
                {
                    rbEstoquista.Checked = true;
                }
                if (modelLogin.Nivel == "Supervisor")
                {
                    rbSupervisor.Checked = true;
                }
            }
        }