예제 #1
0
        private void CarregaGridItens()
        {
            CompraTempTableAdapter taCompraTemp = new CompraTempTableAdapter();

            dgvProdutos.DataSource = taCompraTemp.GetData();


            dgvProdutos.Columns[0].Visible    = false;
            dgvProdutos.Columns[1].HeaderText = "Cod.";
            dgvProdutos.Columns[1].Width      = 70;
            dgvProdutos.Columns[2].HeaderText = "Produto";
            dgvProdutos.Columns[2].Width      = 318;
            dgvProdutos.Columns[3].HeaderText = "Quant.";
            dgvProdutos.Columns[3].Width      = 70;
            dgvProdutos.Columns[4].HeaderText = "Valor";
            dgvProdutos.Columns[4].Width      = 110;
            dgvProdutos.Columns[4].DefaultCellStyle.Format = "C2";
        }
예제 #2
0
        private void btnRemovProd_Click(object sender, EventArgs e)
        {
            if (dgvProdutos.Rows.Count > 0)
            {
                CompraTempTableAdapter taCompraTemp = new CompraTempTableAdapter();
                int vCodProd = (int)dgvProdutos.CurrentRow.Cells["ID_Prod"].Value;
                vValorProd = (decimal)dgvProdutos.CurrentRow.Cells["PrecoTotal_Prod"].Value;
                string vProd      = dgvProdutos.CurrentRow.Cells["Nome_Prod"].Value.ToString();
                int    vQuantProd = (int)dgvProdutos.CurrentRow.Cells["Quant_ItensCompra"].Value;

                taCompraTemp.Delete(vID_VendaAtual, vCodProd, vProd, vQuantProd, vValorProd);
                Limpa_Campos_Item();
                CarregaGridItens();
                vValorTotal   = vValorTotal - vValorProd;
                lblPreco.Text = (vValorTotal).ToString("R$ ###,##0.00");
                lblInfo.Text  = "Produto removido!";
                LigaInfo();
            }
        }
예제 #3
0
        private void btnAddProd_Click(object sender, EventArgs e)
        {
            if (txtnomeProd.Text == "")
            {
                lblInfo.Text = "Escolha um produto para adicionar!";
                LigaInfo();
                return;
            }

            //Grava item na tabela temporária
            vValorProd = decimal.Parse(txtPreco.Text) * Convert.ToInt32(spnQuant.Value);
            bool vAchouIgual = false;
            CompraTempTableAdapter taCompraTemp = new CompraTempTableAdapter();

            for (int i = 0; i <= dgvProdutos.RowCount - 1; i++)
            {
                if (Convert.ToInt32(dgvProdutos.Rows[i].Cells["ID_Prod"].Value) == Convert.ToInt32(txtidProd.Text))
                {
                    vAchouIgual = true;
                    taCompraTemp.SomarQuantidade(Convert.ToInt32(spnQuant.Value), vValorProd, Convert.ToInt32(dgvProdutos.Rows[i].Cells["ID_Prod"].Value));
                }
            }

            if (vAchouIgual == false)
            {
                taCompraTemp.Insert(vID_VendaAtual, int.Parse(txtidProd.Text), txtnomeProd.Text, Convert.ToInt32(spnQuant.Value), vValorProd);
            }

            Limpa_Campos_Item();
            CarregaGridItens();

            vValorTotal   = vValorTotal + vValorProd;
            lblPreco.Text = (vValorTotal).ToString("R$ ###,##0.00");

            lblInfo.Text = "Produto adicionado!";
            LigaInfo();
            txtBarra.Select();
        }
예제 #4
0
        private void ApagarTabela()
        {
            CompraTempTableAdapter taCompraTemp = new CompraTempTableAdapter();

            taCompraTemp.ApagarTabela();
        }