コード例 #1
0
        public static string Excluir(int idfabricante)
        {
            ModelFabricante Obj = new Model.ModelFabricante();

            Obj.IDFabricante = idfabricante;
            return(Obj.Excluir(Obj));
        }
コード例 #2
0
        public static string Inserir(string fabricante)
        {
            ModelFabricante Obj = new Model.ModelFabricante();

            Obj.Fabricante = fabricante;
            return(Obj.Inserir(Obj));
        }
コード例 #3
0
        public DataTable PesquisarFabricante(ModelFabricante Fabricante)
        {
            DataTable     DtTbFabricante = new DataTable("Fabricante");
            SqlConnection SqlCon         = new SqlConnection();

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

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

                SqlDataAdapter SqlDat = new SqlDataAdapter(SqlCmd);
                SqlDat.Fill(DtTbFabricante);
            }
            catch (Exception ex)
            {
                DtTbFabricante = null;
            }
            return(DtTbFabricante);
        }
コード例 #4
0
        public static string Editar(int idfabricante, string fabricante)
        {
            ModelFabricante Obj = new Model.ModelFabricante();

            Obj.IDFabricante = idfabricante;
            Obj.Fabricante   = fabricante;
            return(Obj.Editar(Obj));
        }
コード例 #5
0
        public string Editar(ModelFabricante Fabricante)
        {
            string        resp   = "";
            SqlConnection SqlCon = new SqlConnection();

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

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

                SqlParameter ParIDFabricante = new SqlParameter();
                ParIDFabricante.ParameterName = "@IDFabricante";
                ParIDFabricante.SqlDbType     = SqlDbType.Int;
                ParIDFabricante.Value         = Fabricante.IDFabricante;
                SqlCmd.Parameters.Add(ParIDFabricante);

                SqlParameter ParFabricante = new SqlParameter();
                ParFabricante.ParameterName = "@Fabricante";
                ParFabricante.SqlDbType     = SqlDbType.VarChar;
                ParFabricante.Size          = 75;
                ParFabricante.Value         = Fabricante.Fabricante;
                SqlCmd.Parameters.Add(ParFabricante);

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