Exemplo n.º 1
0
        public Boolean Altera(HorarioDTO pHorarioDTO)
        {
            try
            {
                 DataTable dt = new DataTable();
                 MySqlConnection Conexao = new MySqlConnection(StrCon);
                 StringBuilder vSQLCommand = new StringBuilder();
                 vSQLCommand.AppendLine("UPDATE horario SET");
                 vSQLCommand.AppendLine("HORARIO = @HORARIO ");
                 vSQLCommand.AppendLine(" WHERE 1 = 1 ");

                 if (pHorarioDTO.Identificador != default(int))
                       {
                          vSQLCommand.AppendLine("and idHorario = @idHorario ");
                       }

                 MySqlCommand com = new MySqlCommand(vSQLCommand.ToString(), Conexao);
                 com.Parameters.Add(new MySqlParameter("@idHorario", pHorarioDTO.Identificador));

                 com.Parameters.Add(new MySqlParameter("@Horario", pHorarioDTO.Horario));
                    Conexao.Open();
                    //dt.Load(com.ExecuteReader());
                    com.ExecuteReader();
                    Conexao.Close();

                    return true;
                }
                catch (Exception e)
                {
                    throw e;
                }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     data = Request.QueryString["data"];
     idHorario = Request.QueryString["idHorario"];
     idVenda = Request.QueryString["idVenda"];
     if (data == null || idHorario == null || idVenda == null)
     {
         ScriptManager.RegisterStartupScript(this, this.GetType(), "alerta", "alert('Dados para agendamento incompletos!'); window.location.href='"+PaginaDeAgendamento+"';", true);
     }
     else
     {
         AgendamentoCT agendamentoCT = new AgendamentoCT();
         DataTable dtFuncionariosDisponiveis = agendamentoCT.SelecionarPorFiltroDataHorario(data, idHorario);
         if (dtFuncionariosDisponiveis.Rows.Count == 0)
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "alerta", "alert('Funcionário indisponível para agendamento!'); window.location.href='" + PaginaDeAgendamento + "';", true);
         }
         else
         {
             ddlFuncionario.DataSource = dtFuncionariosDisponiveis;
             ddlFuncionario.DataValueField = "idFuncionario";
             ddlFuncionario.DataTextField = "nome";
             ddlFuncionario.DataBind();
             HorarioCT horarioCT = new HorarioCT();
             HorarioDTO horarioDTO = new HorarioDTO();
             horarioDTO.Identificador = Convert.ToInt32(idHorario);
             DataTable dtHorario = horarioCT.SelecionarPorFiltro(horarioDTO);
             if (dtHorario.Rows.Count > 0)
             {
                 txtHorario.Text = FormataHorario(dtHorario.Rows[0]["horario"].ToString());
             }
             txtData.Text = data;
         }
     }
 }
Exemplo n.º 3
0
        public Boolean Excluir(HorarioDTO pHorarioDTO)
        {
            try
            {
                DataTable dt = new DataTable();
                MySqlConnection Conexao = new MySqlConnection(StrCon);
                StringBuilder vSQLCommand = new StringBuilder();

                vSQLCommand.AppendLine("DELETE FROM horario");

                vSQLCommand.AppendLine(" WHERE 1 = 1 ");

                if (pHorarioDTO.Identificador != default(int))
                {
                    vSQLCommand.AppendLine("and idHorario = @idHorario ");
                }

                MySqlCommand com = new MySqlCommand(vSQLCommand.ToString(), Conexao);

                if (pHorarioDTO.Identificador != default(int))
                {
                    com.Parameters.Add(new MySqlParameter("@idHorario", pHorarioDTO.Identificador));
                }
                Conexao.Open();
                //dt.Load(com.ExecuteReader());
                com.ExecuteReader();
                Conexao.Close();

                return true;

            }
            catch (DataAccessException ex)
            {
                // Verifica se ocorreu erro de constraint
                if (ex.InnerException is SqlException)
                {
                    if (((SqlException)ex.InnerException).Number == 547)
                        throw new Exception();
                    else
                        throw;
                }
                else
                    throw;
            }
            catch (Exception e)
            {
                int pos = 0;
                pos = e.Message.ToString().IndexOf("Cannot delete or update a parent row: a foreign key constraint fails (");
                if (pos > 0)
                {
                    throw new Exception();
                }
                else
                throw new DataAccessException("Ocorreu um erro ao excluir o Cliente.", DataAccessExceptionLocation.DAO, e);
            }
        }
Exemplo n.º 4
0
 public DataTable SelecionarPorFiltroPesquisar(HorarioDTO pHorarioDTO)
 {
     try
     {
         return HorarioDAO.Selecionar(pHorarioDTO);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 5
0
 public Boolean Insere(HorarioDTO pHorarioDTO)
 {
     try
     {
         return HorarioDAO.Insere(pHorarioDTO);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 6
0
 public Boolean Excluir(HorarioDTO pHorarioDTO)
 {
     try
     {
         return HorarioDAO.Excluir(pHorarioDTO);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 7
0
 public Boolean Altera(HorarioDTO pHorarioDTO)
 {
     try
     {
         return HorarioDAO.Altera(pHorarioDTO);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 8
0
        public DataTable SelecionarPesquisar(HorarioDTO pHorarioDTO)
        {
            try
            {
                DataTable dt = new DataTable();
                MySqlConnection Conexao = new MySqlConnection(StrCon);

                StringBuilder vSQLCommand = new StringBuilder();
                vSQLCommand = new StringBuilder();
                vSQLCommand.AppendLine(" SELECT                    ");

                vSQLCommand.AppendLine(" IDHORARIO,");
                vSQLCommand.AppendLine(" HORARIO");

                vSQLCommand.AppendLine(" FROM HORARIO");

                vSQLCommand.AppendFormat(" WHERE (1=1) idHorario ");

                if (pHorarioDTO.Identificador!= default(int))
                    {
                        vSQLCommand.AppendLine("and idHorario = @idHorario ");
                    }

                MySqlCommand com = new MySqlCommand(vSQLCommand.ToString(), Conexao);

                if (pHorarioDTO.Identificador!= default(int))
                    {
                        com.Parameters.Add(new MySqlParameter("@idHorario", pHorarioDTO.Identificador));
                    }

                Conexao.Open();
                dt.Load(com.ExecuteReader());
                com.ExecuteReader();
                Conexao.Close();

                return dt;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 9
0
        public Boolean Insere(HorarioDTO pHorarioDTO)
        {
            try
            {
            MySqlConnection Conexao = new MySqlConnection(StrCon);
            StringBuilder vSQLCommand = new StringBuilder();
            vSQLCommand.AppendLine("INSERT INTO horario(");
            vSQLCommand.AppendLine("HORARIO) values (");
            //com.Parameters.Add(new MySqlParameter("@idHorario", pDTO.Identificador));
            vSQLCommand.AppendLine(" @Horario)");
            MySqlCommand com = new MySqlCommand(vSQLCommand.ToString(), Conexao);
            //com.Parameters.Add(new MySqlParameter("@idHorario", pDTO.Identificador));

            com.Parameters.Add(new MySqlParameter("@Horario", pHorarioDTO.Horario));
            Conexao.Open();
            //dt.Load(com.ExecuteReader());
            com.ExecuteReader();
            Conexao.Close();

            return true;
            }
            catch (Exception e)
            {

            throw e;
            }
        }