Ejemplo n.º 1
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;

            btnExit.Click += (s, e) => Close();

            Load += (s, e) =>
            {
                LoadStatus();

                var pedido = _modelPedido.FindById(idPedido).FirstOrDefault <Model.Pedido>();
                pedido.Id     = idPedido;
                pedido.status = _controllerTitulo.GetLancados(idPedido) < Validation.Round(_modelPedido.Total) ? 2 : 1;

                if (Home.pedidoPage == "Delivery" || Home.pedidoPage == "Balcao")
                {
                    Status.SelectedValue = pedido.campoa;
                    label19.Text         = GetStatus(pedido.campoa);
                }

                pedido.Save(pedido);
            };

            Activated += (s, e) => { LoadData(); };

            btnPgtosLancado.Click += (s, e) => { OpenPedidoPagamentos(); };

            btnRemove.Click += (s, e) =>
            {
                if (labelCfe.Text != @"N/D" || labelNfe.Text != @"N/D")
                {
                    Alert.Message("Ação não permitida", "Existem documentos fiscais vinculados!",
                                  Alert.AlertType.warning);
                    return;
                }

                var result = AlertOptions.Message("Atenção!", "Deseja realmente apagar?", AlertBig.AlertType.warning,
                                                  AlertBig.AlertBtn.YesNo);
                if (result)
                {
                    var remove = new Controller.Pedido();
                    remove.Remove(idPedido);
                    Close();
                }
            };

            btnImprimir.Click += (s, e) =>
            {
                var    f = new OptionBobinaA4();
                string tipo;
                f.TopMost = true;
                var formResult = f.ShowDialog();

                switch (formResult)
                {
                case DialogResult.OK:
                    tipo = "Folha A4";
                    new Controller.Pedido().Imprimir(idPedido, tipo);
                    break;

                case DialogResult.Cancel:
                    tipo = "Bobina 80mm";
                    new Controller.Pedido().Imprimir(idPedido, tipo);
                    break;
                }
            };

            btnNfe.Click += (s, e) =>
            {
                if (!Support.CheckForInternetConnection())
                {
                    Alert.Message("Opps", "Você está sem conexão com a internet.", Alert.AlertType.warning);
                    return;
                }

                if (UserPermission.SetControlVisual(btnNfe, pictureBox4, "fiscal_emissaonfe"))
                {
                    return;
                }

                Nfe();
            };

            btnCFeSat.Click += (s, e) =>
            {
                if (UserPermission.SetControlVisual(btnCFeSat, pictureBox6, "fiscal_emissaocfe"))
                {
                    return;
                }

                Cfe();
                //Cfe(1);
            };

            btnNfse.Click += (s, e) =>
            {
                if (!Support.CheckForInternetConnection())
                {
                    Alert.Message("Opps", "Você está sem conexão com a internet.", Alert.AlertType.warning);
                    return;
                }

                //if (UserPermission.SetControl(btnNfe, pictureBox4, "fiscal_emissaonfe"))
                //    return;

                Nfse();
            };

            btnHelp.Click += (s, e) => Support.OpenLinkBrowser("http://ajuda.emiplus.com.br/");

            SelecionarCliente.Click += (s, e) =>
            {
                var checkNota = new Nota().FindByIdPedidoUltReg(idPedido, "", "NFe").FirstOrDefault <Nota>();
                if (checkNota != null)
                {
                    if (checkNota.Status == "Autorizada")
                    {
                        Alert.Message("Ação não permitida", "Existem documentos fiscais vinculados!",
                                      Alert.AlertType.warning);
                        return;
                    }
                }

                ModalClientes();
            };

            SelecionarColaborador.Click += (s, e) =>
            {
                var checkNota = new Nota().FindByIdPedidoUltReg(idPedido, "", "NFe").FirstOrDefault <Nota>();
                if (checkNota != null)
                {
                    if (checkNota.Status == "Autorizada")
                    {
                        Alert.Message("Ação não permitida", "Existem documentos fiscais vinculados!",
                                      Alert.AlertType.warning);
                        return;
                    }
                }

                ModalColaborador();
            };

            impostos.CheckStateChanged += (s, e) =>
            {
                PedidoItem.impostos = impostos.Checked;

                _controllerPedidoItem.GetDataTableItens(GridLista, idPedido);
            };

            btnStatus.Click += (s, e) =>
            {
                pictureBox7.Visible  = true;
                visualPanel1.Visible = true;
            };

            btnCancelStatus.Click += (s, e) =>
            {
                pictureBox7.Visible  = false;
                visualPanel1.Visible = false;
            };

            btnSaveStatus.Click += (s, e) =>
            {
                if (Status.SelectedValue.ToString() == "Selecione")
                {
                    Alert.Message("Opss", "Selecione um status.", Alert.AlertType.error);
                    return;
                }

                var pedido = _modelPedido.FindById(idPedido).FirstOrDefault <Model.Pedido>();
                pedido.Id     = idPedido;
                pedido.campoa = Status.SelectedValue.ToString();
                label19.Text  = GetStatus(pedido.campoa);
                if (pedido.Save(pedido))
                {
                    Alert.Message("Pronto", "Status atualizado.", Alert.AlertType.success);
                    pictureBox7.Visible  = false;
                    visualPanel1.Visible = false;
                }
            };
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Adiciona os eventos nos Controls do form.
        /// </summary>
        private void Eventos()
        {
            KeyDown                       += KeyDowns;
            panel1.KeyDown                += KeyDowns;
            imprimir.KeyDown              += KeyDowns;
            btnConcluir.KeyDown           += KeyDowns;
            SelecionarCliente.KeyDown     += KeyDowns;
            SelecionarColaborador.KeyDown += KeyDowns;
            Masks.SetToUpper(this);

            Shown += (s, e) =>
            {
                //aLabel.Visible = !String.IsNullOrEmpty(IniFile.Read("Campo_1_Visible", "OS")) ? Convert.ToBoolean(IniFile.Read("Campo_1_Visible", "OS")) : false;
                //aText.Visible = aLabel.Visible;
                aLabel.Text = !string.IsNullOrEmpty(IniFile.Read("Campo_1_Descr", "OS"))
                    ? IniFile.Read("Campo_1_Descr", "OS")
                    : "";

                //bLabel.Visible = !String.IsNullOrEmpty(IniFile.Read("Campo_2_Visible", "OS")) ? Convert.ToBoolean(IniFile.Read("Campo_2_Visible", "OS")) : false;
                //bText.Visible = bLabel.Visible;
                bLabel.Text = !string.IsNullOrEmpty(IniFile.Read("Campo_2_Descr", "OS"))
                    ? IniFile.Read("Campo_2_Descr", "OS")
                    : "";

                //cLabel.Visible = !String.IsNullOrEmpty(IniFile.Read("Campo_3_Visible", "OS")) ? Convert.ToBoolean(IniFile.Read("Campo_3_Visible", "OS")) : false;
                //cText.Visible = cLabel.Visible;
                cLabel.Text = !string.IsNullOrEmpty(IniFile.Read("Campo_3_Descr", "OS"))
                    ? IniFile.Read("Campo_3_Descr", "OS")
                    : "";

                dLabel.Visible = !string.IsNullOrEmpty(IniFile.Read("Campo_4_Visible", "OS")) && Convert.ToBoolean(IniFile.Read("Campo_4_Visible", "OS"));
                dText.Visible  = dLabel.Visible;
                dLabel.Text    = !string.IsNullOrEmpty(IniFile.Read("Campo_4_Descr", "OS"))
                    ? IniFile.Read("Campo_4_Descr", "OS")
                    : "";

                eLabel.Visible = !string.IsNullOrEmpty(IniFile.Read("Campo_5_Visible", "OS")) && Convert.ToBoolean(IniFile.Read("Campo_5_Visible", "OS"));
                eText.Visible  = eLabel.Visible;
                eLabel.Text    = !string.IsNullOrEmpty(IniFile.Read("Campo_5_Descr", "OS"))
                    ? IniFile.Read("Campo_5_Descr", "OS")
                    : "";

                fLabel.Visible = !string.IsNullOrEmpty(IniFile.Read("Campo_6_Visible", "OS")) && Convert.ToBoolean(IniFile.Read("Campo_6_Visible", "OS"));
                fText.Visible  = fLabel.Visible;
                fLabel.Text    = !string.IsNullOrEmpty(IniFile.Read("Campo_6_Descr", "OS"))
                    ? IniFile.Read("Campo_6_Descr", "OS")
                    : "";

                if (!dLabel.Visible && !eLabel.Visible && !eLabel.Visible)
                {
                    visualSeparator1.Location =
                        new Point(visualSeparator1.Location.X, visualSeparator1.Location.Y - 70);
                    label9.Location       = new Point(label9.Location.X, label9.Location.Y - 70);
                    problemaLen.Location  = new Point(problemaLen.Location.X, problemaLen.Location.Y - 70);
                    problemaText.Location = new Point(problemaText.Location.X, problemaText.Location.Y - 70);

                    label10.Location     = new Point(label10.Location.X, label10.Location.Y - 70);
                    solucaoLen.Location  = new Point(solucaoLen.Location.X, solucaoLen.Location.Y - 70);
                    solucaoText.Location = new Point(solucaoText.Location.X, solucaoText.Location.Y - 70);
                }

                AutoComplete();
            };

            Shown += (s, e) =>
            {
                Refresh();

                Resolution.SetScreenMaximized(this);

                if (Id > 0)
                {
                    LoadData();
                }
                else
                {
                    _mPedido.Id          = 0;
                    _mPedido.Cliente     = 1;
                    _mPedido.Colaborador = Settings.Default.user_id;
                    _mPedido.Tipo        = "Ordens de Servico";
                    if (_mPedido.Save(_mPedido))
                    {
                        Id       = _mPedido.GetLastId();
                        _mPedido = _mPedido.FindById(Id).FirstOrDefault <Model.Pedido>();
                        LoadData();
                    }
                    else
                    {
                        Alert.Message("Opss", "Erro ao criar Pedido.", Alert.AlertType.error);
                        Close();
                    }
                }

                aText.Focus();
            };

            btnConcluir.Click += (s, e) =>
            {
                if (_mPedido == null)
                {
                    Alert.Message("Opps!", "Erro ao finalizar.", Alert.AlertType.error);
                    return;
                }

                _mPedido.status = 1;
                if (_mPedido.Save(_mPedido))
                {
                    Alert.Message("Tudo certo!", "Finalizado com sucesso.", Alert.AlertType.success);
                    Close();
                }
                else
                {
                    Alert.Message("Opps!", "Erro ao finalizar.", Alert.AlertType.error);
                }
            };

            btnGerarVenda.Click += (s, e) =>
            {
                //PedidoPagamentos f = new PedidoPagamentos();
                //f.TopMost = true;

                //_mPedido = _mPedido.FindById(Id).First<Model.Pedido>();
                //_mPedido.Id = Id;
                //_mPedido.Tipo = "Vendas";
                //if (_mPedido.Save(_mPedido))
                //{
                //    Alert.Message("Tudo certo!", "Venda gerada com sucesso.", Alert.AlertType.success);
                //    Home.pedidoPage = "Vendas";
                //    LoadData();
                //    return;
                //}
            };

            SelecionarCliente.Click     += (s, e) => ModalClientes();
            SelecionarColaborador.Click += (s, e) => ModalColaborador();

            imprimir.Click += (s, e) => { new Controller.Pedido().Imprimir(Id, "Ordens de Servico"); };

            btnObs.Click += (s, e) =>
            {
                AddObservacao.idPedido = Id;
                var f = new AddObservacao {
                    TopMost = true
                };
                f.Show();
            };

            FormClosing += (s, e) =>
            {
                //if (!btnFinalizado)
                //{
                //    Home.pedidoPage = CachePage;
                //    var result = AlertOptions.Message("Atenção!", "Você está prestes a excluir!" + Environment.NewLine + "Deseja continuar?", AlertBig.AlertType.warning, AlertBig.AlertBtn.YesNo);
                //    if (result)
                //    {
                //        if (Home.pedidoPage == "Compras" || Home.pedidoPage == "Devoluções")
                //            new Controller.Estoque(Id, Home.pedidoPage, "Fechamento de Tela").Remove().Pedido();
                //        else
                //            new Controller.Estoque(Id, Home.pedidoPage, "Fechamento de Tela").Add().Pedido();

                //        _mPedido.Remove(Id);
                //        return;
                //    }

                //    e.Cancel = true;
                //}
            };

            aText.TextChanged += (s, e) =>
            {
                timer.Stop();
                timer.Start();
            };

            bText.TextChanged += (s, e) =>
            {
                timer.Stop();
                timer.Start();
            };

            cText.TextChanged += (s, e) =>
            {
                timer.Stop();
                timer.Start();
            };

            dText.TextChanged += (s, e) =>
            {
                timer.Stop();
                timer.Start();
            };

            eText.TextChanged += (s, e) =>
            {
                timer.Stop();
                timer.Start();
            };

            fText.TextChanged += (s, e) =>
            {
                timer.Stop();
                timer.Start();
            };

            problemaText.TextChanged += (s, e) =>
            {
                problemaLen.Text    = $@"{problemaText.Text.Length} caracteres";
                problemaLen.Visible = true;
                timer.Stop();
                timer.Start();
            };

            solucaoText.TextChanged += (s, e) =>
            {
                solucaoLen.Text    = $@"{solucaoText.Text.Length} caracteres";
                solucaoLen.Visible = true;
                timer.Stop();
                timer.Start();
            };

            timer.AutoReset = false;
            timer.Elapsed  += (s, e) => { Save(); };

            btnRemover.Click += (s, e) =>
            {
                var result = AlertOptions.Message("Atenção!", "Deseja realmente apagar?", AlertBig.AlertType.warning, AlertBig.AlertBtn.YesNo);
                if (!result)
                {
                    return;
                }

                var remove = new Controller.Pedido();
                remove.Remove(Id);
                Close();
            };

            btnExit.Click += (s, e) => Close();
        }