Exemplo n.º 1
0
        //Acao disparada pelo botao de login
        //Sequencialmente
        private Usuario doWork(string logon, string senha)
        {
            //aqui eu ja tenho contexto iniciado

            //traz um usuario indexado do banco
            Usuario user = new UsuarioDaoManager().IsLogin(logon, senha);

            //seta o usuario
            UnitWork.Usuario = user;

            if (user == null)
            {
                MessageBoxBlack.Show("Usuário ou senha inválidos.", "Atenção");

                this._xFrmLogin.BringToFront();
            }
            else
            {
                //login no servidor
                //_application.ITSTools.Login(logon, senha);

                //use o tema do user
                DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = user.Skin;

                //agora sim feche essa janela
                this._xFrmLogin.DisposeOnLogin = true;

                this._xFrmLogin.Dispose();

                //seta a matriz e filial
                this.setMatrizFilial(_ctx);
            }

            return(user);
        }
Exemplo n.º 2
0
        private void wizardPage1_PageValidating(object sender, DevExpress.XtraWizard.WizardPageValidatingEventArgs e)
        {
            if (e.Direction == DevExpress.XtraWizard.Direction.Forward)
            {
                if (lblMsg.Visible)
                {
                    MessageBoxBlack.Show("Para continuar o processo desmarque a opção estorno.",
                                         "Atenção");
                    e.Valid = true;
                }
                else
                {
                    var motivo = txtMotivoCancelamento.Text;
                    var msgs   = "";
                    if (dtEditDataCancelamento.DateTime.ValidateDate() == null)
                    {
                        msgs    = "Informe a data do cancelamento\n\n";
                        e.Valid = false;
                    }

                    if (string.IsNullOrEmpty(motivo))
                    {
                        msgs    = "Informe o motivo do cancelamento";
                        e.Valid = false;
                    }

                    if (!string.IsNullOrEmpty(msgs))
                    {
                        XMessageIts.Mensagem(msgs);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void btnCopyData_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var matriz = lkpMatriz.GetSelectedDataRow() as EmpresaMatriz;

            if (matriz != null)
            {
                txtRazSocial.Text    = matriz.RazaoSocial;
                txtNomeFantasia.Text = matriz.NomeFantasia;
                txtCnpj.Text         = matriz.Cnpj;
                if (matriz.DtRegtroJuntaCom.HasValue)
                {
                    dtRegistroJunta.DateTime = matriz.DtRegtroJuntaCom.Value.Date;
                }

                lookUpMunicipio1.SetMunicipioUF(matriz.Cidade, matriz.Uf);
                cepControl1.TextCep.Text = matriz.Cep;

                txtEndereco.Text         = matriz.NomeEndereco;
                txtNumEndereco.Text      = matriz.NumeroEndereco;
                txtComplemento.Text      = matriz.Complemento;
                txtBairro.Text           = matriz.Bairro;
                cepControl1.TextCep.Text = matriz.Cep;
            }
            else
            {
                MessageBoxBlack.Show("Selecione a matriz a ser copiada");
            }
        }
Exemplo n.º 4
0
        public static void ReadyOnly(bool action, params Component[] componentes)
        {
            foreach (var comp in componentes)
            {
                if (comp != null)
                {
                    if (comp.GetType() == typeof(TextEdit))
                    {
                        TextEdit c = comp as TextEdit;
                        c.ReadOnly = action;
                    }

                    else if (comp.GetType() == typeof(RadioGroup))
                    {
                        RadioGroup c = comp as RadioGroup;
                        c.ReadOnly = action;
                    }

                    else if (comp.GetType() == typeof(DateEdit))
                    {
                        DateEdit c = comp as DateEdit;
                        c.ReadOnly = action;
                    }

                    else if (comp.GetType() == typeof(ComboBoxEdit))
                    {
                        ComboBoxEdit c = comp as ComboBoxEdit;
                        c.ReadOnly = action;
                    }
                    else if (comp.GetType() == typeof(MemoEdit))
                    {
                        var c = comp as MemoEdit;
                        c.ReadOnly = action;
                    }
                    else if (comp.GetType() == typeof(TimeEdit))
                    {
                        var c = comp as TimeEdit;
                        c.ReadOnly = action;
                    }
                    else if (comp.GetType() == typeof(RichTextBox))
                    {
                        var c = comp as RichTextBox;
                        c.ReadOnly = action;
                    }
                    else
                    {
                        MessageBoxBlack.Show("Ready only for " + comp.GetType() + " not implemented or not supported.");
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void setCurrentUser(Usuario user)
        {
            this._currentUser = user;

            if (user == null)
            {
                MessageBoxBlack.Advertencia("Usuário operador não informado ao menu prinicpal", "Atenção");

                LoggerUtilIts.GenerateLogs(new Exception("User not found for XFrmMenu"));

                Application.Exit();
            }
            if (UnitWork.Filial == null)
            {
                navBarUnitWork_LinkClicked(null, null);
            }

            UnitWork.Usuario = user;

            //Define o skin do menu utilizado pelo usuário
            string skin = user.Skin;

            //se existe um
            if (!string.IsNullOrEmpty(skin))
            {
                SkinHelper.InitSkinGallery(skinRibbonGalleryBarItem1);
                defaultLookAndFeel1.LookAndFeel.SkinName = skin;
            }

            //DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = skin;

            //DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = "Visual Studio 2013 Blue";
            //DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = "Office 2013 Light Gray";

            //Eh mais elegante e legivel o nome da pessoa do que o nickname
            this.lbUserLogado.Caption = user.NomeUsuario;
            this.dtAtual.Caption      = DateTime.Now.Date.ToShortDateString();


            //somente eu poss usar essa funcionalidade
            if (user.NomeUtilizador == "filipe" /*
                                                || user.NomeUtilizador == "admin"
                                                || user.NomeUtilizador == "gercy" && user.IsAdmin*/)
            {
                this.ribbonPageGroupInformatica.Visible = true;

                this.ribbonPageGroupSystem.Visible = true;
                this.ribbonPageGroupUtil.Visible   = true;
                this.barBtnRestauracao.Visibility  = BarItemVisibility.Always;
            }
        }
Exemplo n.º 6
0
        public bool AddItem(Produto p)
        {
            var o = GetItensProposta().Find(i => i.Produto.DescricaoProduto.Equals(p.DescricaoProduto));

            if (o != null)
            {
                MessageBoxBlack.Advertencia("Produto \"" + p.DescricaoProduto
                                            + "\" já incluso !");
                return(false);
            }
            //insere no topo da pilha
            this._itensVenda.Add(new ItemVenda(p));
            this.gridControlItensVenda.DataSource = _itensVenda;
            return(true);
        }
Exemplo n.º 7
0
        public ItemOrdemCarga AddItem(MaterialSerra mat, int qtde)
        {
            var o = this._itensVenda.Find(i => i.Material.NomeMaterial.Equals(mat.NomeMaterial));

            if (o != null)
            {
                MessageBoxBlack.Advertencia("Material \"" + mat.NomeMaterial
                                            + "\" já incluso !");
                return(null);
            }

            var item = new ItemOrdemCarga(mat, qtde);

            //garante a consistencia em caso de lajinha
            item.Update(item);
            this._itensVenda.Add(item);
            this.gridControlItensVenda.DataSource = _itensVenda;
            return(item);
        }
Exemplo n.º 8
0
        //Acao disparada pelo botao de login
        //Totalmente assicrono
        private async Task <AdminDTO> doWorkAsync(string logon, string senha)
        {
            AdminDTO admin  = new AdminDTO(logon, senha);
            bool     result = await WaitEntityFramework.StartTask <Package>(TaskEF());

            //aqui tenho um contexto rodando assincrono
            if (result)
            {
                //ja iniciou nao precisa roda a barra denovo
                //isso impede que outro contexto seja iniciado
                this._isInit = true;

                if (admin.IsAdmin == false)
                {
                    //recria
                    this._xFrmLogin = new XFrmLogin(this);
                    //nao feche essa janela ate logar corretamente
                    this._xFrmLogin.DisposeOnLogin = false;

                    //marque false
                    //mesmo que o form marque true
                    //no banco de dados foi negado o acesso
                    this._xFrmLogin.IsLogin = false;

                    //agora nem esconde esse form mais
                    //fica amarrado ate logar corretamente
                    this._xFrmLogin.IsHideOnLogin = false;

                    MessageBoxBlack.Show("Usuário \"" + logon + "\" ou senha inválido(s).", "Atenção");
                }
                else
                {
                    this._xFrmLogin.IsLogin = true;
                    //agora sim feche essa janela
                    this._xFrmLogin.DisposeOnLogin = true;
                }
            }


            return(admin);
        }
Exemplo n.º 9
0
        //Acao disparada pelo botao de login
        //Sequencialmente
        private AdminDTO doWork(string logon, string senha)
        {
            Console.WriteLine("Wait Entityframework initializate ...");

            //aqui eu ja tenho contexto iniciado

            //traz um usuario indexado do banco + login no servidor
            AdminDTO admin = new AdminDTO(logon, senha, _application.ITSTools.Login(logon, senha));



            if (admin.IsAdmin == false)
            {
                MessageBoxBlack.Show("Usuário \"" + logon + "\" não encontrado.", "Atenção");
                this._xFrmLogin.BringToFront();
            }
            else
            {
                //agora sim feche essa janela
                this._xFrmLogin.DisposeOnLogin = true;
                this._xFrmLogin.Dispose();
            }
            return(admin);
        }
Exemplo n.º 10
0
        private void barBtnSerialiar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            object o    = barEd.EditValue;
            string cnpj = o != null?o.ToString() : "";

            if (!string.IsNullOrWhiteSpace(cnpj))
            {
                cnpj = StringUtilIts.FixString(cnpj);
                String json = JSONHelper.GetJSONString(receitaWsUrl + cnpj);
                //var r = JSONHelper.GetObjectFromJSONString<LayoutReceitaWS>(json);
                //JsonConvert.DeserializeObject<LayoutReceitaWS>(json);
                this.ResultValidation = LayoutReceitaWS.GetDataFromCNPJ(cnpj);//

                this.lista.Clear();
                this.lista.Add(ResultValidation);
                this.mEditJSON.Text          = json;
                this.gridControl1.DataSource = lista;
                this.gridViewSerializable.RefreshData();
            }
            else
            {
                MessageBoxBlack.Show("CNPJ " + cnpj + " inválido !");
            }
        }
Exemplo n.º 11
0
        //Acao disparada pelo botao de login
        //Totalmente assicrono
        private async Task <Usuario> doWorkAsync(string logon, string senha)
        {
            Usuario user = new Usuario();

            bool result = await WaitEntityFramework.StartTask <Usuario>(taskInitEF());

            //aqui tenho um contexto rodando assincrono
            if (result)
            {
                //ja iniciou nao precisa roda a barra denovo
                //isso impede que outro contexto seja iniciado
                this._isInit = true;

                //traz um usuario indexado do banco
                if (senha == null)
                {
                    //a senha nunca chega nula a nao ser q eu aponte intencionalmente
                    user = new UsuarioDaoManager().FindUserByNameOrId(logon);
                }
                else
                {
                    user = new UsuarioDaoManager().IsLogin(logon, senha);
                }

                //seta o usuario
                UnitWork.Usuario = user;

                if (user == null)
                {
                    //recria
                    this._xFrmLogin = new ITSolution.Framework.Forms.XFrmLogin(this);

                    //nao feche essa janela ate logar corretamente
                    this._xFrmLogin.DisposeOnLogin = false;

                    //marque false
                    //mesmo que o form marque true
                    //no banco de dados foi negado o acesso
                    this._xFrmLogin.IsLogin = false;

                    //agora nem esconde esse form mais
                    //fica amarrado ate logar corretamente
                    this._xFrmLogin.IsHideOnLogin = false;

                    //mostre o botao de cadastro na tela
                    //so deixe cadastrar no inicio se nao tiver usuarios
                    if (_ctx.UsuarioDao.FindAll().Count == 0)
                    {
                        //se nao coloquei o botao na tela
                        if (this._xFrmLogin.ActionBtn == null)
                        {
                            this._xFrmLogin.ActionBtn         = addUsuario();
                            this._xFrmLogin.BtnAction.Visible = true;
                        }
                    }

                    //se o login automatico falhou
                    if (this._isLoginAutoFailed)
                    {
                        //apaguei as preferencias
                        //implica e fazer todo o processo novamente
                        File.Delete(UnitWork.PREFERENCIAS);
                    }

                    MessageBoxBlack.Show("Usuário \"" + logon + "\" ou senha inválido(s).", "Atenção");
                }
                else
                {
                    //use o tema do user
                    DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = user.Skin;
                    this._xFrmLogin.IsLogin = true;
                    //login no servidor
                    //_application.ITSTools.Login(logon, senha);
                    //agora sim feche essa janela
                    this._xFrmLogin.DisposeOnLogin = true;

                    //seta a matriz e filial
                    setMatrizFilial(_ctx);
                }
            }


            return(user);
        }