예제 #1
0
        private void FormProdutos_Load(object sender, EventArgs e)
        {
            //ao receber o foco
            this.textBoxCompra.GotFocus  += new System.EventHandler(this.textBoxValor_GotFocus);
            this.textBoxVarejo.GotFocus  += new System.EventHandler(this.textBoxValor_GotFocus);
            this.textBoxAtacado.GotFocus += new System.EventHandler(this.textBoxValor_GotFocus);

            //ao perder o foco
            this.textBoxCompra.LostFocus        += new System.EventHandler(this.textBoxCompra_LostFocus);
            this.textBoxCompra.LostFocus        += new System.EventHandler(this.textBoxValor_LostFocus);
            this.textBoxVarejo.LostFocus        += new System.EventHandler(this.textBoxValor_LostFocus);
            this.textBoxAtacado.LostFocus       += new System.EventHandler(this.textBoxValor_LostFocus);
            this.textBoxMarca.LostFocus         += new System.EventHandler(this.textBoxMarca_LostFocus);
            this.textBoxCodFornecedor.LostFocus += new System.EventHandler(this.textBoxCodFornecedor_LostFocus);

            //ao ser alterado
            this.textBoxSub.TextChanged           += new System.EventHandler(this.LimparTextBoxAoAlterar);
            this.textBoxCategoria.TextChanged     += new System.EventHandler(this.LimparTextBoxAoAlterar);
            this.textBoxMarca.TextChanged         += new System.EventHandler(this.LimparTextBoxAoAlterar);
            this.textBoxCodFornecedor.TextChanged += new System.EventHandler(this.LimparTextBoxAoAlterar);
            this.textBoxStatus.TextChanged        += new System.EventHandler(this.LimparTextBoxAoAlterar);

            textBoxDescricao.Select();

            if (infoProd == null)
            {
                negocioPessoa = new PessoaNegocio(Form1.Empresa.empconexao, Form1.Unidade.uniassistencia);
                PessoaInfo forn = negocioPessoa.ConsultarPessoaPadrao(EnumPessoaTipo.Fornecedor);
                textBoxCodFornecedor.Text = string.Format("{0:000}", forn.pssid);
                labelValorFornecedor.Text = forn.pssnome;
            }
        }
예제 #2
0
        private int InserirVenda()
        {
            vendaInfo.venidstatus = 2;
            vendaInfo.venid       = vendaNegocios.InsertVenda(vendaInfo);

            if (vendaInfo.venid > 0)
            {
                if (colecaoItem != null)
                {
                    ProdutoNegocios produtoNegocios = new ProdutoNegocios(Form1.Empresa.empconexao, EnumAssistencia.Loja);
                    PessoaNegocio   negocioPessoa   = new PessoaNegocio(Form1.Empresa.empconexao, EnumAssistencia.Loja);
                    foreach (var item in colecaoItem)
                    {
                        if (item.Id == 0)
                        {
                            ProdutoInfo infoProd = new ProdutoInfo
                            {
                                proId              = 0,
                                proCodBarras       = item.Barras,
                                proControleEstoque = false,
                                proDescricao       = item.Descricao,
                                proQuantMinima     = 1,
                                proValorAtacado    = item.ValorDesc,
                                proValorCompra     = item.ValorUnit,
                                proValorVarejo     = item.ValorDesc,
                                proidfornecedor    = negocioPessoa.ConsultarPessoaPadrao(EnumPessoaTipo.Fornecedor).Id,
                                proidmarca         = 1,
                                proidstatus        = 1,
                                proidsubcategoria  = 1,
                                proidUser          = Form1.User.useidfuncionario,
                                propadrao          = true
                            };

                            int id = produtoNegocios.InsertProduto(infoProd);

                            if (id > 0)
                            {
                                VendaDetalhesInfo vendaDetalhesInfo = new VendaDetalhesInfo
                                {
                                    vendetalhesidprod    = id,
                                    vendetalhesidfunc    = item.funid,
                                    vendetalhesquant     = 1,
                                    vendetalhesvalordesc = item.ValorDesc,
                                    vendetalhesvalorunit = item.ValorUnit
                                };

                                vendacolecao.Add(vendaDetalhesInfo);
                            }
                        }
                    }
                }

                foreach (VendaDetalhesInfo vendaDetalhesInfo in vendacolecao)
                {
                    if (vendaDetalhesInfo.vendetalhesidprod > 0)
                    {
                        vendaDetalhesInfo.vendetalhesidvenda = vendaInfo.venid;

                        if (vendaNegocios.InsertVendaDetalhes(vendaDetalhesInfo) == 0)
                        {
                            FormMessage.ShowMessegeWarning("Falha ao salvar os itens!");
                            return(0);
                        }
                    }
                }

                VendaConcluida = vendaInfo;
                return(vendaInfo.venid);
            }
            else
            {
                return(0);
            }
        }