Example #1
0
        public FormGerSessao(bool editavel, Sessão s)
        {
            salvar        = false;
            this.editavel = editavel;
            InitializeComponent();
            FillComboBox();
            TxtCod.Text     = s.Id.ToString();
            cbFilme.Text    = s.Filme.Nome;
            cbSala.Text     = s.Sala.Nome;
            dtpHorario.Text = s.Horario.ToString();
            if (s.PrecoEntrada < 100)
            {
                txtPreço.Text = "00" + s.PrecoEntrada.ToString();
            }
            else if (s.PrecoEntrada < 1000)
            {
                txtPreço.Text = "0" + s.PrecoEntrada.ToString();
            }
            else
            {
                txtPreço.Text = s.PrecoEntrada.ToString();
            }
            txtLugares.Visible = true;
            txtLugares.Text    = s.LugaresDisponiveis.ToString();

            if (editavel == false)
            {
                TxtCod.Enabled     = false;
                cbFilme.Enabled    = false;
                cbSala.Enabled     = false;
                dtpHorario.Enabled = false;
                txtPreço.Enabled   = false;
            }
        }
Example #2
0
        private void btnVisualizar_Click(object sender, EventArgs e)
        {
            Sessão        s    = DAO.Read((int.Parse(dgvSessao.CurrentRow.Cells[0].Value.ToString())));
            FormGerSessao form = new FormGerSessao(false, s);

            form.StartPosition = FormStartPosition.CenterParent;
            form.ShowDialog(this);
        }
Example #3
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            Sessão        s    = DAO.Read(int.Parse(dgvSessao.CurrentRow.Cells[0].Value.ToString()));
            FormGerSessao form = new FormGerSessao(true, s);

            form.StartPosition = FormStartPosition.CenterParent;
            form.ShowDialog(this);
            LoadDatabase();
            Fill("");
        }
Example #4
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            Sessão s = DAO.Read((int.Parse(dgvSessao.CurrentRow.Cells[0].Value.ToString())));

            if ((s.LugaresDisponiveis == 0) || (s.LugaresDisponiveis == s.Sala.QtddLugares))
            {
                s.Filme.RmvSessao(s);
                DAO.Delete(s.Id);
                LoadDatabase();
                Fill("");
            }
            else if (s.IngressosVendidos1 > 0)
            {
                MessageBox.Show("Impossivel Apagar sessão,ingressos já foram vendidos,quando os lugares se esgotarem a sessão será exibida e assim poderá ser apagada", "Inconsistencia", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #5
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            if ((string.IsNullOrEmpty(cbFilme.Text)) || string.IsNullOrEmpty(cbSala.Text) || string.IsNullOrEmpty(txtPreço.Text))
            {
                MessageBox.Show("Por favor, não deixe nenhum campo em branco", "Campos em branco", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (double.Parse(txtPreço.Text) <= 0)
            {
                MessageBox.Show("Por favor,digite um valor maior que 0", "Preço invalida", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (dtpHorario.Text == "00: 00")
            {
                MessageBox.Show("Por favor,digite um horario maior que 0", "Horario invalida", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                Sessão s = new Sessão();
                s.Filme        = DAOf.FindByName(cbFilme.Text);
                s.Sala         = DAOs.FindByName(cbSala.Text);
                s.Horario      = dtpHorario.Text;
                s.PrecoEntrada = (float.Parse(txtPreço.Text));


                if (salvar)
                {
                    s.LugaresDisponiveis = s.Sala.QtddLugares;
                    DAO.Create(s);
                    Dispose();
                }
                if (editavel)
                {
                    s.LugaresDisponiveis = int.Parse(txtLugares.Text);
                    s.Filme.RmvSessao(s);
                    s.Id = int.Parse(TxtCod.Text);
                    DAO.Update(s);
                    s.Filme.AddSessao(s);
                    Dispose();
                }
                if (!salvar && !editavel)
                {
                    Dispose();
                }
            }
        }
Example #6
0
 public void RmvSessao(Sessão s)
 {
     Sessoes.Remove(s);
 }
Example #7
0
 public void AddSessao(Sessão s)
 {
     Sessoes.Add(s);
 }