private void btExcluir_Click(object sender, EventArgs e)
        {
            if (dgwPrincipal.SelectedRows.Count == 0)
            {
                MessageBox.Show("Nenhum agendamento selecionado", "Excluir diz:");
                return;
            }

            DialogResult dialogResult = MessageBox.Show("Tem certeza?", "Excluir diz:", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.No)
            {
                return;
            }

            int Codigo = Convert.ToInt32(dgwPrincipal.CurrentRow.Cells[0].Value);
            AgendaNegocio agendaNegocio = new AgendaNegocio();
            string retorno = agendaNegocio.ExcluirAgendamento(Codigo);

            try
            {
                int IdAgendamento = Convert.ToInt32(retorno);
                MessageBox.Show("Agendamento excluido", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                PesquisarAgenda();
            }
            catch
            {
                MessageBox.Show("Não foi possivel excluir. Detalhes: " + retorno, "Erro ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
        public FrmCaixa(int IdCliente)
        {
            InitializeComponent();
            dgwPrincipal.AutoGenerateColumns = false;

            dgwPrincipal.Rows.Clear();
            AgendaNegocio agendaNegocio = new AgendaNegocio();
            AgendaColecao agendaColecao = new AgendaColecao();

            agendaColecao = agendaNegocio.ConsultarPorCodigo(IdCliente);
            foreach (Agenda item in agendaColecao)
            {
                dgwPrincipal.Rows.Add();
                dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["IdCliente"].Value = item.IdCliente.IdCliente;
                dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Nome"].Value      = item.IdCliente.Nome;
                dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Descricao"].Value = item.agendaServicos.IdServico.Descricao;
                dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Valor"].Value     = item.agendaServicos.IdServico.Valor;
            }

            int valor = 0;

            foreach (DataGridViewRow row in dgwPrincipal.Rows)
            {
                valor += Convert.ToInt32(row.Cells["Valor"].Value);
            }
            txtValorTotal.Text       = valor.ToString("###,###,##0.00");
            txtMostraValorFinal.Text = valor.ToString("###,###,##0.00");
        }
Ejemplo n.º 3
0
        private void btAgendar_Click(object sender, EventArgs e)
        {
            AgendaNegocio agendaNegocio = new AgendaNegocio();
            Agenda        agenda        = new Agenda();
            int           Codigo        = Convert.ToInt32(dgwCliente.CurrentRow.Cells[0].Value);

            agenda.IdCliente           = new Cliente();
            agenda.IdCliente.IdCliente = Codigo;
            agenda.Data                     = dtpData.Value;
            agenda.agendaServicos           = new AgendaServicos();
            agenda.agendaServicos.IdServico = new Servicos();
            if (cbServicos.Text == "Cabelo")
            {
                agenda.agendaServicos.IdServico.IdServico = 1;
            }
            else if (cbServicos.Text == "Barba")
            {
                agenda.agendaServicos.IdServico.IdServico = 2;
            }
            string IdAgendamento = agendaNegocio.ServicoAgendar(agenda);

            try
            {
                int Id = Convert.ToInt32(IdAgendamento);
                MessageBox.Show("Agendamento Realizado. Id do agendamento: " + Id, "Agendamento", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.DialogResult = DialogResult.Yes;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ao agendar. Detalhes: " + IdAgendamento, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.DialogResult = DialogResult.No;
            }
        }
 private void PesquisarAgenda()
 {
     try
     {
         dgwPrincipal.Rows.Clear();
         int Codigo = Convert.ToInt32(txtPesquisar.Text);
         AgendaNegocio agendaNegocio = new AgendaNegocio();
         AgendaColecao agendaColecao = new AgendaColecao();
         agendaColecao = agendaNegocio.ConsultarPorCodigo(Codigo);
         foreach (Agenda item in agendaColecao)
         {
             dgwPrincipal.Rows.Add();
             dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Data"].Value = item.Data;
             dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["IdAgendamento"].Value = item.IdAgendamento;
             dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["IdCliente"].Value = item.IdCliente.IdCliente;
             dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Nome"].Value = item.IdCliente.Nome;
             dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Descricao"].Value = item.agendaServicos.IdServico.Descricao;
             dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Valor"].Value = item.agendaServicos.IdServico.Valor;
             dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["AgendadoEm"].Value = item.AgendadoEm;
             dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Atendido"].Value = item.Atendido;
             dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Pago"].Value = item.Caixa.Pago;
         }
     }
     catch
     {
         dgwPrincipal.Rows.Clear();
         AgendaNegocio agendaNegocio = new AgendaNegocio();
         AgendaColecao agendaColecao = new AgendaColecao();
         agendaColecao = agendaNegocio.ConsultarPorNome(txtPesquisar.Text);
         foreach (Agenda item in agendaColecao)
         {
             dgwPrincipal.Rows.Add();
             dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Data"].Value = item.Data;
             dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["IdAgendamento"].Value = item.IdAgendamento;
             dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["IdCliente"].Value = item.IdCliente.IdCliente;
             dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Nome"].Value = item.IdCliente.Nome;
             dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Descricao"].Value = item.agendaServicos.IdServico.Descricao;
             dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Valor"].Value = item.agendaServicos.IdServico.Valor;
             dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["AgendadoEm"].Value = item.AgendadoEm;
             dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Atendido"].Value = item.Atendido;
             dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Pago"].Value = item.Caixa.Pago;
         }
     }
 }
 private void btBuscarData_Click(object sender, EventArgs e)
 {
     dgwPrincipal.Rows.Clear();
     AgendaNegocio agendaNegocio = new AgendaNegocio();
     AgendaColecao agendaColecao = new AgendaColecao();
     agendaColecao = agendaNegocio.ConsultarPorData(dtpData.Value);
     foreach (Agenda item in agendaColecao)
     {
         dgwPrincipal.Rows.Add();
         dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Data"].Value = item.Data;
         dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["IdAgendamento"].Value = item.IdAgendamento;
         dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["IdCliente"].Value = item.IdCliente.IdCliente;
         dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Nome"].Value = item.IdCliente.Nome;
         dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Descricao"].Value = item.agendaServicos.IdServico.Descricao;
         dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Valor"].Value = item.agendaServicos.IdServico.Valor;
         dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["AgendadoEm"].Value = item.AgendadoEm;
         dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Atendido"].Value = item.Atendido;
         dgwPrincipal.Rows[dgwPrincipal.Rows.Count - 1].Cells["Pago"].Value = item.Caixa.Pago;
     }
 }
        private void btSalvar_Click(object sender, EventArgs e)
        {
            Agenda        agendaAlterar = new Agenda();
            AgendaNegocio agendaNegocio = new AgendaNegocio();

            agendaAlterar.IdAgendamento = Convert.ToInt32(lbIdAgenda.Text);
            string Atendido = cbAtendido.Text;

            if (Atendido == "Não")
            {
                agendaAlterar.Atendido = false;
            }
            else if (Atendido == "Sim")
            {
                agendaAlterar.Atendido = true;
            }
            agendaAlterar.Data                     = dtpData.Value;
            agendaAlterar.agendaServicos           = new AgendaServicos();
            agendaAlterar.agendaServicos.IdServico = new Servicos();
            if (cbServico.Text == "Cabelo")
            {
                agendaAlterar.agendaServicos.IdServico.IdServico = 1;
            }
            else if (cbServico.Text == "Barba")
            {
                agendaAlterar.agendaServicos.IdServico.IdServico = 2;
            }
            string retorno = agendaNegocio.AgendaAlterar(agendaAlterar);

            try
            {
                int Id = Convert.ToInt32(retorno);
                MessageBox.Show("Alteração realizada com sucesso", "Alterar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DialogResult = DialogResult.Yes;
            }
            catch
            {
                MessageBox.Show("Erro ao alterar. Detalhes: " + retorno, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.No;
            }
        }