예제 #1
0
        public override void Gravar()
        {
            try
            {
                Validar();

                int MesaInicio = teInicial.Text.Trim().ToInt32() ?? 0;
                int MesaFinal  = teFinal.Text.Trim().ToInt32() ?? 0;

                for (int i = MesaInicio; i <= MesaFinal; i++)
                {
                    Mesa = new TB_GOU_MESA();
                    if (Modo == UTILS.Modo.Alterar)
                    {
                        Mesa.ID_MESA = teIdentificador.Text.Trim().ToInt32() ?? 0;
                    }

                    Mesa.ID_AMBIENTE = beAmbiente.Text.ToInt32().Padrao();
                    Mesa.ST_ATIVO    = ceAtivo.Checked;
                    Mesa.ID_MESA     = i;
                    var posicaoTransacao = 0;
                    new QMesa().Gravar(Mesa, ref posicaoTransacao);
                }



                base.Gravar();
            }
            catch (Exception excessao)
            {
                excessao.Validar();
            }
        }
예제 #2
0
        private void afterGravar(List <MPedidoItem> vItens)
        {
            var vpedido = new MPedido();

            var transferencia = new List <MPedidoItem>();

            for (int i = 0; i < vItens.Count; i++)
            {
                transferencia.Add(new MPedidoItem
                {
                    ID_ITEM   = vItens[i].ID_ITEM,
                    ID_PEDIDO = vItens[i].ID_PEDIDO
                });
            }

            var lresult = VerificaPedido(teMesa.Text.Trim(), teCartao.Text.Trim());

            var existeMesa = new TB_GOU_MESA();//VERIFICA NO CADASTRO DE MESAS SE EXISTE

            if (teMesa.Text.Trim().Length > 0)
            {
                existeMesa = ExisteMesa(teMesa.Text.Trim());
            }

            if (existeMesa == null)
            {
                throw new Exception("Mesa destino informada não esta cadastrada!");
            }

            vpedido.ID_EMPRESA   = 1;
            vpedido.ID_CLIFOR    = 1;
            vpedido.ID_MESA      = lresult.Count > 0 ? lresult[0].ID_MESA : (teMesa.Text.Trim() == "" ? "0" : teMesa.Text.Trim());
            vpedido.ID_CARTAO    = lresult.Count > 0 ? lresult[0].ID_CARTAO : (teCartao.Text.Trim() == "" ? "0" : teCartao.Text.Trim());
            vpedido.ST_ATIVO     = vItens.Count > 0;
            vpedido.ST_PEDIDO    = "O";
            vpedido.TP_MOVIMENTO = "S";

            if (lresult.Count > 0)
            {
                vpedido.ID_PEDIDO = lresult[0].ID_PEDIDO;
            }



            for (int i = 0; i < vItens.Count; i++)
            {
                (vItens[i] as MPedidoItem).ID_PEDIDO = 0;
                vpedido.Itens.Add(vItens[i] as MPedidoItem);
            }

            int posiscao_transacao = 0;

            new QPedido().Gravar(vpedido, ref posiscao_transacao, transferencia);

            new QPedido().VerificaMesaSemItem();

            this.Close();
        }
예제 #3
0
        public void Deletar(TB_GOU_MESA mesa, ref int posicaoTransacao)
        {
            try
            {
                Conexao.Iniciar(ref posicaoTransacao);

                var existente = Conexao.BancoDados.TB_GOU_MESAs.FirstOrDefault(a => a.ID_MESA == mesa.ID_MESA);

                Conexao.BancoDados.TB_GOU_MESAs.DeleteOnSubmit(mesa);
                Conexao.Enviar();

                Conexao.Finalizar(ref posicaoTransacao);
            }
            catch (Exception excessao)
            {
                Conexao.Voltar(ref posicaoTransacao);
                throw excessao;
            }
        }
예제 #4
0
        public void Gravar(TB_GOU_MESA mesa, ref int posicaoTransacao)
        {
            try
            {
                Conexao.Iniciar(ref posicaoTransacao);

                var existente = Conexao.BancoDados.TB_GOU_MESAs.FirstOrDefault(a => a.ID_MESA == mesa.ID_MESA);

                #region Inserção
                if (existente == null)
                {
                    Conexao.BancoDados.TB_GOU_MESAs.InsertOnSubmit(mesa);
                }
                #endregion

                #region Atualização
                else
                {
                    existente.ID_MESA     = mesa.ID_MESA;
                    existente.NM          = mesa.NM;
                    existente.ST_ATIVO    = mesa.ST_ATIVO;
                    existente.ID_AMBIENTE = mesa.ID_AMBIENTE;
                    Conexao.Enviar();
                }

                #endregion

                Conexao.Enviar();

                Conexao.Finalizar(ref posicaoTransacao);
            }
            catch (Exception excessao)
            {
                Conexao.Voltar(ref posicaoTransacao);
                throw excessao;
            }
        }
예제 #5
0
        public FMesa_Cadastro()
        {
            InitializeComponent();

            this.Shown += delegate
            {
                try
                {
                    beAmbiente.ButtonClick += (s, e) =>
                    {
                        if (e.Button.Tag.ToString() == "adicionar")
                        {
                            try
                            {
                                using (var filtro = new SYS.FORMS.FFiltro()
                                {
                                    Consulta = Ambientes(false),
                                    Colunas = new List <SYS.FORMS.Coluna>()
                                    {
                                        new SYS.FORMS.Coluna {
                                            Nome = "ID", Descricao = "Identificador do ambiente", Tamanho = 100
                                        },
                                        new SYS.FORMS.Coluna {
                                            Nome = "NM", Descricao = "Nome do ambiente", Tamanho = 350
                                        }
                                    }
                                })
                                {
                                    if (filtro.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                    {
                                        beAmbiente.Text   = (filtro.Selecionados.FirstOrDefault().ID as int?).Padrao().ToString();
                                        teNMambiente.Text = (filtro.Selecionados.FirstOrDefault().NM as string).Validar();
                                    }
                                }
                            }
                            catch (Exception excessao)
                            {
                                excessao.Validar();
                            }
                        }
                    };

                    Action AmbienteLeave = delegate
                    {
                        try
                        {
                            var complemento = Ambientes(true).FirstOrDefaultDynamic();

                            beAmbiente.Text   = complemento != null ? (complemento.ID as int?).Padrao().ToString() : "";
                            teNMambiente.Text = complemento != null ? (complemento.NM as string).Validar() : "";
                        }
                        catch (Exception excessao)
                        {
                            excessao.Validar();
                        }
                    };

                    beAmbiente.Leave += delegate { AmbienteLeave(); };

                    if (Modo == Modo.Cadastrar)
                    {
                        Mesa = new TB_GOU_MESA();
                    }
                    else if (Modo == Modo.Alterar)
                    {
                        if (Mesa == null)
                        {
                            Excessoes.Alterar();
                        }

                        teInicial.ReadOnly = true;
                        teFinal.ReadOnly   = true;

                        teIdentificador.Text = Mesa.ID_MESA.ToString();
                        beAmbiente.Text      = Mesa.ID_AMBIENTE.ToString();
                        AmbienteLeave();
                        ceAtivo.Checked = Mesa.ST_ATIVO ?? false;
                    }
                }
                catch (Exception excessao)
                {
                    excessao.Validar();
                }
            };
        }