示例#1
0
        public List <MODEL.Servicos> Select()
        {
            List <MODEL.Servicos> lstServicos = new List <MODEL.Servicos>();
            SqlConnection         conexao     = new SqlConnection(strCon);
            string     sql = "SELECT * FROM Servicos";
            SqlCommand cmd = new SqlCommand(sql, conexao);

            try
            {
                conexao.Open();
                SqlDataReader dados = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (dados.Read())
                {
                    MODEL.Servicos servico = new MODEL.Servicos();
                    servico.idSer   = Convert.ToInt32(dados["idSer"].ToString());
                    servico.saida   = Convert.ToDateTime(dados["saida"].ToString());
                    servico.ordemID = Convert.ToInt32(dados["servicoID"].ToString());

                    //Camadas.DAL.Ordens dalOrd = new Ordens();
                    //Camadas.MODEL.Ordens ordem = dalOrd.SelectById(servico.ordemID);
                    //servico.nomeCli = cliente.nome;

                    lstServicos.Add(servico);
                }
            }
            catch
            {
                Console.WriteLine("Erro na consulta dos Serviços...");
            }
            finally
            {
                conexao.Close();
            }
            return(lstServicos);
        }
示例#2
0
        public void Update(MODEL.Servicos servicos)
        {
            SqlConnection conexao = new SqlConnection(strCon);
            string        sql     = "Update Servicos set nome=@nome, ";

            sql += " valor_unit=valor_unit,";
            sql += "observacao=@observacao where id=@id;";
            SqlCommand cmd = new SqlCommand(sql, conexao);

            cmd.Parameters.AddWithValue("@id", servicos.id);
            cmd.Parameters.AddWithValue("@nome", servicos.nome);
            cmd.Parameters.AddWithValue("@valor_unit", servicos.valor_unit);
            conexao.Open();
            try
            {
                cmd.ExecuteNonQuery();
            }
            catch
            {
                Console.WriteLine("Erro na atualização de Serviços");
            }
            finally
            {
                conexao.Close();
            }
        }
示例#3
0
        public List <MODEL.Servicos> Select()
        {
            List <MODEL.Servicos> lstservico = new List <MODEL.Servicos>();
            SqlConnection         conexao    = new SqlConnection(strCon);
            string     sql = "Select * From Servicos";
            SqlCommand cmd = new SqlCommand(sql, conexao);

            conexao.Open();
            try
            {
                SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);

                while (reader.Read())
                {
                    MODEL.Servicos servico = new MODEL.Servicos();
                    servico.id         = Convert.ToInt32(reader[0].ToString());
                    servico.nome       = reader["nome"].ToString();
                    servico.valor_unit = Convert.ToInt32(reader["valor_unit"].ToString());
                    servico.observacao = reader["observacao"].ToString();
                    lstservico.Add(servico);
                }
            }
            catch
            {
                Console.WriteLine("Deu erro na Seleção de Serviços...");
            }
            finally
            {
                conexao.Close();
            }

            return(lstservico);
        }
        public void Insert(MODEL.Servicos servico)
        {
            BLL.Ordens          bllOrdem  = new Ordens();
            List <MODEL.Ordens> lstOrdens = bllOrdem.SelectById(servico.ordemID);

            MODEL.Ordens ordem = lstOrdens[0];
            ordem.situacao = 2;
            bllOrdem.Update(ordem);

            DAL.Servicos dalSer = new DAL.Servicos();
            dalSer.Insert(servico);
        }
示例#5
0
        public void Delete(MODEL.Servicos servicos)
        {
            SqlConnection conexao = new SqlConnection(strCon);
            string        sql     = "Delete from Servicos where id=@id;";
            SqlCommand    cmd     = new SqlCommand(sql, conexao);

            cmd.Parameters.AddWithValue("@id", servicos.id);
            conexao.Open();
            try
            {
                cmd.ExecuteNonQuery();
            }
            catch
            {
                Console.WriteLine("Erro na Remoção de Serviços");
            }
            finally
            {
                conexao.Close();
            }
        }
示例#6
0
        public void Insert(MODEL.Servicos servico)
        {
            SqlConnection conexao = new SqlConnection(strCon);
            string        sql     = "INSERT INTO Servicos VALUES (@saida, @ordemID)";
            SqlCommand    cmd     = new SqlCommand(sql, conexao);

            cmd.Parameters.AddWithValue("@saida", servico.saida);
            cmd.Parameters.AddWithValue("@ordemID", servico.@ordemID);
            try
            {
                conexao.Open();
                cmd.ExecuteNonQuery();
            }
            catch
            {
                Console.WriteLine("Erro na inclusão do Serviço...");
            }
            finally
            {
                conexao.Close();
            }
        }
示例#7
0
        public void Update(MODEL.Servicos servico)
        {
            SqlConnection conexao = new SqlConnection(strCon);
            string        sql     = "UPDATE Servicos SET saida=@saida, ordemID=@ordemID WHERE idSer=@idSer";
            SqlCommand    cmd     = new SqlCommand(sql, conexao);

            cmd.Parameters.AddWithValue("@idSer", servico.idSer);
            cmd.Parameters.AddWithValue("@saida", servico.saida);
            cmd.Parameters.AddWithValue("@ordemID", servico.ordemID);
            try
            {
                conexao.Open();
                cmd.ExecuteNonQuery();
            }
            catch
            {
                Console.WriteLine("Erro na alteração da Ordem de Serviço...");
            }
            finally
            {
                conexao.Close();
            }
        }
示例#8
0
        public void Insert(MODEL.Servicos servicos)
        {
            SqlConnection conexao = new SqlConnection(strCon);
            string        sql     = "Insert into Servicos values (@nome, @valor_unit, @observacao);";
            SqlCommand    cmd     = new SqlCommand(sql, conexao);

            cmd.Parameters.AddWithValue("@nome", servicos.nome);
            cmd.Parameters.AddWithValue("@valor_unit", servicos.valor_unit);
            cmd.Parameters.AddWithValue("@observacao", servicos.observacao);

            conexao.Open();
            try
            {
                cmd.ExecuteNonQuery();
            }
            catch
            {
                Console.WriteLine("Deu erro na inserção de Serviços...");
            }
            finally
            {
                conexao.Close();
            }
        }
 public void Update(MODEL.Servicos servico)
 {
     DAL.Servicos dalSer = new DAL.Servicos();
     dalSer.Update(servico);
 }