Exemplo n.º 1
0
        public DataTable PesquisarListaCompras(ModelListaCompras ListaCompras)
        {
            DataTable     DtTbListaCompras = new DataTable("ListaCompras");
            SqlConnection SqlCon           = new SqlConnection();

            try
            {
                SqlCon.ConnectionString = Dbstring.Cnx;
                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "ProcPesquisarCompras";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                SqlParameter ParPesquisar = new SqlParameter();
                ParPesquisar.ParameterName = "@PesquisarCompras";
                ParPesquisar.SqlDbType     = SqlDbType.VarChar;
                ParPesquisar.Size          = 75;
                ParPesquisar.Value         = ListaCompras.Pesquisar;
                SqlCmd.Parameters.Add(ParPesquisar);

                SqlDataAdapter SqlDat = new SqlDataAdapter(SqlCmd);
                SqlDat.Fill(DtTbListaCompras);
            }
            catch (Exception ex)
            {
                DtTbListaCompras = null;
            }
            return(DtTbListaCompras);
        }
Exemplo n.º 2
0
        public static string Excluir(int idcompras)
        {
            ModelListaCompras Obj = new Model.ModelListaCompras();

            Obj.IDCompras = idcompras;
            return(Obj.Excluir(Obj));
        }
Exemplo n.º 3
0
        public static string Inserir(string descricao, int fkcomponente, int quantidade, int executado)
        {
            ModelListaCompras Obj = new Model.ModelListaCompras();

            Obj.Descricao    = descricao;
            Obj.FKComponente = fkcomponente;
            Obj.Quantidade   = quantidade;
            Obj.Executado    = executado;
            return(Obj.Inserir(Obj));
        }
Exemplo n.º 4
0
        public string Excluir(ModelListaCompras ListaCompras)
        {
            string        resp   = "";
            SqlConnection SqlCon = new SqlConnection();

            try
            {
                SqlCon.ConnectionString = Dbstring.Cnx;
                SqlCon.Open();

                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "ProcExcluirCompras";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                SqlParameter ParIDCompras = new SqlParameter();
                ParIDCompras.ParameterName = "@IDCompras";
                ParIDCompras.SqlDbType     = SqlDbType.Int;
                ParIDCompras.Value         = ListaCompras.IDCompras;
                SqlCmd.Parameters.Add(ParIDCompras);

                resp = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "Cadastro não excluído!";
            }
            catch (Exception ex)
            {
                resp = ex.Message;
            }
            finally
            {
                if (SqlCon.State == ConnectionState.Open)
                {
                    SqlCon.Close();
                }
            }
            return(resp);
        }
Exemplo n.º 5
0
        public string Inserir(ModelListaCompras ListaCompras)
        {
            string        resp   = "";
            SqlConnection SqlCon = new SqlConnection();

            try
            {
                SqlCon.ConnectionString = Dbstring.Cnx;
                SqlCon.Open();

                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "ProcCadastrarCompras";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                SqlParameter ParIDCompras = new SqlParameter();
                ParIDCompras.ParameterName = "@IDCompras";
                ParIDCompras.SqlDbType     = SqlDbType.Int;
                ParIDCompras.Direction     = ParameterDirection.Output;
                SqlCmd.Parameters.Add(ParIDCompras);

                SqlParameter ParDescricao = new SqlParameter();
                ParDescricao.ParameterName = "@Descricao";
                ParDescricao.SqlDbType     = SqlDbType.VarChar;
                ParDescricao.Size          = 75;
                ParDescricao.Value         = ListaCompras.Descricao;
                SqlCmd.Parameters.Add(ParDescricao);

                SqlParameter ParQuantidade = new SqlParameter();
                ParQuantidade.ParameterName = "@Quantidade";
                ParQuantidade.SqlDbType     = SqlDbType.Int;
                ParQuantidade.Value         = ListaCompras.Quantidade;
                SqlCmd.Parameters.Add(ParQuantidade);

                SqlParameter ParExecutado = new SqlParameter();
                ParExecutado.ParameterName = "@Executado";
                ParExecutado.SqlDbType     = SqlDbType.Int;
                ParExecutado.Value         = ListaCompras.Executado;
                SqlCmd.Parameters.Add(ParExecutado);

                SqlParameter ParFKComponente = new SqlParameter();
                ParFKComponente.ParameterName = "@FKComponente";
                ParFKComponente.SqlDbType     = SqlDbType.Int;
                ParFKComponente.Value         = ListaCompras.FKComponente;
                SqlCmd.Parameters.Add(ParFKComponente);

                resp = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "Cadastro não realizado!";
            }
            catch (Exception ex)
            {
                resp = ex.Message;
            }
            finally
            {
                if (SqlCon.State == ConnectionState.Open)
                {
                    SqlCon.Close();
                }
            }
            return(resp);
        }