Exemplo n.º 1
0
        private void btnRemover_Click(object sender, EventArgs e)
        {
            string msg;

            if (lblIdVenda.Text != string.Empty)
            {
                msg = "Confirma Remoção de Venda " + lblIdVenda.Text + "?";
                DialogResult resp;
                resp = MessageBox.Show(msg, "Remoção", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
                if (resp == DialogResult.Yes)
                {
                    int id = Convert.ToInt32(lblIdVenda.Text);
                    Camadas.BLL.Venda   bllVenda = new Camadas.BLL.Venda();
                    Camadas.Model.Venda venda    = new Camadas.Model.Venda();
                    venda.Id = id;
                    bllVenda.Delete(venda);
                    dgvVenda.DataSource = "";
                    dgvVenda.DataSource = bllVenda.Select();
                }
            }
            else
            {
                msg = "Não há Venda para remoção...";
                MessageBox.Show(msg, "Venda", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            LimparControlesVenda();
            HabilitarControlesVenda(false);
        }
Exemplo n.º 2
0
        private void btnGrvar_Click(object sender, EventArgs e)
        {
            Camadas.BLL.Venda   bllVenda = new Camadas.BLL.Venda();
            Camadas.Model.Venda venda    = new Camadas.Model.Venda();
            int id = Convert.ToInt32(lblIdVenda.Text);

            string msg = "";

            if (id == -1)
            {
                msg = "Confirma Inclusão de venda?";
            }
            else
            {
                msg = "Confirma Atualização de Venda?";
            }

            DialogResult resp;

            resp = MessageBox.Show(msg, "Gravar", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            if (resp == DialogResult.Yes)
            {
                venda.Cliente        = Convert.ToInt32(txtIdCliente.Text);
                venda.Funcionario    = Convert.ToInt32(txtIdFuncionario.Text);
                venda.DataVenda      = dtpVenda.Value;
                venda.DataVencimento = dtpVencimento.Value;
                venda.DataPagamento  = dtpPagamento.Value;

                if (id == -1)
                {
                    bllVenda.Insert(venda);
                }
                else
                {
                    venda.Id = id;
                    bllVenda.Update(venda);
                }
            }
            dgvVenda.DataSource = "";
            dgvVenda.DataSource = bllVenda.Select();
            LimparControlesVenda();
            HabilitarControlesVenda(false);
        }